Knowledge Support Agent
Describe a support issue in Mastra Studio and get a next step grounded in your team's guides, policies, and past cases. The support agent searches Mastra Knowledge, cites the pages it uses, and asks follow-up questions to narrow down the problem.
Why we built this
When a fix lives in a closed ticket or an old chat, the next technician may have to investigate the same problem from scratch. With Mastra Knowledge, a reviewer can turn a confirmed fix into guidance that other technicians can find in future conversations.
Teams can share guides while limiting access to each customer's case history. Pinned policies keep standing rules, like when to get approval before making a change, available to the agent as it works through a case.
Demo
Prerequisites
- OpenAI API key. Set
OPENAI_API_KEYfor the defaultopenai/gpt-4o-minimodel.
Quickstart 🚀
- Open the project
- Run
npx create-mastra@latest knowledge-support-agent --template knowledge-support-agent, thencd knowledge-support-agent. - If you already have the template in a checkout, open its directory and run
npm install. In the monorepo the directory istemplates/template-knowledge-support-agent.
- Run
- Add your API key
- Run
cp .env.example .envand set the key from Prerequisites.
- Run
- Load the example Knowledge
- Run
npm run knowledge:seed -- --dry-runto preview the pages and their scopes. - Run
npm run knowledge:seedto load the retail support guides and policy into the local database.
- Run
- Start Studio
- Run
npm run devand copy theretailops-store-42token from the private credential file whose path the launcher prints. - Open Mastra Studio with
?auth_header=Bearer%20YOUR_TOKENappended to the URL. ReplaceYOUR_TOKENwith the copied token and keep the resulting URL private. - Select Support, open a new chat, and ask “My Square Terminal loses Wi-Fi connectivity. What should I check?” Look for a citation to the network guide and a question about which connection indicator is visible.
- Run
Try it out
- Ask “Can I factory reset while offline payments are pending?” Look for guidance based on the pinned policy to preserve the pending payments.
- Run
npm run knowledge:seed -- --dataset retail-pos-history, then ask about Store 42 connectivity in a fresh chat. Look for dated cases and which observations remain open. - Use the Studio walkthrough to record a technician's observation, approve it, and find the shared guidance in another technician's chat.
- Reopen a saved chat using the token from your latest Studio launch.
Customization
- Ask your coding agent to explore the project and suggest a plan before editing. For example, “Adapt this template for a field service team with shared equipment guides and a separate case history for each site.”
- Add cases or replace the standing policy with Datasets and examples. You can also try the software integration and IT helpdesk examples.
Deploy to Mastra Platform
Deploy to Mastra Platform to create a project from this template. Attach a managed Turso, Neon, or PostgreSQL database to your environment. Mastra sets the database connection variables automatically. Managed databases
Set these environment variables in the platform dashboard.
OPENAI_API_KEYwith your OpenAI API key.DATABASE_PROVIDERwithturso,neon, orpostgresto match the attached database.MASTRA_ORGANIZATION_IDwith the ID of the organization that owns the project.MASTRA_PLATFORM_STUDIO_AUTH=disabledso Studio uses the template's Mastra sign-in and access rules.
The database needs the example Knowledge before Support can answer questions. For a fresh database, SUPPORT_SEED_ON_STARTUP=true loads the example on first start when the deployment includes the dataset packaged by npm run build.
About Mastra templates
This official template is maintained in the Mastra monorepo and synchronized to a standalone repository.
