Docs Call centers

Masky API keys are generated at https://masky.ai/docs — creating or changing a call center needs one. Agents with no key can get one without that page: see "No key?" in https://masky.ai/skill.md.

Masky call centers#

A Masky call center is a scripted conversation with an avatar. You write the lines and the branches once. Masky renders each line once as the avatar speaking: lip-synced video, or the avatar's voice over a still image. A visitor then walks the script. The avatar plays a line, the visitor answers with a button or by typing, and the flow picks the next line. The avatar never improvises, so every visitor sees the same clips, and nothing is rendered during a call.

No phone number is needed. A call center normally runs on the web, as an iframe on your page or as your own player built on two requests. It is called a call center because it does a call center's job (greet, ask, branch, collect, hand off), and it works like one without a phone line. A real inbound number is an optional extra at $5/month, covered in the last section.

Use this guide when someone asks for a call center, a scripted avatar, an avatar that walks people through fixed steps, a guided intake or onboarding, or an avatar FAQ desk. It is complete on its own. The rest of the Masky API (images, videos, conversations, brains, email) is in https://masky.ai/masky-api.md and is not needed here, apart from picking an avatar.

What you get#

  • Fixed, pre-rendered turns. Each step is one script line (up to 500 characters) rendered once in the avatar's voice, with lip-synced video if you ask for it. Visitors replay the stored clips.
  • Predictable cost. You pay once per step when it renders, at the avatar's normal speak price. Calls cost no credits.
  • Flow logic you control. Transitions decide which step plays next. A reply that matches a button is routed with no model involved; free text is read by a small model against the conditions you wrote. Every response says which rule chose the step (routedBy).
  • Loops and end steps. A step can lead back to itself (answer, then "anything else?"). A step with no way out ends the call.
  • Gates. A step can refuse to advance until something happens on your side, such as an upload or a payment, tracked per visitor in a session.
  • Your own interface. Each step carries a ui object of your design (buttons, panels, sliders) that your player draws beside the avatar.
  • Optional extras. A step can answer from a Living Book or text a person instead of routing, and the whole flow can also answer a real phone number.

Auth#

Base URL: https://masky.ai/api. All bodies are JSON (Content-Type: application/json).

  • Building and changing a call center needs the owner's key: Authorization: Bearer mky_....
  • Visitors need no key. Once web.enabled is true, /embed, /flow, /respond and /sessions work anonymously from the sites you allow.

Each step speaks as one of your avatars. List them with curl -s https://masky.ai/api/avatars -H "Authorization: Bearer $MASKY_API_KEY" and use an avatarId from the result. Creating an avatar is in https://masky.ai/masky-api.md.

Build one: create, render, embed#

Three steps: create the flow and render its lines, wait for the clips, then put it on a page. None of them involves a phone number.

1. Create it and render every line (owner key). One call does both:

curl -s -X POST https://masky.ai/api/call-centers \
  -H "Authorization: Bearer $MASKY_API_KEY" -H "Content-Type: application/json" \
  -d '{
    "name": "Front desk",
    "defaultAvatarId": "AVATAR_ID",
    "defaultRenderMode": "video",
    "renderSteps": true,
    "web": { "enabled": true, "allowedUrls": ["example.com"] },
    "entryStepId": "welcome",
    "steps": {
      "welcome":  { "script": "Hi, thanks for calling. Are you booking a visit, or asking about a bill?", "ui": { "chips": ["Book a visit", "Ask about a bill"] } },
      "booking":  { "script": "Happy to help you book. What day works best?" },
      "billing":  { "script": "I can help with billing. What is the invoice number?" },
      "goodbye":  { "script": "Thanks for calling. Goodbye." }
    },
    "transitions": [
      { "from": "welcome", "to": "booking", "reasoning": "Book a visit" },
      { "from": "welcome", "to": "billing", "reasoning": "Ask about a bill" },
      { "from": "booking", "to": "goodbye", "reasoning": "the caller named a day" },
      { "from": "billing", "to": "goodbye", "reasoning": "the caller gave an invoice number" }
    ]
  }'
# 201 -> { "callCenterId": "...", "flowUrl", "respondUrl", "embedUrl", "renders": [ { "stepId", "generationId", "status", "output" } ] }
  • defaultRenderMode: "video" is the avatar lip-syncing each line. "audio" (the default) is the avatar's voice over a still image and costs less. A step can override with its own "renderMode", "avatarId" or "imageUrl".
  • renderSteps: true spends credits now, once per step with a script, at the normal speak price for that avatar. A renders entry with "error" instead of generationId did not start (usually 402, not enough credits).
  • web.enabled: true publishes the call center to the web: visitors use it without a key and without a phone. allowedUrls (up to 20) limits which sites may embed or call it; leave it empty to allow any site.
  • Limits: 32 steps, 500 characters per script, 128 transitions, step ids [A-Za-z0-9_-]{1,64}. A step with no outgoing transition ends the call.

2. Wait until the clips are ready. Video takes about a minute per line.

curl -s https://masky.ai/api/call-centers/CC_ID -H "Authorization: Bearer $MASKY_API_KEY"
# -> { ..., "renders": [ { "stepId": "welcome", "output": "video", "state": "ready" }, { "stepId": "booking", "output": "video", "state": "rendering" } ] }

Every step with a script is listed. Poll every 10 seconds until every state is "ready". "none" (the render never started, usually not enough credits) and "failed" mean that step has no clip: run POST /call-centers/CC_ID/steps/STEP_ID/render with {"output":"video"} again. Nothing else is needed to publish a clip; a step plays as soon as its render finishes.

3. Put it on a page. Either embed the ready-made player, or drive your own.

The ready-made player is one iframe. It shows a start button, then plays each step's clip (the lip-synced video, or the voice over the step's image), shows the line as a caption, and gives the visitor a text box to answer. It is the simplest way to ship, with two limits: it does not draw ui.chips buttons, and it does not open a session, so a call center that uses requires gates needs your own player.

<iframe src="https://masky.ai/api/call-centers/CC_ID/embed" allow="autoplay" style="width:420px;height:640px;border:0"></iframe>
# Your own player: fetch the first step, play step.media, send the reply, repeat.
curl -s https://masky.ai/api/call-centers/CC_ID/flow
# -> { "entryStep": { "stepId": "welcome", "script": "...", "isEnd": false, "ui": { "chips": [...] }, "media": { "output": "video", "videoUrl": "https://...", "audioUrl": "https://..." } } }

curl -s -X POST https://masky.ai/api/call-centers/CC_ID/respond -H "Content-Type: application/json" \
  -d '{"currentStepId":"welcome","userText":"Book a visit"}'
# -> { "nextStepId": "booking", "matchedReasoning": "Book a visit", "routedBy": "exact", "isEnd": false, "step": { ..., "media": { ... } } }

Your own player is two requests in a loop, so it can look like anything: buttons from ui.chips, a microphone that you transcribe and send as userText, your own panels beside the avatar.

media URLs are minted per request and expire, so read them from each response and do not store them. media: null means that step has no finished clip; show script as text or speak it yourself. When step.isEnd is true, play it and stop.

How the next step is chosen, and how to make it exact#

When /respond or /route moves the call to a next step, routedBy says which rule chose it (it is absent on a blocked gate, at the end of the call, and on book or text steps):

routedByWhenSame answer every time?
onlyThe step has one outgoing transition.Yes. No model is involved.
exactuserText is the reasoning text of one transition (case, spacing and a final . ! ? are ignored).Yes. No model is involved.
llmAnything else. A small model reads the caller's words and each transition's reasoning and picks one.Usually, not guaranteed.
fallbackThe model could not be reached or gave no usable answer; the first transition was taken and the call has moved there.No. It is rare and logged on Masky's side; if a wrong turn here would matter, use buttons on that step.

To get a call that never surprises you:

  • Buttons: make each button's text the transition's reasoning, and send that text as userText. That is exact. Put the same strings in the step's ui.chips so your player can draw them (ui is yours: any JSON up to 4KB, returned with the step).
  • Free speech or typing: write each reasoning as a plain condition about the caller that cannot overlap its siblings, such as "the insured person is 50 or older" and "the insured person is younger than 50". Two transitions that could both be true is the usual cause of a wrong turn.
  • Order the transitions so the first one out of each step is the safest place to land. It is the one taken on fallback.
  • A step that should repeat (answering questions, then asking "anything else?") is a transition from the step to itself.
  • Test every branch before you share the call: one /respond per transition, checking nextStepId. It takes seconds and costs nothing.

Changing a call center later#

  • PUT /call-centers/CC_ID with steps replaces the whole step map, including each step's render. Read the center first and send every step back with its render object, or the clips are dropped and the steps fall back to text.
  • After changing a script, render only that step: POST /call-centers/CC_ID/steps/STEP_ID/render with {"output":"video"}. renderSteps: true on a PUT renders every step again.
  • A step that must wait for something on your side (an upload, a payment) uses requires and a session: see Sessions and gates below.

Deployment API#

Owner key (mky_… or a Firebase ID token). Masky stores the flow graph, session identity, and step state. It does not store uploaded documents, filenames, or document text. A caller passage sent as userText is routed for that turn and is not written to Firestore; logs record the step id and the character length only.

# Create a center. steps replaces the whole map. requires is only
# { "type": "upload", "key", "accept"? }. ui is a JSON object, max 4KB.
curl -s -X POST https://masky.ai/api/call-centers \
  -H "Authorization: Bearer $MASKY_API_KEY" -H "Content-Type: application/json" \
  -d '{"name":"Fraction","entryStepId":"upload","web":{"enabled":true},"steps":{"upload":{"script":"Upload your policy.","ui":{"panel":"upload"},"requires":[{"type":"upload","key":"policy"}]}},"transitions":[]}'
# 201 -> { callCenterId, flowUrl, respondUrl, embedUrl, silentTurns }

# Update the fields you send. steps or transitions replaces that whole graph.
curl -s -X PUT https://masky.ai/api/call-centers/CC_ID \
  -H "Authorization: Bearer $MASKY_API_KEY" -H "Content-Type: application/json" \
  -d '{"web":{"enabled":true}}'

# GET /call-centers lists yours: { callCenters: [ { id, name, entryStepId, updatedAt } ] }.
# DELETE /call-centers/CC_ID removes one. It is 409 while a phone number is still attached.

POST /call-centers/{id}/steps/{stepId}/render with { "output": "audio" } (or "video") returns 202 { generationId, status, output } and writes step.render. renderSteps: true on create or update does that for every step that has a script, using each step's renderMode or the center's defaultRenderMode. GET /call-centers/{id} (owner) returns renders: [{ stepId, output, state }] with state none, ready, rendering or failed, read live from each render. A step's clip is served in step.media as soon as its render finishes.

POST /call-centers/{id}/silent-turns with { "prompts": ["…"], "avatarId": "…", "imageUrl": "…" } renders silent idle clips of the avatar, for your player to loop while the visitor is thinking. It starts the first prompt only (one render in flight, custom prompt, max 6 clips on that image). Call again with the rest. 409 while that image is already rendering.

Sessions and gates#

POST /call-centers/{id}/sessions with { "externalUserId": "<optional opaque id, max 128>" }. Owner key, or anonymous when web.enabled. 201 { sessionId, sessionToken, expireAt }. The token is ccst_…; only its hash is stored. Send it as Authorization: Bearer ccst_…. It is rejected in the query string and in the JSON body, because a query token lands in access logs. A token for session A receives 403 on session B, including another session of the same call center.

Anonymous creates are 20 per IP per rolling hour (429 over the cap). The address is CloudFront-Viewer-Address when the request came through CloudFront, otherwise the TCP peer. Client X-Forwarded-For is ignored. No address → 400. Owner creates are not capped.

Sessions expire 30 days after creation (expireAt). An hourly sweep deletes the session and its token whether or not anyone opens it again. A read after expireAt deletes the row and returns 404.

POST /call-centers/{id}/sessions/{sessionId}/satisfy body { "key": "policy" } is owner key only. A session token gets 403. Stores { key, satisfiedAt } and nothing else. The key must already be declared on a step. Idempotent.

On POST /respond and POST /route, an unmet requirement does not advance, and userText may be empty:

{ "blocked": true, "blockReason": "upload_required", "missing": [{ "type": "upload", "key": "policy" }], "nextStepId": "upload", "isEnd": false, "step": { "stepId": "upload", "ui": { "panel": "upload" }, "requires": [{ "type": "upload", "key": "policy" }], "satisfied": [] } }

A clear gate adds "blocked": false and still 400s on empty userText. A call center that declares requires on any step returns 401 { "error": "session required" } on every /respond and /route that has no session. Naming a later currentStepId does not walk past the gate. Centers that declare no requirements still route anonymously for the legacy embed. The phone surface is not gated. When a route reaches an end step the session stores stepId: null, and further /respond and /route calls return 409 { "error": "session ended" }. Naming a later step does not resume it.

GET /flow, POST /route, and POST /respond steps include ui and requires. satisfied is present only when a session resolves (GET /flow?sessionId= with that session's token, or the owner key). Entries are { "type": "upload", "key", "satisfiedAt" }.

GET /call-centers/{id}/sessions/{sessionId}/events?since=<unix ms> (session token or owner key, token in the header):

{ "events": [ { "type": "gate_blocked", "at": 0, "stepId": "upload", "missing": [{ "type": "upload", "key": "policy" }] }, { "type": "requirement_satisfied", "at": 0, "key": "policy" }, { "type": "step_changed", "at": 0, "fromStepId": "upload", "stepId": "estimate", "blocked": false, "ui": { "panel": "sliders" } } ], "cursor": 0 }

Steps that answer or text instead of routing#

By default a reply moves the call to a next step. A step can do something else with the reply instead. This is the step's "When the caller responds" mode, set in the designer or sent as step.userLine ({ "mode": "route" | "book" | "text", "bookSlug", "textTo", "ack", "smsTemplate", "waitForReply" }):

  • Route to a next step (route, the default) — the routing rules above pick an outgoing transition.
  • Answer from a Living Book (book) — the caller's words are sent to https://livingbook.masky.ai/api/books/{slug}/ask; if the book covers the question, the verbatim passage is spoken back. If not, the question is texted to the author (the number configured on the step, or the author's LivingBook incoming number) from the call center's own phone number. The step loops so the caller can keep asking.
  • Text it to a phone number (text) — the caller's spoken line is sent as an SMS to the number you configure, from the call center's provisioned number, then a confirmation line is spoken. The step loops.

Sending a text is the one web feature that needs the call center to own a phone number (see the last section), because the text is sent from it. Without one, the step says so instead of texting. Answering from a Living Book needs no number.

For texting modes on a phone call, "Hold the call for the SMS reply" keeps the caller on the line for up to ~3 minutes; when the texted person replies by SMS, the reply is read aloud on the call.

POST /call-centers/{id}/respond handles every mode (/route is the older, routing-only endpoint, kept for old embeds): body {"currentStepId","userText"} → for routing steps it behaves exactly like /route, returning {"nextStepId","matchedReasoning","routedBy","isEnd","step"} (see How the next step is chosen above); for book/text steps it returns {"action","say","found","smsSent","nextStepId"} where say is the line to show or speak and nextStepId stays on the same step (the step loops). Texts are rate-limited per call center (30/hour).

Web sessions can link a Masky conversation: pass "conversationId" in the /respond body and, when the texted person replies by SMS, their reply is injected into that conversation as a rendered turn — it plays in the open /live view with no client work. Only the most recent open thread per sender receives the reply, and only conversations belonging to the call center's owner qualify. Poll GET /call-centers/{id}/sms-status?conversationId=… → {sent, sentAt, replied, reply, repliedAt} to show a "replied" indicator.

Q&A memory#

Every reply the texted author sends back is saved on the call center as a question → answer pair. After a Living Book miss (any surface), the saved pairs are checked first — a question the author already answered gets the saved answer instantly, with no new text sent. Combined with the render cache, a repeat question plays its answer immediately and costs nothing.

Optional: a phone number ($5/month)#

Everything above runs on the web with no phone number. If you also want people to dial in, a call center can own a real inbound phone number. It is a $5/month Stripe subscription; the number is purchased for you (Twilio, US local) the moment checkout completes. Incoming calls walk the same flow: each step's pre-rendered voice line plays, the caller's speech is transcribed, and the same routing as the web picks the next step. Phone calls are voice only, so the avatar's video is a web feature.

# Start a $5/month number checkout (owner only). areaCode optional.
curl -X POST https://masky.ai/api/call-centers/CC_ID/phone/checkout \
  -H "Authorization: Bearer $MASKY_API_KEY" -H "Content-Type: application/json" \
  -d '{"areaCode":"805","successUrl":"https://masky.ai/you/call-centers","cancelUrl":"https://masky.ai/you/call-centers"}'
# -> { "url": "https://checkout.stripe.com/…" }  — complete payment there;
#    the number lands on the call center a few seconds later.

# Release the number + cancel the subscription (also happens automatically
# when the subscription ends in Stripe). Do this before deleting the call center.
curl -X DELETE https://masky.ai/api/call-centers/CC_ID/phone \
  -H "Authorization: Bearer $MASKY_API_KEY"
# -> { "ok": true, "released": "+18055551234" }

Steps without a rendered voice line fall back to plain text-to-speech on the call. Render the steps (see Build one above) for your avatar's real voice. requires gates are not enforced on the phone.

Incoming SMS#

Texts to the call center's number are told apart automatically: a reply the center is waiting on is delivered to the session that asked (call, web, or SMS); anything else is a new texter, handled by the Incoming SMS tab of the Agent Flow in the designer (stored as center.sms). This surface is text-only — no renders:

  • Do nothing (default) — the text is stored, nothing is sent.
  • Answer from a Living Book — saved Q&A pairs and the book are checked first and the answer is texted back; unanswered questions are forwarded to the author, the sender gets a configurable acknowledgement, and the author's reply is texted straight back to the sender.
  • Forward it to a phone number — the text is forwarded verbatim (or via the wording template), and the reply relays back to the sender.

All outbound messages draw from the same 30/hour SMS budget.

Generate or manage your Masky API key any time at https://masky.ai/docs

Reading this as an AI assistant, or want to hand it to one? The same guide is plain markdown at masky.ai/masky-call-center.md.