get_faqs_by_category
Retrieve frequently asked questions for a specific support category to quickly find relevant answers and solutions for user inquiries.
Instructions
Get all FAQs for a specific category
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| category | Yes |
Implementation Reference
- src/tools/chatbot.tools.ts:177-225 (handler)The execute handler function for the 'get_faqs_by_category' tool. It validates the category input, fetches FAQs using the chatbot service, formats the response as JSON, and handles errors.execute: async (args: { category: string }) => { try { logger.info('Getting FAQs by category', args); validateNotEmpty(args.category, 'Category'); const faqs = chatbotService.getFAQsByCategory(args.category); return { content: [ { type: 'text', text: JSON.stringify( { success: true, category: args.category, count: faqs.length, faqs: faqs.map(faq => ({ question: faq.question, answer: faq.answer })) }, null, 2 ) } ] }; } catch (error) { logger.error('Failed to get FAQs by category', error); return { content: [ { type: 'text', text: JSON.stringify( { success: false, error: error instanceof Error ? error.message : 'Unknown error' }, null, 2 ) } ], isError: true }; } } },
- src/tools/chatbot.tools.ts:174-176 (schema)Zod input schema defining the required 'category' parameter as a string.parameters: z.object({ category: z.string().describe('Category name to filter FAQs') }),
- src/index.ts:60-68 (registration)Registration of the chatbot tools (including get_faqs_by_category) by creating the tools object via createChatbotTools and merging it into the allTools object used by MCP request handlers.const ticketTools = createTicketTools(apiService); const chatbotTools = createChatbotTools(chatbotService); const pdfTools = createPDFTools(pdfService); const allTools = { ...ticketTools, ...chatbotTools, ...pdfTools };
- Helper method in ChatbotService that filters the hardcoded list of SupportFAQs by the given category (case-insensitive). Called by the tool handler.getFAQsByCategory(category: string): SupportFAQ[] { return this.faqs.filter(faq => faq.category.toLowerCase() === category.toLowerCase() ); }