Agent Copilot: Knowledge resource (public beta)
Public Beta
Agent Copilot is currently available as a Public Beta product and the information contained in this document is subject to change. This means that some features are not yet implemented and others may be changed before the product is declared as Generally Available. Public Beta products are not covered by a SLA.
Not a HIPAA Eligible Service or PCI Compliant
Agent Copilot is not a HIPAA Eligible Service or PCI compliant and should not be used in Flex workflows that are subject to HIPAA or PCI. However, we offer mitigation tools such as PII redaction. To learn more, see AI data use.
The Knowledge API lets you programmatically upload your unstructured data sources for Agent Copilot to use.
The SID of the Account that created the Knowledge resource.
^AC[0-9a-fA-F]{32}$Min length: 34Max length: 34The status of processing the knowledge source ('QUEUED', 'PROCESSING', 'COMPLETED', 'FAILED')
The date and time in GMT when the Knowledge was created specified in ISO 8601 format.
POST https://knowledge.twilio.com/v1/Knowledge
application/jsonThe embedding model to be used for the knowledge source. It's required for 'Database' type but disallowed for other types.
From the API, you can create the following type of Knowledge sources: Web, Text, and File.
Give Agent Copilot a publicly accessible URL to index information from.
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 createKnowledge() {11const knowledge = await client.knowledge.v1.knowledge.create({12name: "name",13type: "Web",14description: "Web description",15knowledge_source_details: {16source: "https://twilio.com",17},18});1920console.log(knowledge.description);21}2223createKnowledge();
Provide plain text for Agent Copilot.
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 createKnowledge() {11const knowledge = await client.knowledge.v1.knowledge.create({12name: "Help center article",13type: "Text",14description: "Text description",15knowledge_source_details: {16content: "Details of text source",17},18});1920console.log(knowledge.description);21}2223createKnowledge();
Upload a file for Agent Copilot to reference.
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 createKnowledge() {11const knowledge = await client.knowledge.v1.knowledge.create({12name: "My PDF",13type: "File",14description: "Use this for a PDF file",15knowledge_source_details: {16content_type: "application/pdf",17content_url: "https://example.com/myfile.pdf",18},19});2021console.log(knowledge.description);22}2324createKnowledge();
GET https://knowledge.twilio.com/v1/Knowledge/{id}
Fetch details about a single Knowledge source.
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 fetchKnowledge() {11const knowledge = await client.knowledge.v1.knowledge("id").fetch();1213console.log(knowledge.description);14}1516fetchKnowledge();
Response
1{2"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",3"date_created": "2009-07-06T20:30:00Z",4"date_updated": "2009-07-06T20:30:00Z",5"description": "description",6"embedding_model": "embedding_model",7"id": "id",8"knowledge_source_details": {},9"name": "Miss Christine Morgan",10"status": "status",11"type": "type",12"url": "https://www.example.com"13}
GET https://knowledge.twilio.com/v1/Knowledge/{id}/Status
When you create a Knowledge source, Twilio processes the Knowledge so it's accessible to Agent Copilot. You can fetch the status of processing for a given Knowledge source.
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 fetchKnowledgeStatus() {11const knowledgeStatus = await client.knowledge.v112.knowledge("id")13.knowledgeStatus()14.fetch();1516console.log(knowledgeStatus.accountSid);17}1819fetchKnowledgeStatus();
Response
1{2"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",3"date_updated": "2009-07-06T20:30:00Z",4"last_status": "last_status",5"status": "status"6}
GET https://knowledge.twilio.com/v1/Knowledge
How many resources to return in each list page. The default is 50, and the maximum is 1000.
1Maximum: 1000Json array of tag and value pairs for tag filtering.
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 listKnowledge() {11const knowledge = await client.knowledge.v1.knowledge.list({ limit: 20 });1213knowledge.forEach((k) => console.log(k.description));14}1516listKnowledge();
Response
1{2"knowledge": [3{4"description": "description",5"id": "aia_know_#",6"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",7"knowledge_source_details": {},8"name": "name",9"status": "status",10"type": "type",11"url": "https://www.example.com",12"embedding_model": "embedding_model",13"date_created": "2009-07-06T20:30:00Z",14"date_updated": "2009-07-06T20:30:00Z"15}16],17"meta": {18"first_page_url": "https://www.example.com",19"key": "key",20"next_page_url": "https://www.example.com",21"page": 42,22"page_size": 42,23"previous_page_url": "https://www.example.com",24"url": "https://www.example.com"25}26}
PUT https://knowledge.twilio.com/v1/Knowledge/{id}
application/jsonThe embedding model to be used for the knowledge source. It's only applicable to 'Database' type.
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 updateKnowledge() {11const knowledge = await client.knowledge.v1.knowledge("id").update({12description: "description",13});1415console.log(knowledge.description);16}1718updateKnowledge();
Response
1{2"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",3"date_created": "2009-07-06T20:30:00Z",4"date_updated": "2009-07-06T20:30:00Z",5"description": "description",6"embedding_model": "embedding_model",7"id": "id",8"knowledge_source_details": {},9"name": "Miss Christine Morgan",10"status": "status",11"type": "type",12"url": "https://www.example.com"13}
DELETE https://knowledge.twilio.com/v1/Knowledge/{id}
the Knowledge 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 deleteKnowledge() {11await client.knowledge.v1.knowledge("id").remove();12}1314deleteKnowledge();