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.
GET https://assistants.twilio.com/v1/Sessions/{sessionId}/Messages
Session id or name
How many resources to return in each list page. The default is 50, and the maximum is 1000.
1
Maximum: 1000
The page token. This is provided by the API.
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function listMessages() {11const messages = await client.assistants.v112.sessions("sessionId")13.messages.list({ limit: 20 });1415messages.forEach((m) => console.log(m.id));16}1718listMessages();
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}