Skip to contentSkip to navigationSkip to topbar
On this page

Conversation History


This API returns the Conversation History for a given session. Conversation History contains a list of all Messages (both user and Assistant-generated) as well as Tool and Knowledge calls from the provided session.

The API returns Tool and Knowledge calls as Messages, where the role property is either tool or knowledge, respectively.


Message Properties

message-properties page anchor
Property nameTypeRequiredDescriptionChild properties
idstringOptional
Not PII

The message ID.

Pattern: ^aia_msg_*$

account_sidSID<AC>Optional

The SID of the Account that created the Message resource.

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

assistant_idstringOptional

The Assistant ID.

Pattern: ^aia_asst_*$

session_idstringOptional

The Session ID.


identitystringOptional

The identity of the user.


rolestringOptional

The role of the user associated with the message.


contentobjectOptional

The content of the message.


metaobjectOptional

The metadata of the message.


date_updatedstring<date-time>Optional

The date and time in GMT when the Message was last updated specified in ISO 8601(link takes you to an external page) format.


GET https://assistants.twilio.com/v1/Sessions/{sessionId}/Messages

Path parameters

path-parameters page anchor
Property nameTypeRequiredPIIDescription
sessionIdstringrequired

Session id or name

Property nameTypeRequiredPIIDescription
PageintegerOptional

The page index. This value is simply for client state.

Minimum: 0

PageSizeintegerOptional

How many resources to return in each list page. The default is 50, and the maximum is 1000.

Minimum: 1Maximum: 1000

PageTokenstringOptional

The page token. This is provided by the API.

List multiple MessagesLink to code sample: List multiple Messages
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 listMessages() {
11
const messages = await client.assistants.v1
12
.sessions("sessionId")
13
.messages.list({ limit: 20 });
14
15
messages.forEach((m) => console.log(m.id));
16
}
17
18
listMessages();

Output

1
{
2
"messages": [
3
{
4
"id": "aia_msg",
5
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
6
"assistant_id": "aia_asst",
7
"session_id": "session_id",
8
"identity": "identity",
9
"role": "role",
10
"content": {},
11
"meta": {},
12
"date_created": "2009-07-06T20:30:00Z",
13
"date_updated": "2009-07-06T20:30:00Z"
14
}
15
],
16
"meta": {
17
"first_page_url": "https://www.example.com",
18
"key": "key",
19
"next_page_url": "https://www.example.com",
20
"page": 42,
21
"page_size": 42,
22
"previous_page_url": "https://www.example.com",
23
"url": "https://www.example.com"
24
}
25
}

Need some help?

Terms of service

Copyright © 2024 Twilio Inc.