Handling the response
The four actions Dexbi sends back, what your app should do with each, and a full example of every one.
Every successful response has these fields. action tells you what to do. Dexbi never posts, pings or closes anything itself for an API request: your app does.
| Field | Type | What it is |
|---|---|---|
action | "reply", "handover", "close" or "none" | What your app should do. |
message | string or null | The text to send the member. It can contain Markdown, like bold, lists and links, as in Discord. |
staffNote | string or null | With handover: a short brief of the issue, for your staff. |
title | string or null | A suggested thread title, only when you ask for one with suggestTitle: sent once, on the turn the issue becomes clear, in lowercase words joined by dashes. |
teamWaitSeconds | number or null | With none in a ticket with reply: "smart": your staff replied last, so Dexbi waits this many seconds for them. null with teamWaitMinutes: "never". See Waiting for your staff. |
conversation | string | The conversation you sent. |
fields | object | Only when you send fields: each one filled in, under its own name. See Custom fields. |
attribution | object | The "Powered by Dexbi" credit, and whether your plan requires it. See Show the Powered by Dexbi credit. |
Show the "Powered by Dexbi" credit
Every response has an attribution object:
"attribution": { "text": "Powered by Dexbi", "url": "https://dexbi.app", "required": true }On the Free plan, required is true. Wherever you show Dexbi's answers, on your website, in your app or in Modmail, keep "Powered by Dexbi" visible next to them, linked to https://dexbi.app. Removing, hiding or changing it breaks the Terms of Service, and we may suspend the API key or the workspace.
On a paid plan, required is false, and showing it is up to you.
The Modmail plugin handles this for you. See Keys made by Modmail.
The four actions
action | What it means | What your app should do |
|---|---|---|
reply | Dexbi has something to tell the member. | Send message to the member. |
handover | One of your escalation rules matched. | Send message to the member, and alert your staff with staffNote. |
close | The member is done, or asked to close. | Send message, then close the thread. |
none | Dexbi should stay out. | Nothing. Don't send anything. |
message can also be null with handover or close, when Dexbi has nothing to say. Only send it when it's there.
reply
{
"action": "reply",
"message": "You can ask for a refund within 14 days from your order page: **Account → Orders → Request refund**.",
"staffNote": null,
"title": "refund",
"conversation": "thread-8812"
}handover
{
"action": "handover",
"message": "I've passed this to the team. A teammate will sort out your refund here shortly.",
"staffNote": "Charged twice this month for the same order; wants one charge refunded.",
"title": null,
"conversation": "modmail-thread-8812"
}Your escalation rules live in Guidance > Escalation, the same ones Discord uses. What happens next is up to you: ping your staff, move the thread, or assign it. The On escalation actions you set in the dashboard don't run for API requests. See Escalate tickets to staff.
close
{
"action": "close",
"message": "Glad that's sorted! I'll close this ticket now.",
"staffNote": null,
"title": null,
"conversation": "modmail-thread-8812"
}Dexbi sends close when the member asks to close the conversation or confirms it's done. Close the thread in your app. The On close actions you set in the dashboard don't run for API requests.
none
{
"action": "none",
"message": null,
"staffNote": null,
"title": null,
"conversation": "website-chat-visitor-51"
}Handle it in code
const answer = await response.json();
switch (answer.action) {
case "reply":
await sendToMember(answer.message);
break;
case "handover":
if (answer.message) await sendToMember(answer.message);
await alertStaff(answer.staffNote);
break;
case "close":
if (answer.message) await sendToMember(answer.message);
await closeThread();
break;
case "none":
break; // Dexbi stays out.
}sendToMember, alertStaff and closeThread are your app's own functions.
Why Dexbi sends none
none means Dexbi should not speak. It's not an error, and it doesn't use an AI reply. Some reasons:
- With
reply: "smart", the message is chatter, not a question for Dexbi. In aticket, your staff replied last and Dexbi is waiting for them: the response hasteamWaitSeconds. - The message is from your staff (
author: "staff"). - Dexbi has no answer and
whenUnsureis"quiet". - With
reply: "pings", the message isn'tdirected. - The conversation was escalated and Dexbi is staying quiet. See After an escalation.
- It's a ticket Dexbi couldn't answer while your workspace was out of monthly AI replies. Your staff looked after it, so it stays theirs after the replies come back: Dexbi answers only
directedmessages there, until you resume it. - The conversation was closed and
afterCloseis"quiet". - The member is ignored for trolling, blocked, or reached the daily reply limit.
- Your workspace used its monthly AI replies, or replies are paused.
After an escalation
After a handover, afterEscalation decides what Dexbi does for the rest of the conversation. Leave it out and your workspace's After escalation setting in Guidance applies.
"quiet"(Only reply when pinged): Dexbi sendsnoneso your team can take over, unless the message hasdirected: true."open"(Keep replying normally): Dexbi keeps answering.
Keep using the same conversation, so Dexbi knows it was escalated. Set directed: true when the member pings Dexbi or replies to it. A directed message is answered, and the conversation stays with your team.
When your team is done, resume the conversation and Dexbi answers every message again.
After a close
If the member writes again in a closed conversation, afterClose decides:
"quiet": Dexbi sendsnonefor every later message, like Go silent. To start over, use a newconversation."open": Dexbi keeps answering.
Leave it out and Dexbi keeps answering, the same as "open".
Dexbi doesn't close a conversation that went quiet. Close idle threads in your app.
