Create and configure Assistants programatically using the REST API.
POST https://assistants.twilio.com/v1/Assistants
application/json
The Personalization and Perception Engine settings.
The Segment Credentials to be used for the assistant.
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 createAssistant() {11const assistant = await client.assistants.v1.assistants.create({12name: "Your first Assistant",13personality_prompt: "You are a helpful assistant.",14});1516console.log(assistant.accountSid);17}1819createAssistant();
1{2"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",3"customer_ai": {},4"date_created": "2009-07-06T20:30:00Z",5"date_updated": "2009-07-06T20:30:00Z",6"id": "aia_asst",7"model": "model",8"name": "name",9"owner": "owner",10"personality_prompt": "personality_prompt",11"url": "url"12}
GET https://assistants.twilio.com/v1/Assistants/{id}
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 fetchAssistant() {11const assistant = await client.assistants.v112.assistants("aia_asst_00000000-1111-2222-3333-444444444444")13.fetch();1415console.log(assistant.accountSid);16}1718fetchAssistant();
1{2"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",3"customer_ai": {},4"date_created": "2009-07-06T20:30:00Z",5"date_updated": "2009-07-06T20:30:00Z",6"id": "aia_asst_00000000-1111-2222-3333-444444444444",7"knowledge": [8{9"description": "description",10"id": "aia_know",11"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",12"knowledge_source_details": {},13"name": "name",14"status": "status",15"type": "type",16"url": "url",17"date_created": "2009-07-06T20:30:00Z",18"date_updated": "2009-07-06T20:30:00Z"19}20],21"model": "model",22"name": "name",23"owner": "owner",24"personality_prompt": "personality_prompt",25"tools": [26{27"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",28"description": "description",29"enabled": false,30"id": "aia_tool",31"meta": {},32"name": "name",33"requires_auth": false,34"type": "type",35"url": "url",36"date_created": "2009-07-06T20:30:00Z",37"date_updated": "2009-07-06T20:30:00Z"38}39],40"url": "url"41}
GET https://assistants.twilio.com/v1/Assistants
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 listAssistants() {11const assistants = await client.assistants.v1.assistants.list({ limit: 20 });1213assistants.forEach((a) => console.log(a.accountSid));14}1516listAssistants();
1{2"assistants": [3{4"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",5"customer_ai": {},6"id": "aia_asst",7"model": "model",8"name": "name",9"owner": "owner",10"url": "url",11"personality_prompt": "personality_prompt",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}
DELETE https://assistants.twilio.com/v1/Assistants/{id}
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 deleteAssistant() {11await client.assistants.v112.assistants("aia_asst_00000000-1111-2222-3333-444444444444")13.remove();14}1516deleteAssistant();