Skip to contentSkip to navigationSkip to topbar
Page toolsOn this page
Looking for more inspiration?Visit the

Agent Copilot: Knowledge resource (public beta)


(new)

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.

(warning)

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.


Knowledge properties

knowledge-properties page anchor
Property nameTypeRequiredPIIDescriptionChild properties
descriptionstring

Optional

Not PII

The type of knowledge source.


idstring
required

The description of knowledge.

Pattern: ^aia_know_.+$

accountSidSID<AC>

Optional

The SID of the Account that created the Knowledge resource.

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

knowledgeSourceDetailsobject

Optional

The details of the knowledge source based on the type.


namestring
required

The name of the knowledge source.


statusstring

Optional

The status of processing the knowledge source ('QUEUED', 'PROCESSING', 'COMPLETED', 'FAILED')


typestring
required

The type of knowledge source ('Web', 'Database', 'Text', 'File')


urlstring

Optional

The url of the knowledge resource.


embeddingModelstring

Optional

The embedding model to be used for the knowledge source.


dateUpdatedstring<date-time>
required

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


Create a new Knowledge source

create-a-new-knowledge-source page anchor

POST https://knowledge.twilio.com/v1/Knowledge

Request body parameters

request-body-parameters page anchor
Encoding type:application/json
Schema
Property nameTypeRequiredPIIDescriptionChild properties
descriptionstring

Optional

The description of the knowledge source.


knowledgeSourceDetailsobject

Optional

The details of the knowledge source based on the type.


namestring
required

The name of the tool.


policyobject

Optional

The policy associated with the knowledge source.


typestring
required

The type of the knowledge source.


embeddingModelstring

Optional

The 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.

Crawl a websiteLink to code sample: Crawl a website
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 createKnowledge() {
11
const knowledge = await client.knowledge.v1.knowledge.create({
12
name: "name",
13
type: "Web",
14
description: "Web description",
15
knowledge_source_details: {
16
source: "https://twilio.com",
17
},
18
});
19
20
console.log(knowledge.description);
21
}
22
23
createKnowledge();

Provide plain text for Agent Copilot.

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 createKnowledge() {
11
const knowledge = await client.knowledge.v1.knowledge.create({
12
name: "Help center article",
13
type: "Text",
14
description: "Text description",
15
knowledge_source_details: {
16
content: "Details of text source",
17
},
18
});
19
20
console.log(knowledge.description);
21
}
22
23
createKnowledge();

Upload a file for Agent Copilot to reference.

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 createKnowledge() {
11
const knowledge = await client.knowledge.v1.knowledge.create({
12
name: "My PDF",
13
type: "File",
14
description: "Use this for a PDF file",
15
knowledge_source_details: {
16
content_type: "application/pdf",
17
content_url: "https://example.com/myfile.pdf",
18
},
19
});
20
21
console.log(knowledge.description);
22
}
23
24
createKnowledge();

GET https://knowledge.twilio.com/v1/Knowledge/{id}

Property nameTypeRequiredPIIDescription
idstring
required

Fetch details about a single Knowledge source.

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 fetchKnowledge() {
11
const knowledge = await client.knowledge.v1.knowledge("id").fetch();
12
13
console.log(knowledge.description);
14
}
15
16
fetchKnowledge();

Response

Note about this 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
}

Fetch status of a Knowledge source

fetch-status-of-a-knowledge-source page anchor

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/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 fetchKnowledgeStatus() {
11
const knowledgeStatus = await client.knowledge.v1
12
.knowledge("id")
13
.knowledgeStatus()
14
.fetch();
15
16
console.log(knowledgeStatus.accountSid);
17
}
18
19
fetchKnowledgeStatus();

Response

Note about this 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

Property nameTypeRequiredPIIDescription
pageinteger

Optional

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

Minimum: 0

pageSizeinteger

Optional

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

Minimum: 1Maximum: 1000

pageTokenstring

Optional

The page token. This is provided by the API.


tagsstring

Optional

Json array of tag and value pairs for tag filtering.

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 listKnowledge() {
11
const knowledge = await client.knowledge.v1.knowledge.list({ limit: 20 });
12
13
knowledge.forEach((k) => console.log(k.description));
14
}
15
16
listKnowledge();

Response

Note about this 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}

Property nameTypeRequiredPIIDescription
idstring
required
Encoding type:application/json
Schema
Property nameTypeRequiredPIIDescriptionChild properties
descriptionstring

Optional

The description of the knowledge source.


knowledgeSourceDetailsobject

Optional

The details of the knowledge source based on the type.


namestring

Optional

The name of the knowledge source.


policyobject

Optional

The policy associated with the knowledge source.


typestring

Optional

The description of the knowledge source.


embeddingModelstring

Optional

The 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/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 updateKnowledge() {
11
const knowledge = await client.knowledge.v1.knowledge("id").update({
12
description: "description",
13
});
14
15
console.log(knowledge.description);
16
}
17
18
updateKnowledge();

Response

Note about this 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}

Property nameTypeRequiredPIIDescription
idstring
required

the Knowledge ID.

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 deleteKnowledge() {
11
await client.knowledge.v1.knowledge("id").remove();
12
}
13
14
deleteKnowledge();