Add knowledge

Add a document to a project as knowledge, so an agent can search it and answer from it.

Before you start

You need an agent. See Create an agent.

Add knowledge

  1. Add the document under knowledge/:
    knowledge/returns-policy.md
    ---title: Returns policydescription: How long customers have to return an item, and when refunds arrive.--- Returns are accepted within 45 days of delivery.Refunds are issued to the original payment method within 5 business days of approval.
  2. Give your agent a search tool for it:
    tools/search_knowledge.ts
    import { createSearchKnowledgeTool } from "veryfront/knowledge"; export default createSearchKnowledgeTool({  id: "search_knowledge",  description: "Search the project's returns and refunds policy.",});
  3. Add the tool to your agent's tools, and tell it to read the document it finds:
    agents/support.ts
    import { agent } from "veryfront/agent"; export default agent({  id: "support",  name: "Support assistant",  system: "Answer customer questions about orders and refunds from the project's knowledge. Find the document with search_knowledge, then read it by its path before you answer. Keep replies to two sentences.",  tools: { search_knowledge: true },});
  4. Start the project with npm run dev.
  5. Open Chat in Studio.
  6. Pick Support assistant.
  7. Ask "How many days do I have to return an item?". You should now see it call search_knowledge and reply 45 days.

Try it in a sandbox

  1. Create a project

  2. Add the document

  3. Add the search tool

  4. Add it to your agent

  5. Start it

  6. Ask it

Try it out

Next steps