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
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.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.
introMessage
Opening message before the first question.
completionMessage
Message after the survey is complete.
onComplete
Callback fired when the survey is finished. Receives all responses and the total score.
name
Agent display name.
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.