/** * FAQBotAgent - A prefab agent that answers frequently asked questions using * keyword/word-overlap matching with configurable similarity thresholds * and optional escalation to a live agent. * * Ported from the Python SDK `signalwire.prefabs.faq_bot.FAQBotAgent`. Keeps * TS-specific enhancements (configurable similarity threshold, word-overlap * matcher, escalation tool) alongside the Python prefab's public surface. */ import { AgentBase } from '../AgentBase.js'; import type { AgentOptions } from '../types.js'; /** A single frequently-asked-question entry consumed by {@link FAQBotAgent}. */ export interface FAQEntry { /** The representative question text. */ question: string; /** The answer to provide when this FAQ matches. */ answer: string; /** Additional keywords to boost matching accuracy. */ keywords?: string[]; /** Taxonomy categories this FAQ belongs to (used for filtering and hints). */ categories?: string[]; } /** Configuration for the {@link FAQBotAgent}. */ export interface FAQBotConfig { /** Agent display name (defaults to `"faq_bot"`). */ name?: string; /** HTTP route for this agent (defaults to `"/faq"`). */ route?: string; /** List of FAQ entries for the knowledge base. */ faqs: FAQEntry[]; /** Whether to suggest related questions alongside a match. Default `true`. */ suggestRelated?: boolean; /** Custom personality description for the agent's "Personality" prompt section. */ persona?: string; /** Minimum match score (0-1) for an FAQ to be considered a match. Default 0.5. */ threshold?: number; /** Message spoken when no FAQ matches the query. */ escalationMessage?: string; /** Phone number to transfer to on escalation. If not set, escalate tool is not registered. */ escalationNumber?: string; /** Additional AgentBase options forwarded to super(). */ agentOptions?: Partial; } /** * Prefab agent that answers frequently asked questions using keyword matching with optional escalation to a live agent. * * Pass an array of `{ question, answer, keywords }` entries and the agent will * fuzzy-match inbound utterances against them. If no match crosses the confidence * threshold, the call can optionally escalate to a configured phone number. * * @example * ```ts * import { FAQBotAgent } from '@signalwire/sdk'; * * const agent = new FAQBotAgent({ * faqs: [ * { * question: 'What are your business hours?', * answer: "We're open 9 AM to 5 PM Pacific, Monday through Friday.", * keywords: ['hours', 'open', 'closed', 'time'], * }, * { * question: 'Where are you located?', * answer: 'Our headquarters are in San Francisco, California.', * keywords: ['location', 'address', 'office'], * }, * ], * escalationNumber: '+15551234567', * }); * * await agent.serve({ port: 3000 }); * ``` */ export declare class FAQBotAgent extends AgentBase { /** The configured FAQ entries. */ faqs: FAQEntry[]; /** Whether runner-up FAQ suggestions are appended to matches. */ suggestRelated: boolean; /** The personality description used in the prompt. */ persona: string; private threshold; private escalationMessage; private escalationNumber; /** * Create a FAQBotAgent with the specified FAQ entries and matching threshold. * @param config - Configuration including FAQ entries, threshold, and escalation settings. */ constructor(config: FAQBotConfig); private buildPrompt; private configureAgentSettings; /** * Compute a word-overlap similarity score between a query and an FAQ entry. * Combines question text similarity and keyword overlap. * Returns a value between 0 and 1. */ private computeMatchScore; private tokenize; private wordOverlap; /** Register the search_faqs and optional escalate SWAIG tools. */ protected defineTools(): void; /** * Process the interaction summary returned at the end of a call. * Logs structured summaries as JSON. Subclasses may override to persist or process. */ onSummary(summary: Record | null, _rawData: Record): void | Promise; } /** * Factory function that creates and returns a new FAQBotAgent. * @param config - Configuration for the FAQ bot agent. * @returns A configured FAQBotAgent instance. */ export declare function createFAQBotAgent(config: FAQBotConfig): FAQBotAgent; export default FAQBotAgent;