FAQBotAgent

View as MarkdownOpen in Claude

Answers frequently asked questions by matching user queries against a provided knowledge base using word-overlap similarity scoring. Optionally escalates to a live agent when no match is found.

1import { FAQBotAgent } from '@signalwire/sdk';
2
3const agent = new FAQBotAgent({ /* FAQBotConfig */ });

FAQBotConfig

faqs
FAQEntry[]Required

List of FAQ entries for the knowledge base. Each FAQEntry object has:

  • question (string, required) — The representative question text.
  • answer (string, required) — The answer to provide when matched.
  • keywords (string[]) — Additional keywords to boost matching accuracy.
threshold
numberDefaults to 0.5

Minimum match score (0 to 1) for an FAQ to be considered a match.

escalationMessage
string

Message spoken when no FAQ matches. Defaults to an apology offering to transfer.

escalationNumber
string

Phone number to transfer to on escalation. If not set, the escalate tool is not registered.

name
stringDefaults to FAQBot

Agent display name.

agentOptions
Partial<AgentOptions>

Additional AgentBase options forwarded to the constructor.

Built-in Tools

ToolDescriptionParameters
search_faqSearch the FAQ knowledge base and return the best match with a confidence scorequery (string)
escalateTransfer the caller to a live agent (only registered when escalationNumber is set)reason (string, optional)

FAQBot works best with up to ~50 FAQs. For larger knowledge bases, use the native_vector_search skill instead.

Example

1import { FAQBotAgent } from '@signalwire/sdk';
2
3const agent = new FAQBotAgent({
4 faqs: [
5 {
6 question: 'What is the warranty period?',
7 answer: 'All products come with a 2-year warranty.',
8 keywords: ['warranty', 'guarantee'],
9 },
10 {
11 question: 'How do I return a product?',
12 answer: 'Start a return within 30 days at returns.example.com.',
13 keywords: ['return', 'refund'],
14 },
15 {
16 question: 'Do you ship internationally?',
17 answer: 'Yes, we ship to over 50 countries.',
18 keywords: ['shipping', 'international'],
19 },
20 ],
21 threshold: 0.4,
22 escalationNumber: '+15559999999',
23 escalationMessage: 'Let me transfer you to a specialist who can help.',
24});
25
26agent.serve();

createFAQBotAgent

1import { createFAQBotAgent } from '@signalwire/sdk';
2
3const agent = createFAQBotAgent({
4 faqs: [
5 { question: 'What are your hours?', answer: 'We are open 9 AM to 5 PM.' },
6 ],
7});