Xuda logo Xuda Docs User Guides
/
xuda.io
← All guides Other Guides

Xuda Auto Answer API Reference

Source file: xuda-auto-answer-api-reference.md

Xuda Auto Answer API Reference

This reference documents the complete method surface of Xuda Auto Answer, the module that decides who answers on your behalf in Xuda chat, on your website chat widget, by email, on your contact form and on inbound phone calls. It is written for developers and integrators who need to know exactly what each method does, what it takes, what it returns and what it refuses. In the dashboard the product is labeled Auto Response, and every method key below uses that spelling.

What The Availability Labels Mean

Every method in this document carries an explicit Availability line. Read it first, because it tells you whether you can call the method from your own code today. The labels are:

  • Availability: API key. Reachable by an external developer API key or through the MCP layer. You can call it from your own server or agent.
  • Availability: Dashboard session. Reachable only over the authenticated dashboard endpoint by the signed-in account owner. It is not exposed to developer API keys, not offered by the MCP layer at call time, and not available in the Studio workflow picker. You can drive it from the dashboard UI, but not from an API key today.
  • Availability: Public endpoint. Unauthenticated, called from a browser or a server integration.
  • Availability: Operator only. Xuda staff or internal platform use, listed here for completeness rather than as something you can call.

Be aware of the honest headline before you read further: Auto Answer exposes no API key method today. All seven of its registered methods are flagged private in the platform method catalog, which in this codebase means dashboard session only. The eighth function, the resolver, is not registered at all and has no HTTP surface of any kind. Every method is documented in full below anyway, because that is the entire surface of the feature and there is no second, public one.

How To Call These Methods

Every method here is a Xuda CPI method. Methods labeled API key are called over the Xuda API and MCP layer with your account API key as the credential; see /api-mcp-integration for the transport-level detail, including the request shape and how MCP surfaces a method as a tool.

The methods in this document are not in that group. All seven registered Auto Answer methods are reachable only over the authenticated dashboard /cpi/ endpoint, as the signed-in account owner. They are withheld from the developer-keys API picker, from the MCP layer at call time, and from the Studio workflow picker.

Every method declares clearance: user, job: false, cache: false and private: true, and none carries a min_plan or min_support_plan. The account is always taken from the authenticated session, so no method takes an account id as a parameter.

Response Envelope

Every method returns the standard Xuda envelope:

Field Meaning
code 1 on success. A negative number on failure.
data The result payload on success. On failure it carries the message.

Plan refusals are returned as a plain sentence a customer can read, not as a raw code alone, so a client can surface data directly.

Channels

Five channel keys are recognized. They are a fixed set and no other value is accepted.

Key Meaning
chat Contact conversations inside Xuda.
chat_widget Strangers arriving through the chat widget on the customer's own website.
email Mail threads with contacts.
contact_form Profile or static-site contact form submissions.
phone Inbound calls.

Method Index

Method What It Does
get_auto_response_plans Returns the plan ladder, which tier the account is on, and what it is using.
set_auto_response_plan Activates, upgrades, downgrades or deactivates the account's auto response plan.
get_auto_response_scenarios Lists every scenario on the account in priority order, with the profiles using each one.
save_auto_response_scenario Creates or updates one scenario.
delete_auto_response_scenario Soft-deletes a scenario and unbinds it from every profile.
attach_profile_auto_response Gives a profile a scenario to answer with.
detach_profile_auto_response Removes one scenario, or every scenario, from a profile.
resolve_auto_response Internal seam that answers "does the AI answer here, right now, and with what".

Availability at a glance: 0 API key, 7 Dashboard session, 0 Public endpoint, 1 Operator only.

get_auto_response_plans

Get Auto Response Plans

Returns the account's auto response plan ladder: the tiers with their prices, features, scenario allowances and the channels each tier can answer on, which tier the account is on, whether the plan has been activated, and what it is already using. Nothing auto responds until a plan is activated.

Availability: Dashboard session

Parameters

This method takes no parameters. The account is taken from the authenticated session.

Response

Field Meaning
plans The ordered catalog, cheapest first, with cumulative entitlement flags per tier.
current_tier The tier the account holds.
current_rank The position of that tier in the ladder.
plan_active Whether a tier has ever been deliberately picked.
activated_ts Millisecond timestamp of the last plan change.
entitlements The flags the account actually holds. Empty when the plan was never activated.
channels The five channel keys.
not_activated_reason Why nothing answers, when plan_active is false.
usage scenarios, enabled, profiles_attached, profiles_total.
billing monthly_total, plus the note "One charge for the account, however many scenarios you write."

Notes

  • clearance: user.
  • No plan gate. This is the method that tells you whether a plan exists, so it must work before one does.
  • An absent plan field on the account means "never activated", which is a distinct state from holding the free tier. An account that never activated holds no entitlements at all, not even the free tier's.

set_auto_response_plan

Set Auto Response Plan

Activates, upgrades or downgrades the account's auto response plan (auto_response_free, auto_response_starter, auto_response_growth, auto_response_scale) and adds it to the consolidated subscription. A downgrade that would strand more scenarios than the new plan allows, or leave a scenario answering on a channel the new plan does not cover, is refused by name rather than silently leaving the account over its limit.

Availability: Dashboard session

Parameters

Name Type Required Description
plan_id string Yes The plan id (auto_response_free, auto_response_starter, auto_response_growth, auto_response_scale) or the bare tier (free, starter, growth, scale).
deactivate boolean No Undeclared in the method's field list but read by the implementation. true (or an empty-string plan_id or tier) reprices the paid line to free and then unsets the plan field, which is what every surface reads as switched off.
tier string No Undeclared in the method's field list but accepted as an alias for plan_id.

Response

Case Returns
Upgrade { plan_id, tier, name, flags }
Scheduled downgrade { plan_id, tier, name, scheduled: true, effective }
No change { plan_id, tier, unchanged: true }
Deactivation { plan_id: '', tier: '', deactivated: true }

Notes

  • clearance: user.
  • Error codes: -61 unknown plan; -62 downgrade would strand scenarios or channels; -402 the tier has no real Stripe price yet; -400 save failed.
  • This is the only billing path for the module. The paid tiers ride the consolidated Stripe subscription as a single line item under the category auto_response, added through stripe_module.add_subscription_item({ uid, plan_id }). The generic stripe_change_plan path is deliberately not used.
  • A move back to Free still calls Stripe, because the same call reprices the existing item to the free price. Skipping it would leave the customer billed for a plan they no longer hold.
  • Upgrades are immediate and prorated. Downgrades are scheduled to the end of the paid period, and the plan field is only moved when the Stripe subscription webhook transitions the schedule.
  • In production none of the four auto_response_* plans carries a price_id, and add_subscription_item hard-refuses a plan with no real price id with code -402, surfaced as "The plan is not billable yet". The three paid tiers cannot be bought in production today. Free is activatable in production, because Stripe is skipped entirely when the price is 0 and no auto_response subscription item exists yet. Only the dev configuration carries Stripe TEST price ids.
  • Deactivation deletes the plan field rather than blanking it. Billing is stopped first, and only then is the field unset.

get_auto_response_scenarios

Get Auto Response Scenarios

Lists every auto response scenario on the account, in priority order, with the profiles each one is attached to, the plan entitlements that gate the editor and the default shape for a new scenario.

Availability: Dashboard session

Parameters

This method takes no parameters. The account is taken from the authenticated session.

Response

Each scenario is returned with _id, name, enabled, priority, channels, when, answer, otherwise, ts and attached_profiles, where attached_profiles is an array of { profile_id, name, main }.

Notes

  • clearance: user. No plan gate on read.
  • Sorted by ascending priority, then most recently edited first.
  • attached_profiles is derived live from the profile documents rather than stored on the scenario, so a detach can never leave a stale profile name on a card.
  • When no plan has been activated the method still succeeds. It returns an empty list plus plan_active: false and not_activated_reason.
  • Reads are capped at 200 scenarios and 200 profiles per account.

save_auto_response_scenario

Save Auto Response Scenario

Creates or updates one scenario: which channels it answers on (chat, chat widget, email, contact form, phone), when it applies (always, only while you are away, or inside or outside a set of business hours), who answers and in what voice, and what happens when it does not apply. A setting the plan does not include is refused by name so the customer is told what to upgrade for. Saving is strict: an unnamed scenario, a scenario covering no channel, an unrecognized timezone, an unknown mode or an entitlement the tier lacks each return a plain-English sentence rather than a code. Returns the saved scenario.

Availability: Dashboard session

Parameters

Name Type Required Description
scenario_id string No Omit to create a new scenario, pass it to update an existing one.
scenario object Yes The scenario body: name, enabled, priority, channels, when, answer, otherwise.

The scenario object

Name Type Required Description
name string Yes Up to 80 characters. Internal label only; the customer never shows it to anyone.
enabled boolean No Defaults to true. A disabled scenario is stored but never applies.
priority number No 0 to 999, default 100. Lower wins when more than one scenario fits. Shown in the dashboard as "Order".
channels array of string Yes One or more of chat, chat_widget, email, contact_form, phone. Every entry must be covered by the plan.
when.mode string No always, when_offline or hours. Defaults to always. hours requires the business_hours entitlement.
when.applies string No inside or outside, default inside. Says whether the configured hours are when the scenario runs or when it does not.
when.business_hours.enabled boolean No Turns the hours grid on. Requires the business_hours entitlement.
when.business_hours.timezone string No An IANA timezone name, default UTC. Validated with Intl.DateTimeFormat; an unrecognized zone is refused.
when.business_hours.week array of 7 arrays No Index 0 is Sunday. Each day holds up to 4 { start, end } windows in HH:MM (an end of 24:00 is allowed). An end at or before the start means the window wraps past midnight.
answer.ai_agents array of string No Up to 20 AI agent ids. Empty means the account's own agents answer. Requires the ai_agents entitlement to be non-empty.
answer.voice_agent.voice string No Up to 40 characters. The voice used when the scenario answers a call. Requires the voice_agent entitlement.
answer.voice_agent.tone string No Up to 40 characters. The personality preset used on a call. Requires the voice_agent entitlement.
answer.greeting string No Up to 500 characters. The opening line, delivered in the other person's language.
answer.tips string No Up to 4000 characters. Instructions and prohibitions for this situation, passed to the model as delimited business-supplied reference material.
answer.signature string No Up to 1000 characters. Falls back to the profile's own signature when blank.
otherwise.action string No none, voicemail, forward or message. Anything other than none requires the fallback_actions entitlement. This value is stored and validated but no caller acts on it yet.
otherwise.number string No Up to 32 characters. The number to forward to.
otherwise.message string No Up to 1000 characters. The message to reply with.

Notes

  • clearance: user. Requires an activated plan; otherwise returns code -63.
  • Error codes: -61 validation or entitlement refusal, where the message is a customer-ready sentence; -62 over the scenario allowance, or the scenario has been deleted; -404 scenario not found or not owned by this account.
  • Validation on save is strict: a setting the plan does not include is refused by name. Validation at answer time is lenient: the same normalization runs non-strictly, so a setting the tier no longer covers is silently coerced away and a downgrade takes effect on the very next message rather than at the next save.
  • name has its whitespace collapsed. greeting, tips and signature keep their newlines.
  • priority is clamped to 0 to 999 rather than rejected out of range.
  • The dashboard editor exposes no control for priority or for the otherwise object. Both are round-tripped on save, so an API caller can set them even though the UI cannot.
  • Content written into answer.tips is passed to the model wrapped in explicit begin and end delimiters and labeled as business-supplied reference material that must not override platform rules. Treat it as content, not as a place to inject instructions.

delete_auto_response_scenario

Delete Auto Response Scenario

Deletes a scenario and unbinds it from every profile that pointed at it, so no profile is left falling through to a scenario the customer can no longer see. The delete is soft: the document is moved to a deleted status rather than destroyed.

Availability: Dashboard session

Parameters

Name Type Required Description
scenario_id string Yes The scenario to delete.

Response

{ scenario_id, detached }, where detached lists the profile ids that were unbound.

Notes

  • clearance: user.
  • Error codes: -61 missing scenario_id; -404 scenario not found or not owned by this account.
  • Deleting an already-deleted scenario succeeds with unchanged: true.

attach_profile_auto_response

Attach Auto Response Scenario To Profile

Gives a profile a scenario to answer with. A profile holds a list, so it can answer differently on different channels or at different hours, and one scenario can serve several profiles. A profile does not need a phone number to answer.

Availability: Dashboard session

Parameters

Name Type Required Description
profile_id string Yes The account profile that should answer with this scenario.
scenario_id string Yes The scenario to give it.

Response

{ profile_id, scenario_id, scenarios }, with the profile's full scenario list after the change.

Notes

  • clearance: user. Requires an activated plan; otherwise returns code -63.
  • Error codes: -61 missing ids; -62 the scenario has been deleted; -404 scenario or profile not found.
  • Attaching an already-attached scenario succeeds with unchanged: true.
  • Answering is a property of the profile, never of a phone number. There is deliberately no "this profile holds a number" check, because the main profile is forbidden from holding one and still answers chat, mail and transferred calls.
  • auto_response_scenarios on the profile document is the only field this module ever writes on a profile.

detach_profile_auto_response

Detach Auto Response Scenario From Profile

Unbinds a scenario from a profile. The scenario itself stays, so the other profiles using it are untouched. Omitting the scenario id detaches every scenario from that profile, which is what switching auto response off for the profile means.

Availability: Dashboard session

Parameters

Name Type Required Description
profile_id string Yes The account profile to unbind from.
scenario_id string No Omit to detach every scenario from this profile.

Response

{ profile_id, scenarios, detached }.

Notes

  • clearance: user.
  • There is no activation gate on detach, so an account whose plan lapsed can still clean up.
  • Error codes: -61 missing profile_id; -404 profile not found.

resolve_auto_response

Resolve Auto Response

The internal seam that answers "does the AI answer on this profile, on this channel, right now, and with what". It is called module to module through the message broker by the AI module (contact chat, email and the contact form), the router module (the embeddable chat widget's own look, on the chat_widget channel) and the voice module (inbound calls, on the phone channel).

Availability: Operator only

This method is not registered in the platform method catalog at all, so it has no HTTP surface whatsoever. It is listed here for completeness so that integrators understand where the answering decision is made. It cannot be called with an API key, from a dashboard session, or from a browser.

Parameters

Name Type Required Description
uid string Yes The owning account.
profile_id string Yes The profile the message or call arrived on.
app_id string No The app whose database holds the scenarios, when it is not the account default.
channel string No An explicit channel key. Supply this, or conversation_type plus contact_source.
conversation_type string No A coarse type (chat, email, ticket) from which the channel is derived.
contact_source string No Where the contact came from. Combined with conversation_type it splits a coarse chat into chat_widget or chat.
now_ts number No An injectable current time, used for evaluating open hours.

Because this method is not registered, it carries no declared field list. The parameters above are the ones the resolver reads.

Response

The winning scenario's scenario_id, source (scenario or legacy), name, channel, answer, otherwise, when, plan_tier and plan_active, or null when nothing applies.

Notes

  • Selection order when more than one scenario fits: lowest priority wins, a tie goes to the scenario covering fewer channels (the more specific one), and a final tie goes to the most recently edited.
  • when_offline is decided from the account's live dashboard socket. A live value means the owner is at their desk.
  • Open hours are evaluated in the business's own IANA timezone with Intl.DateTimeFormat, so daylight saving is correct without storing an offset. A window whose end is at or before its start is carried through as a wrap past midnight.
  • When an account has no plan or no scenario for that channel, the resolver falls back to the legacy flat profile fields (auto_respond, auto_respond_mode, auto_respond_agents) and returns a synthetic scenario named "Default" at priority 500 covering chat, chat_widget, email and contact_form, but never phone.
  • The scenario is re-normalized non-strictly against the current plan on every lookup, so a downgrade takes effect on the very next message.
  • Callers degrade safely. The phone path falls back to the legacy answer on any error, and the widget path falls back to not claiming the AI answers, so a resolver outage never drops a call or takes the widget down.
  • otherwise is returned to callers, but no caller reads it today.

Plan Gates

Entitlements are cumulative: a tier holds its own flags plus every flag of the tiers below it, and the channels flag merges rather than overwrites.

Tier Plan id Scenarios Channels added at this tier Other entitlement flags
Free auto_response_free 1 chat none
Starter auto_response_starter 3 chat_widget, email, contact_form ai_agents: true, business_hours: true
Growth auto_response_growth 10 phone voice_agent: true, transcript: true, ai_minutes: 100
Scale auto_response_scale unlimited (-1) none added (all five already covered) fallback_actions: true, ai_minutes: 400

Which gates are actually enforced in code:

Gate Enforced On Behavior
Scenario count save_auto_response_scenario Refused with "Your plan covers N scenarios. Delete one first, or move up a plan." -1 means unlimited, and a missing flag is treated as unlimited rather than zero.
Channels save_auto_response_scenario Refused with the covered list named, for example "Your plan answers on chat, email. Move up a plan to cover the rest of what this scenario asks for."
business_hours when.mode: hours and when.business_hours.enabled Starter and up.
ai_agents a non-empty answer.ai_agents Starter and up.
voice_agent answer.voice_agent.voice and .tone Growth and up.
fallback_actions otherwise.action other than none Scale only.
Downgrade guard set_auto_response_plan Refused if it would strand scenarios over the new count, or leave a scenario answering on a channel the new tier does not cover.
Activation save_auto_response_scenario, attach_profile_auto_response Throws auto_response_not_activated and returns code -63 if no tier has been picked.
Superuser override account level Accounts listed in the platform superuser list hold the top tier without buying it. This is a platform testing posture, not a customer feature.

Two flags on the tier cards are not read by any code in this module: transcript on Growth, and ai_minutes on Growth and Scale. The only transcript entitlement actually enforced anywhere is the phone plan's, in the voice module, and nothing meters or caps AI minutes against an auto response tier. Do not build against either flag.

Nothing on the auto response path deducts credits or charges per message, per answer or per minute. Answers are produced through the existing AI and voice paths.

Limits And Quotas

Enforced on save:

Field Limit
name 80 characters, whitespace collapsed, required
priority integer clamped to 0 to 999, default 100
answer.greeting 500 characters, newlines preserved
answer.tips 4000 characters, newlines preserved
answer.signature 1000 characters, newlines preserved
answer.ai_agents maximum 20 agent ids
answer.voice_agent.voice 40 characters
answer.voice_agent.tone 40 characters
otherwise.number 32 characters
otherwise.message 1000 characters
open-hours windows maximum 4 windows per weekday, HH:MM, where an end of 24:00 is also allowed

Enforced on read:

Read Limit
Scenarios per account 200
Profiles per account 200

Idempotency And Repeat Calls

Call Repeat behavior
set_auto_response_plan with the tier already held Succeeds and returns { plan_id, tier, unchanged: true }. No Stripe change is made.
save_auto_response_scenario with a scenario_id Updates in place. Omitting scenario_id always creates a new scenario, so retrying a create without an id produces a second scenario.
delete_auto_response_scenario on an already-deleted scenario Succeeds with unchanged: true. Deletes are soft, so the document is moved to a deleted status rather than destroyed.
attach_profile_auto_response with a scenario already attached Succeeds with unchanged: true.
detach_profile_auto_response with no scenario_id Detaches every scenario from that profile. Safe to repeat.

Errors

Code Meaning Returned by
-61 Unknown plan. set_auto_response_plan
-61 Validation or entitlement refusal. The message is a customer-ready sentence. save_auto_response_scenario
-61 Missing scenario_id. delete_auto_response_scenario
-61 Missing ids. attach_profile_auto_response
-61 Missing profile_id. detach_profile_auto_response
-62 The downgrade would strand scenarios or channels. set_auto_response_plan
-62 Over the scenario allowance, or the scenario has been deleted. save_auto_response_scenario
-62 The scenario has been deleted. attach_profile_auto_response
-63 auto_response_not_activated. No tier has ever been picked. save_auto_response_scenario, attach_profile_auto_response
-400 Save failed. set_auto_response_plan
-402 The tier has no real Stripe price yet. Surfaced as "The plan is not billable yet". set_auto_response_plan
-404 Scenario not found, or not owned by this account. save_auto_response_scenario, delete_auto_response_scenario
-404 Scenario or profile not found. attach_profile_auto_response
-404 Profile not found. detach_profile_auto_response

Refusal messages you should expect to surface verbatim rather than rewrite:

  • "Your plan covers N scenarios. Delete one first, or move up a plan."
  • "Your plan answers on chat, email. Move up a plan to cover the rest of what this scenario asks for."
  • "You have 5 scenarios and the Starter plan includes 3. Delete 2 first."
  • "The Free plan does not answer on phone, email. Remove those channels from your scenarios first."
  • "The plan is not billable yet: ..."

Every plan refusal is turned into a plain sentence at the one boundary a person reads it, so a client should display data rather than mapping the code to its own copy.

Webhooks

Auto Answer registers no webhooks of its own and no scheduled jobs.

It does depend on one existing webhook: the Stripe subscription webhook, handled in the Stripe module. A downgrade requested through set_auto_response_plan is scheduled rather than applied, and the account's plan field is only moved when that webhook reports the Stripe schedule transitioning. Until then, get_auto_response_plans continues to report the old tier with the scheduled change alongside it.

Not Part Of The Public Surface

For completeness: resolve_auto_response is documented above but is not registered in the platform method catalog and has no HTTP surface. It is the internal seam that the AI, router and voice modules call when a message or a call arrives.

The module writes only two document types: its own scenario documents, and the single auto_response_scenarios field on an account profile. It creates no database of its own, and it calls no third-party vendor directly. Stripe is reached through the Stripe module, and the text and voice answers themselves are produced through the existing AI and voice paths.