Messages

Send a message

Sends one or more messages to a specific conversation.

Message types

You can send two types of messages to a conversation:

You can send a batch of consecutive messages in a single request, and combine user messages and system messages in one request.

Deliver a message exactly once

If an initial request to send a message fails, you can retry your request. To avoid message duplication on retries, use the idempotencyKey field when sending the messages. You can retry sending a message with the same idempotencyKey any number of times, and it gets sent exactly once.

Make sure that your idempotencyKey is unique for a message within a conversation.

An idempotencyKey is associated with a specific message in a conversation for 24 hours. After 24 hours, you can associate the key with another message.

Attach a file to a message

To send a message with a file attachment, such as an image, video, or a document, take the following two steps:

  1. Upload the file you would like to attach to the TalkJS servers, using the 'Upload a file' resource. You'll receive an attachmentToken in response to the request.
  2. Send a message that includes the attachmentToken you received when uploading the file.
post/v1/{appId}/conversations/{conversationId}/messages

Request

Path parameters

appIdstring required
Example:abcd1234

A unique identifier of your TalkJS app. You can find your app ID on the Settings page of your dashboard.

conversationIdstring required
Example:0123456789abcdef

A unique identifier of a conversation.

Request body

OR

Example request

[
  {
    "text": "Great! Let's do that",
    "sender": "alice",
    "type": "UserMessage",
    "referencedMessageId": "msg_abcdefghijklm",
    "custom": {
      "reminder": true
    },
    "idempotencyKey": "one_message"
  }
]

Response

Message or messages sent successfully.

idstring

An automatically generated unique identifier of this message.

Example response

[
  {
    "id": "msg_123ABcdefghiJKlmNOpqRS"
  }
]

Changes

No recorded changes to this operation across all 1 revision of this API.