メニュー

Expand
ページを評価:

Sending Messages and Media

Using the SDK, you can craft messages with text and/or media attachments and send them to other participants in your Conversation.

Send a text Message

If you’d like to send your Message as a one-shot method call, you can use this basic method.

        
        
        

        We also provide a more flexible method that allows you to programmatically build your message. This method is more robust and is typically ideal for most use cases.

        Message Builder

        The Message Builder class allows you to build a new text and/or media Message and makes the Message ready to be sent to the Conversation.

        When creating the MessageBuilder object, you’ll set each property of the message individually. For example, you’ll set the body and the message attributes separately.

              
              
              

              Media Message

              You can add photos, videos, and other types of media files to your Conversation. Media is displayed seamlessly between all participating channels.

              Send a Media Message

              To add a media Message (i.e. photos, videos) to your Conversation, you’ll need to create a Message and add a media file, filename and content type to the Message Builder.

                    
                    
                    

                    Each SDK accepts media input differently:

                    For JS, use:

                    • A String or Node.js Buffer containing a media byte stream
                    • A new FormData object containing file information: filename, content-type, size, and all required FormData information

                    For iOS, use:

                    • an InputStream
                    • an NSInputStream-compliant stream
                    • an NSData buffer

                    For Android, use:

                    • any java.io.InputStream-compliant stream

                    Send Multiple Media Messages

                    The maximum combined size of attachments is 150 MB.

                    You can also attach multiple media items to a single message by using the Message Builder.

                          
                          
                          

                          Retrieve Media Message Content

                          You can get a short-lived, temporary URL to download the media content in a Conversation.

                          If a message has more than one attachment, an array of media Messages can be retrieved, but it has to match the specific category of media.

                          media is currently the only category available

                          You can use your preferred method to retrieve the content from the temporary URL and render it in your UI.

                                
                                
                                

                                Media Limits

                                Conversations is a cross-channel messaging product, so each channel has a different set of limitations about incoming media files. Please refer to the Media Limits documentation for channel-specific information and supported file types.

                                セキュリティ

                                Media content is encrypted and can not be downloaded directly. When required, only authenticated users can generate temporary/expiring URLs to download the media content. The temporary URLs are valid for 300 seconds, after which a new temporary URL must be requested.

                                関連トピック

                                Let’s learn other features in Twilio Conversations:

                                ページを評価:

                                ヘルプが必要ですか?

                                We all do sometimes; code is hard. Get help now from our support team, or lean on the wisdom of the crowd by visiting Twilio's Stack Overflow Collective or browsing the Twilio tag on Stack Overflow.

                                      
                                      
                                      

                                      フィードバックくださりありがとうございます!

                                      Please select the reason(s) for your feedback. The additional information you provide helps us improve our documentation:

                                      Sending your feedback...
                                      🎉 Thank you for your feedback!
                                      Something went wrong. Please try again.

                                      Thanks for your feedback!

                                      Refer us and get $10 in 3 simple steps!

                                      ステップ1

                                      Get link

                                      Get a free personal referral link here

                                      ステップ2:

                                      Give $10

                                      Your user signs up and upgrade using link

                                      ステップ3

                                      Get $10

                                      1,250 free SMSes
                                      OR 1,000 free voice mins
                                      OR 12,000 chats
                                      OR more