Send a message
Sends one or more messages to a specific conversation.
Message types
You can send two types of messages to a conversation:
- a user message sent on behalf of a user;
- a system message sent on behalf of the application.
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:
- 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.
- Send a message that includes the attachmentToken you received when uploading the file.
Request
- Base URLhttps://api.talkjs.com
- Auth
- HTTP bearer
- or HTTP bearer
- TypeScriptA function with typed inputs. Its response is checked against the schema.
Path parameters
A unique identifier of your TalkJS app. You can find your app ID on the Settings page of your dashboard.
A unique identifier of a conversation.
Request body
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.
Example response
[
{
"id": "msg_123ABcdefghiJKlmNOpqRS"
}
]Changes
No recorded changes to this operation across all 1 revision of this API.