***

title: FAQBotAgent
slug: /reference/typescript/agents/prefabs/faq-bot-agent
description: An FAQ bot agent that answers frequently asked questions by matching user queries against a provided knowledge base using word-overlap similarity scoring.
---------------------

For a complete index of all SignalWire documentation pages, fetch https://signalwire.com/docs/llms.txt

[agentbase]: /docs/server-sdks/reference/typescript/agents/agent-base

[functionresult]: /docs/server-sdks/reference/typescript/agents/function-result

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.

```typescript {3}
import { FAQBotAgent } from '@signalwire/sdk';

const agent = new FAQBotAgent({ /* FAQBotConfig */ });
```

## FAQBotConfig

<ParamField path="faqs" type="FAQEntry[]" required={true} toc={true}>
  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.
</ParamField>

<ParamField path="threshold" type="number" default="0.5" toc={true}>
  Minimum match score (0 to 1) for an FAQ to be considered a match.
</ParamField>

<ParamField path="escalationMessage" type="string" toc={true}>
  Message spoken when no FAQ matches. Defaults to an apology offering to transfer.
</ParamField>

<ParamField path="escalationNumber" type="string" toc={true}>
  Phone number to transfer to on escalation. If not set, the `escalate` tool is not registered.
</ParamField>

<ParamField path="name" type="string" default="FAQBot" toc={true}>
  Agent display name.
</ParamField>

<ParamField path="agentOptions" type="Partial<AgentOptions>" toc={true}>
  Additional [`AgentBase`][agentbase] options forwarded to the constructor.
</ParamField>

## Built-in Tools

| Tool         | Description                                                                          | Parameters                  |
| ------------ | ------------------------------------------------------------------------------------ | --------------------------- |
| `search_faq` | Search the FAQ knowledge base and return the best match with a confidence score      | `query` (string)            |
| `escalate`   | Transfer the caller to a live agent (only registered when `escalationNumber` is set) | `reason` (string, optional) |

<Tip>
  FAQBot works best with up to \~50 FAQs. For larger knowledge bases, use the
  `native_vector_search` skill instead.
</Tip>

## Example

```typescript {3}
import { FAQBotAgent } from '@signalwire/sdk';

const agent = new FAQBotAgent({
  faqs: [
    {
      question: 'What is the warranty period?',
      answer: 'All products come with a 2-year warranty.',
      keywords: ['warranty', 'guarantee'],
    },
    {
      question: 'How do I return a product?',
      answer: 'Start a return within 30 days at returns.example.com.',
      keywords: ['return', 'refund'],
    },
    {
      question: 'Do you ship internationally?',
      answer: 'Yes, we ship to over 50 countries.',
      keywords: ['shipping', 'international'],
    },
  ],
  threshold: 0.4,
  escalationNumber: '+15559999999',
  escalationMessage: 'Let me transfer you to a specialist who can help.',
});

agent.serve();
```

### createFAQBotAgent

```typescript {3}
import { createFAQBotAgent } from '@signalwire/sdk';

const agent = createFAQBotAgent({
  faqs: [
    { question: 'What are your hours?', answer: 'We are open 9 AM to 5 PM.' },
  ],
});
```