Base URLhttps://ottla.ai/api/v1

Guides

Hand conversations to your team

The widget triggers this behaviour when you enable a channel; a custom chat calls the same escalation endpoints.

Updated 8 min read

On this page

Shoppers can ask for a person at any time, and the assistant offers one when it cannot answer or when a shopper seems frustrated. Handoffs go to your team in Ottla’s Support inbox with the conversation attached, and can also be forwarded to your own help desk by webhook.

Email notifications, support tickets and webhook handoff are on every plan. Live chat, where your team joins the same chat window in real time, is on Growth and above. There is no direct Zendesk, Gorgias or Freshdesk integration: forward handoffs to those by webhook.

If you use the widget, everything on this page up to the custom screen is console set-up. If you have built your own chat UI on the API, the escalation endpoints below do the same job.

Set up in the console

Everything lives in Customer chat → Support settings. Until at least one channel is switched on, the “talk to a person” option is hidden from shoppers.

Support settings
Section What you set
Channels Email notifications and the Notification email; Support tickets; Webhook handoff and its Webhook endpoint
Live chat (Growth and above) Live chat; Staffing mode (Staffed, On demand or Scheduled); Response window, how long a shopper waits; When no agent is free
Agent alerts Push, in-app and email alerts when a shopper is waiting, and how often they repeat
Hours of operation Timezone and Open hours
Offline messages What shoppers see when nobody is available
Routing and offers Default channel, and when to offer a person: Offer on explicit request, Offer on frustration, Offer when no answer
How agents appear Agent names and avatars, message timestamps and the new-message chime
Wording The handoff offer, its buttons and the messages shoppers see along the way

The three staffing modes are for different teams. Staffed has live chat only when someone has the inbox open. On demand has it whenever an agent is on duty, and pings them when a shopper asks. Scheduled does the same but only within your opening hours. If nobody can join in time, the recommended fallback lets shoppers leave their contact details and converts the chat to a ticket.

On demand is the natural place to start with a small team. Nobody needs to sit and watch the inbox, and because the console installs as an app on a phone or desktop, the alert comes to whoever is on duty wherever they are.

Support settings with email, tickets, webhook handoff and live chat options Example data

Build your own handoff screen

A custom chat UI calls six endpoints, in this order. Each uses your Storefront widget key (the escalation endpoints need feedback:write) and is checked against its allowed origins. The samples share this small helper:

Helper used below
const API = 'https://ottla.ai/api/v1/';

async function ottla(path, body) {
  const res = await fetch(API + path, {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer YOUR_BROWSER_KEY',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify(body),
  });
  return { status: res.status, body: await res.json() };
}
  1. Open a handoff

    Call POST /escalation with the shopper’s question and session_id, and their email and name if you have them. Set mode to "live" only when live chat is switched on; otherwise leave the default, "ticket". opened_reason can be shopper_request (the default), fallback or no_answer.

    JavaScript
    const { body: handoff } = await ottla('escalation', {
      question: 'Can I speak to someone about bulk orders?',
      session_id: sessionId,
      shopper_contact: '[email protected]',
      shopper_name: 'Sam',
      mode: 'live',
    });
    // 201 { status: 'received', escalation_id, channel, message, channel_secret }
  2. Keep the channel secret

    The 201 response includes a channel_secret, but only when a new thread opens. It is the shopper’s pass to this one conversation, so keep it in memory for as long as the chat lasts and do not log it or store it anywhere else.

    JavaScript
    const secret = handoff.channel_secret; // undefined if a thread was already open for this session
  3. Send the shopper’s messages

    Post each message with POST /escalation/message, up to 4,000 characters.

    JavaScript
    await ottla('escalation/message', {
      channel_secret: secret,
      body: 'We need 40 tents for a school trip in May.',
    });
    // 201 { status: 'sent', message_id }
  4. Fetch replies

    While the chat is open, call POST /escalation/messages every few seconds with the highest message id you have seen as since_id. Messages come back oldest first, each with an id, a sender, the body, the agent’s display name and a time. A system message with event_kind: "agent_joined" tells you a person has joined.

    JavaScript
    let lastId = 0;
    const poll = setInterval(async () => {
      const { status, body } = await ottla('escalation/messages', { channel_secret: secret, since_id: lastId });
      if (status !== 200) return clearInterval(poll);
      for (const message of body.messages) {
        showMessage(message); // your own function
        lastId = Math.max(lastId, message.id);
      }
    }, 5000);
  5. Offer to take contact details

    While the shopper waits, offer to take an email address (and a phone number if you want one) with POST /escalation/contact. If they leave before anyone replies, your team’s reply reaches them by email.

    JavaScript
    await ottla('escalation/contact', { channel_secret: secret, email: '[email protected]' });
    // 201 { status: 'captured' }
  6. Ask for a rating

    When the conversation is resolved, ask the shopper to rate it from 1 to 5 with POST /escalation/rate, then stop polling.

    JavaScript
    await ottla('escalation/rate', { channel_secret: secret, rating: 5 });
    clearInterval(poll);
An example chat on Kestrel & Fell’s store. The shopper asks: “Can I speak to someone about bulk orders?”. The assistant answers: “Sure, I can connect you with our team.”. A note in the chat says: “Priya has joined the chat.”. A member of the store’s team replies: “Hi, I’m Priya from the team. How many tents are you after, and when do you need them by?”.

While a person is answering

Once someone from your team has joined, the assistant steps back. A call to /ask for that session_id returns this instead of an AI answer, and uses none of your answered questions:

JSON
{
  "status": "human_active",
  "escalation_id": 381,
  "message": "A member of the team is in this chat. They will reply here."
}

Send the shopper’s text to /escalation/message instead. If your UI only knows how to call /ask, include the channel_secret in that call and the text goes into the thread for you.

Responses to handle

Escalation responses
Response Meaning What to do
403 not_authorised The channel_secret is wrong or the conversation is no longer open. On purpose, the response does not say which. Stop polling. If the shopper still needs help, open a new handoff.
422 A field is missing or too long, such as a message over 4,000 characters Fix the request
429 Too many calls: opening, contact and rating share 20 a minute for the key, and sending and fetching messages share 120 a minute for each conversation Wait retry_after seconds, and poll only while a handoff is open

See rate limits for how the limits work, and the escalations reference for every escalation field.

Forward to your help desk

To work handoffs in your own help desk, switch on Webhook handoff in Support settings and choose the endpoint. Ottla then sends escalation.opened when a shopper asks for a person (without the transcript), escalation.message for each message, escalation.resolved when it closes and escalation.rated when the shopper rates it. Only that endpoint receives them, and only the events it subscribes to. The full conversation stays in the Support inbox, with the AI chat above your team’s replies. Receive and verify webhooks shows how to check each delivery, and the events reference lists the payloads.

Support inbox with the AI conversation shown above the agent’s reply Example data

FAQ

Frequently asked questions

Which handoff channels come with each plan?

Email notifications, support tickets and webhook handoff are included in every plan. Live chat, where your team joins a shopper’s chat in real time, is on Growth and above. See pricing for full details.

Can handoffs go to Zendesk?

Not directly. Enable Webhook handoff, then forward its events to Zendesk (or any other help desk) from your own endpoint.

What if nobody is online?

Instead, shoppers leave a message, and your reply reaches them by email if they left an address. Your opening hours and offline wording are found in Support settings.

Does the webhook include the conversation?

The escalation.opened event does not include the transcript. Each escalation.message event carries one message, and the full conversation is in the Support inbox.

How does my custom UI get replies in real time?

Poll /escalation/messages every few seconds with since_id while the handoff is open, and stop when it closes.

Next

Try Ottla

Give every shopper a good answer.

Start your free trial on your own store, or book a demo and we’ll show you Ottla on a store like yours.

14 days free. No card needed.