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
- 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. - 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.",}); - Add the tool to your agent's
tools, and tell it to read the document it finds:agents/support.tsimport { 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 },}); - Start the project with
npm run dev. - Open Chat in Studio.
- Pick Support assistant.
- Ask "How many days do I have to return an item?". You should now see it call
search_knowledgeand reply 45 days.
Try it in a sandbox
Create a project
Add the document
Add the search tool
Add it to your agent
Start it
Ask it