Skip to contentSkip to navigationSkip to topbar
On this page

Messages Resource


Send a message to an Assistant


Message Properties

message-properties page anchor
Property nameTypeRequiredDescriptionChild properties
statusstring
required
Not PII

success or failure based on whether the request successfully generated a response.


flaggedboolean

Optional

If successful, this property will denote whether the response was flagged or not.


abortedboolean

Optional

This property will denote whether the request was aborted or not.


sessionIdstring
required

The unique name for the session.


accountSidSID<AC>
required

The SID of the Account that sent the Message.

Pattern: ^AC[0-9a-fA-F]{32}$Min length: 34Max length: 34

bodystring

Optional

If successful, the body of the generated response


errorstring

Optional

The error message if generation was not successful


Send a message to the Assistant

send-a-message-to-the-assistant page anchor

POST https://assistants.twilio.com/v1/Assistants/{id}/Messages

Path parameters

path-parameters page anchor
Property nameTypeRequiredPIIDescription
idstring
required

the Assistant ID.

Encoding type:application/json
Schema
Property nameTypeRequiredDescriptionChild properties
identitystring
required

The unique identity of user for the session.


sessionIdstring

Optional

The unique name for the session.


bodystring
required

The query to ask the assistant.


webhookstring

Optional

The webhook url to call after the assistant has generated a response or report an error.


modestring

Optional

one of the modes 'chat', 'email' or 'voice'

Default: chat
Send a message to the AssistantLink to code sample: Send a message to the Assistant
1
// Download the helper library from https://www.twilio.com/docs/node/install
2
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
3
4
// Find your Account SID and Auth Token at twilio.com/console
5
// and set the environment variables. See http://twil.io/secure
6
const accountSid = process.env.TWILIO_ACCOUNT_SID;
7
const authToken = process.env.TWILIO_AUTH_TOKEN;
8
const client = twilio(accountSid, authToken);
9
10
async function createMessage() {
11
const message = await client.assistants.v1
12
.assistants("aia_asst_00000000-1111-2222-3333-444444444444")
13
.messages.create({
14
identity: "email:test@api.com",
15
body: "When was Twilio founded?",
16
});
17
18
console.log(message.status);
19
}
20
21
createMessage();

Response

1
{
2
"aborted": false,
3
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
4
"body": "This will be the body of the new message!",
5
"error": "error",
6
"flagged": false,
7
"session_id": "session_id",
8
"status": "status"
9
}