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();

### Hierarchy

- MessageBuilder

## Index

### Methods

- addMedia
- build
- buildAndSend
- setAttributes
- setBody
- setContentTemplate
- setEmailBody
- setEmailHistory
- setSubject

## Methods

### addMedia

- addMedia(payload: FormData | SendMediaOptions): MessageBuilder

- Adds media to the message.

  #### Parameters

  - ##### payload: FormData | SendMediaOptions

    Media to add.

  #### Returns MessageBuilder

### build

- build(): UnsentMessage

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

  #### Returns UnsentMessage

### buildAndSend

- buildAndSend(): CancellablePromise<number>

- Prepares a message and sends it to the conversation.

  #### Returns CancellablePromise<number>

### setAttributes

- setAttributes(attributes: JSONValue): MessageBuilder

- Sets the message attributes.

  #### Parameters

  - ##### attributes: JSONValue

    Message attributes.

  #### Returns MessageBuilder

### setBody

- setBody(text: string): MessageBuilder

- Sets the message body.

  #### Parameters

  - ##### text: string

    Contents of the body.

  #### Returns MessageBuilder

### setContentTemplate

- setContentTemplate(contentSid: string, contentVariables?: ContentTemplateVariable[]): 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

  - ##### contentVariables: ContentTemplateVariable[] = []

  #### Returns MessageBuilder

### setEmailBody

- setEmailBody(contentType: string, body: FormData | SendMediaOptions): 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

### setEmailHistory

- setEmailHistory(contentType: string, history: FormData | SendMediaOptions): 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

### setSubject

- setSubject(subject: string): MessageBuilder

- Sets the message subject.

  #### Parameters

  - ##### subject: string

    Contents of the subject.

  #### Returns MessageBuilder