SurveyAgent
Conducts surveys with support for multiple question types, conditional branching based on answers, per-answer scoring, and a completion callback. The agent guides the caller through each question, validates answers, and tracks progress per call.
SurveyConfig
surveyName
Human-readable survey name used in prompts and global data.
questions
Ordered list of survey questions. Each SurveyQuestion object has:
id(string, required) — Unique question identifier.text(string, required) — The question text to ask the caller.type(string, required) — One of"multiple_choice","open_ended","rating", or"yes_no".options(string[]) — Required formultiple_choicequestions.scale(number, default5) — Forratingquestions, the upper bound of the scale (1..scale).required(boolean, defaulttrue) — Whether the question must be answered.nextQuestion(string | Record<string, string>) — Next question ID, or a map from answer value to next question ID for branching. If omitted, proceeds in array order.points(number | Record<string, number>) — Fixed points for any answer, or per-answer scoring map.
introduction
Opening message before the first question. Defaults to a generic intro.
conclusion
Closing message spoken after the survey completes.
brandName
Brand or company name the agent represents. Used in prompt sections.
maxRetries
Maximum number of times to retry invalid answers before moving on.
onComplete
Callback fired when the survey is finished. Receives all responses and the total score.
name
Agent display name.
route
HTTP route for the agent.
agentOptions
Additional AgentBase options forwarded to the constructor.
Built-in Tools
Branching and Scoring
Questions support conditional branching via the nextQuestion property. When set to a
Record<string, string>, the agent routes to different follow-up questions based on the
caller’s answer. Use the key "_default" as a fallback branch.
Scoring is configured via the points property. A fixed number awards the same points
for any answer. A Record<string, number> awards different points per answer value.