Knowledge Overview πŸ“™

✴️ What is Knowledge


Knowledge API endpoints help to create a knowledge base for an agent by processing documents or websites you upload. They use RAG (Retrieval-Augmented Generation) technology to break down the documents into pieces(chunks), place these pieces in a special vector database, and organize them in a way that the agent can easily use as memory. Knowledge API also allows for adding, removing, and organizing the information within the agent's knowledge base.

✴️ See a Working Example

Live Agents
Converse with real AI Agents

Live Agent embedded on D-ID's website
Make a live conversation with a real AI Agent on D-ID's website, ask related questions, and be inspired by its relevant knowledge, quality, latency, and the potential it could benefit your users in your platform. Check it out now!

Create your own Agent in D-ID's Studio
Anyone can create an agent, without any special knowledge or skills. Creating an agent is as easy as selecting a role, giving the agent instructions, and uploading documents that constitute its knowledge base. Try it out!

✴️ Ready to Start

Create a Knowledge
And bind it with your Agent in 3 steps only



✴️ Step 1: Create a new Knowledge Base

To create a new knowledge base, make a POST request to Create a Knowledge endpoint. In the request’s body, provide the knowledge base name and description, keep it meaningful! The response will contain a unique id for the created knowledge base - referred to as knowledgeId in other requests.

POST https://api.d-id.com/knowledge | Create a Knowledge

{
  name: "CVBasedKnowledge",
  description: "This knowledge base contains information from my CV",
}
{
  created: "2024-02-22T10:09:45.778Z",
  created_by: "google-oauth2|1004592475295613957286",
  description: "This knowledge base contains information from my CV",
  name: "CVBasedKnowledge",
  modified: "2024-02-22T10:09:45.778Z",
  type: "knowledge",
  status: "",
  owner_id: "google-oauth2|1004592475295613957286",
  id: "knl_91YI41kaS8CuJtCS9SRz8"
}

✴️ Step 2: Add Documents to the Knowledge Base

After creating the knowledge base container, now it's time to add documents to it. The Agent will answer users' questions based on the information from these documents. To add a document to your knowledge base, make a POST request to Create a Document endpoint. In the request’s body, provide the document’s title, file's type (PDF / TXT / etc.) and its source_url. The response will contain a unique id for the created document in the following format: "knl_12345#doc_12345". The split part after the '#' , starting with "doc" is referred to as documentId in other requests. Code example:

POSThttps://api.d-id.com/knowledge/{knowledgeId}/documents | Create a Document

{
  "documentType": "pdf",
  "source_url": "https://yourwebsite.com/title.pdf",
  "title": "document_title",
  "webhook":"https://host.domain.tld/to/webhook"
 }
{
  created: '2024-02-21T10:44:55.899Z',
  documentType: 'pdf',
  source_url: 'https://yourwebsite.com/title.pdf',
  created_by: 'google-oauth2|1004592475295613957286',
  modified: '2024-02-21T10:44:55.899Z',
  title: 'Hotel',
  type: 'document',
  status: 'processing',
  owner_id: 'google-oauth2|1004592475295613957286',
  id: 'knl_vHfds74Or80_5tFFF3Sac#doc_4MjLSEgsZneXdB_lIdINmNY'
}

πŸ‘

Use Webhooks!

You can create an endpoint on your side and add it in the webhook field, then the webhook endpoint will be triggered with the same response body once the document is ready.


✴️ Step 3: Retrieving the Document and Knowledge status

Knowledge should have "status" : "done"to bind this knowledge with your created Agents. The Knowledge's status is determined by its documents' statuses, once they all have "status" : "done", the Knowledge's status becomes "done" as well. To check the documents' statuses, please provide a webhook for each document in the previous step, and collect the responses.

{
  created: '2024-02-21T10:44:55.899Z',
  documentType: 'pdf',
  source_url: 'https://yourwebsite.com/title.pdf',
  created_by: 'google-oauth2|1004592475295613957286',
  modified: '2024-02-21T10:44:55.899Z',
  title: 'Hotel',
  type: 'document',
  status: 'done',
  owner_id: 'google-oauth2|1004592475295613957286',
  id: 'knl_vHfds74Or80_5tFFF3Sac#doc_4MjLSEgsZneXdB_lIdINmNY'
}

Alternatively, if you didn't use the webhook option in the previous step, you can utilize the Get Documents endpoint (to see all your Documents), or Get a Document endpoint (to see only a specific one). Once ALL of the created documents' webhooks had been fired or if all of the documents' statuses are "done",
then proceed to check the Knowledge status in the Get a Knowledge endpoint:

GEThttps://api.d-id.com/knowledge/{knowledgeId}/ | Get a Knowledge

{
  created: "2024-02-22T10:09:45.778Z",
  created_by: "google-oauth2|1004592475295613957286",
  description: "This knowledge base contains information from my CV",
  name: "CVBasedKnowledge",
  modified: "2024-02-22T10:09:45.778Z",
  type: "knowledge",
  status: "done",
  owner_id: "google-oauth2|1004592475295613957286",
  id: "knl_91YI41kaS8CuJtCS9SRz8"
}

Once the knowledge status is "done", you can proceed to bind Agent with Knowledge Base



✴️ Support


Have any questions? We are here to help! Please leave your question in the Discussions section and we will be happy to answer shortly.

Ask a question