A message in a conversation.

### Hierarchy

- ReplayEventEmitter<MessageEvents>
  - Message

## Index

### Properties

- conversation
- updated

### Accessors

- aggregatedDeliveryReceipt
- attachedMedia
- attributes
- author
- body
- contentSid
- dateCreated
- dateUpdated
- index
- lastUpdatedBy
- media
- participantSid
- sid
- subject
- type

### Methods

- getChannelMetadata
- getContentData
- getDetailedDeliveryReceipts
- getEmailBody
- getEmailHistory
- getMediaByCategories
- getMessageRecipients
- getParticipant
- getTemporaryContentUrlsForAttachedMedia
- getTemporaryContentUrlsForMedia
- getTemporaryContentUrlsForMediaSids
- remove
- updateAttributes
- updateBody

## Properties

### Readonly conversation

conversation: Conversation

Conversation that the message is in.

### Static Readonly updated

updated: "updated" = "updated"

Fired when the properties or the body of the message has been updated.

Parameters:

1. object `data` - info object provided with the event. It has the following properties:
   - Message message - the message in question
   - MessageUpdateReason[] updateReasons - array of reasons for the update

## Accessors

### aggregatedDeliveryReceipt

- get aggregatedDeliveryReceipt(): AggregatedDeliveryReceipt

- Aggregated information about the message delivery statuses across all participants of a conversation..

  #### Returns AggregatedDeliveryReceipt

### attachedMedia

- get attachedMedia(): Media[]

- Return all media attachments, except email body/history attachments, without temporary urls.

  #### Returns Media[]

### attributes

- get attributes(): JSONValue

- Custom attributes of the message.

  #### Returns JSONValue

### author

- get author(): string

- Name of the user that sent the message.

  #### Returns string

### body

- get body(): string

- Body of the message.

  #### Returns string

### contentSid

- get contentSid(): string

- Unique identifier of ContentTemplate for this message.

  #### Returns string

### dateCreated

- get dateCreated(): Date

- Date this message was created on.

  #### Returns Date

### dateUpdated

- get dateUpdated(): Date

- Date this message was last updated on.

  #### Returns Date

### index

- get index(): number

- Index of this message in the conversation's list of messages.

  By design, the message indices may have arbitrary gaps between them, that does not necessarily mean they were deleted or otherwise modified - just that messages may have some non-contiguous indices even if they are being sent immediately one after another.

  Trying to use indices for some calculations is going to be unreliable.

  To calculate the number of unread messages, it is better to use the Read Horizon API. See Conversation.getUnreadMessagesCount for details.

  #### Returns number

### lastUpdatedBy

- get lastUpdatedBy(): string

- Identity of the last user that updated the message.

  #### Returns string

### media

- get media(): Media

- One of the attached media (if present).

  deprecated

    Use attachedMedia instead. Note that the latter is now an array.

  #### Returns Media

### participantSid

- get participantSid(): string

- The server-assigned unique identifier of the authoring participant.

  #### Returns string

### sid

- get sid(): string

- The server-assigned unique identifier for the message.

  #### Returns string

### subject

- get subject(): string

- Message subject. Used only in email conversations.

  #### Returns string

### type

- get type(): MessageType

- Type of the message.

  #### Returns MessageType

## Methods

### getChannelMetadata

- getChannelMetadata(): Promise<ChannelMetadata>

- Get the ChannelMetadata for this message. Resolves to `null` if the message doesn't have any channel metadata.

  #### Returns Promise<ChannelMetadata>

### getContentData

- getContentData(): CancellablePromise<ContentData>

- Get the ContentData for this message. Resolves to `null` when Message.contentSid is null.

  #### Returns CancellablePromise<ContentData>

### getDetailedDeliveryReceipts

- getDetailedDeliveryReceipts(): Promise<DetailedDeliveryReceipt[]>

- Get the delivery receipts of the message.

  #### Returns Promise<DetailedDeliveryReceipt[]>

### getEmailBody

- getEmailBody(type?: string): Media

- Get a media descriptor for an email body attachment of a provided type. Allowed body types are returned in the Conversation.limits().emailBodiesAllowedContentTypes array.

  #### Parameters

  - ##### type: string = "text/plain"

    Type of email body to request, defaults to `text/plain`.

  #### Returns Media

### getEmailHistory

- getEmailHistory(type?: string): Media

- Get a media descriptor for an email history attachment of a provided type. Allowed body types are returned in the Conversation.limits().emailHistoriesAllowedContentTypes array.

  #### Parameters

  - ##### type: string = "text/plain"

    Type of email history to request, defaults to `text/plain`.

  #### Returns Media

### getMediaByCategories

- getMediaByCategories(categories: MediaCategory[]): Media[]

- Return a (possibly empty) array of media matching a specific set of categories. Allowed category is so far only 'media'.

  #### Parameters

  - ##### categories: MediaCategory[]

    Array of categories to match.

  #### Returns Media[]

  Array of media descriptors matching given categories.

### getMessageRecipients

- getMessageRecipients(): Promise<RecipientDescriptor[]>

- Get recipients of the message.

  #### Returns Promise<RecipientDescriptor[]>

### getParticipant

- getParticipant(): Promise<Participant>

- Get the participant who is the author of the message.

  #### Returns Promise<Participant>

### getTemporaryContentUrlsForAttachedMedia

- getTemporaryContentUrlsForAttachedMedia(): CancellablePromise<Map<string, string>>

- Get content URLs for all media attached to the message.

  #### Returns CancellablePromise<Map<string, string>>

### getTemporaryContentUrlsForMedia

- getTemporaryContentUrlsForMedia(contentSet: Media[]): CancellablePromise<Map<string, string>>

- Get content URLs for all media attachments in the given set using a single operation.

  #### Parameters

  - ##### contentSet: Media[]

    Set of media attachments to query content URLs.

  #### Returns CancellablePromise<Map<string, string>>

### getTemporaryContentUrlsForMediaSids

- getTemporaryContentUrlsForMediaSids(mediaSids: string[]): CancellablePromise<Map<string, string>>

- Get content URLs for all media attachments in the given set of media sids using a single operation.

  #### Parameters

  - ##### mediaSids: string[]

    Set of media sids to query for the content URL.

  #### Returns CancellablePromise<Map<string, string>>

### remove

- remove(): Promise<Message>

- Remove the message.

  #### Returns Promise<Message>

### updateAttributes

- updateAttributes(attributes: JSONValue): Promise<Message>

- Edit the message attributes.

  #### Parameters

  - ##### attributes: JSONValue

    New attributes.

  #### Returns Promise<Message>

### updateBody

- updateBody(body: string): Promise<Message>

- Edit the message body.

  #### Parameters

  - ##### body: string

    New body of the message.

  #### Returns Promise<Message>