@twilio/flex-sdk
    Preparing search index...

    Class MessageBuilder

    Message builder. Allows the message to be built and sent via method chaining.

    Example:

    await testConversation.prepareMessage()
    .setBody('Hello!')
    .setAttributes({foo: 'bar'})
    .addMedia(media1)
    .addMedia(media2)
    .build()
    .send();
    Index

    Constructors

    • Internal

      Parameters

      • limits: ConversationLimits
      • messagesEntity: Messages

      Returns MessageBuilder

    Methods

    • Adds media to the message.

      Parameters

      • payload: FormData | SendMediaOptions

        Media to add.

      Returns MessageBuilder

    • Builds the message, making it ready to be sent.

      Returns UnsentMessage

    • Prepares a message and sends it to the conversation.

      Returns CancellablePromise<null | number>

    • Sets the message attributes.

      Parameters

      • attributes: JSONValue

        Message attributes.

      Returns MessageBuilder

    • Adds ContentTemplate SID for the message alongside optional variables. When no variables provided, the default values will be used.

      Adding the content SID converts the message to a rich message. In this case, other fields are ignored and the message is sent using the content from the the ContentTemplate.

      Use Client.getContentTemplates to request all available ContentTemplates.

      Parameters

      • contentSid: string

        SID of the ContentTemplate

      • OptionalcontentVariables: ContentTemplateVariable[]

      Returns MessageBuilder

    • Set the email body with a given content type.

      Parameters

      • contentType: string

        Format of the body to set (text/plain or text/html).

      • body: FormData | SendMediaOptions

        Body payload in the selected format.

      Returns MessageBuilder

    • Set the email history with a given content type.

      Parameters

      • contentType: string

        Format of the history to set (text/plain or text/html).

      • history: FormData | SendMediaOptions

        History payload in the selected format.

      Returns MessageBuilder

    • Sets the message subject.

      Parameters

      • subject: string

        Contents of the subject.

      Returns MessageBuilder