Create a Mastra Patient FAQ Agent that answers general healthcare questions from your curated medical knowledge, then connect it to CometChat.Imagine an agent that answers common patient questions with concise, cited guidance—grounded in your medical content and available right inside chat.
patient-faq).knowledge/<namespace> folder and cites sources..env as OPENAI_API_KEYnamespace using the ingestSources tool. Normalized content is stored under knowledge/<namespace>.knowledge/<namespace> content, ranks results, and returns excerpts with file names as sources.Prepare project
OPENAI_API_KEY in .env.Define the agent
Register in server
/api/tools/ingestSources and /api/tools/searchDocs. The agent chat endpoint is /api/agents/patient-faq/generate. See server entry.Ingest knowledge
namespace (default: medical) and POST sources to /api/tools/ingestSources. Use URLs, file paths, or raw text.Ask the agent
/api/agents/patient-faq/generate with a messages array. Optionally pass toolParams.namespace to scope retrieval.Connect to CometChat
patient-faq, and point Deployment URL to your public generate endpoint.Deploy & observe
src/mastra/agents/patient-faq-agent.ts
name to “patient-faq” so the API path is /api/agents/patient-faq/*.docsRetriever.src/mastra/index.ts
/api/agents/patient-faq/*.server.build.swaggerUI=true.http://localhost:4111/api
Install dependencies
npm installStart the dev server
npx mastra devIngest sources
/api/tools/ingestSources with a namespace (default: medical).Ask the agent
/api/agents/patient-faq/generate./api/tools/ingestSources — ingest URLs/files/text into knowledge/<namespace>/api/tools/searchDocs — retrieve relevant snippets from knowledge/<namespace>/api/agents/patient-faq/generate — chat with the agent/api/agents/patient-faq/generate is reachable.Open Dashboard
Navigate
Add agent
patient-faq, Deployment URL=your public generate endpoint.(Optional) Enhancements
Enable
For more on CometChat AI Agents, see the docs: Overview · Instructions · Custom agents
Open variant
Customize & Deploy
Adjust settings
Preview

Note: The Mastra Patient FAQ agent you connected earlier is already part of the exported configuration, so your end-users can chat with that agent immediately.
API generates response
/api/agents/patient-faq/generate returns a doc-grounded answer with disclaimers.Agent listed
/api/agents includes “patient-faq”.Tool action works
docsRetriever tool invocation.Full sample test (run curl)
/knowledge contains .md/.mdx/.txt files or your ingestion job populated the store.patient-faq.pdf-parse if needed; use allowInsecureTLS only in trusted environments.summarize-doc, triage-symptom, or link-to-source./swagger-ui).