For the complete documentation index, see llms.txt. This page is also available as Markdown.

Human Handoff Webhook Events

Webhook delivery sends the human handoff lifecycle (AI requests handoff, agent assignment, return to AI, and queue timeout) to your system endpoint. This guide covers event types and formats, signatur

At each stage of the human handoff workflow—AI determines that a human is needed, assignment to a support agent, return to AI, or queue timeout—MaiAgent sends an event via HTTPS POST to your configured endpoint. This lets dispatching, alerts, CRM, or your own customer service system take over automatically, without polling. Event names describe handoff state transitions and form a fixed public contract. Each event has a corresponding event_type in the conversation event log API (GET /api/v1/conversations/{id}/events/; see the table below), which you can use for reconciliation or to retrieve the same information through polling.

How to Enable

Customer administrators or integration staff can configure this themselves in the admin console, without engineering assistance:

  1. In the admin console, go to “Customer Service Conversations” → “Conversation Platforms” → Edit the conversation platform to integrate → “Human Handoff Settings” → “Notifications” tab

  2. Enable “Webhook Notifications (System Integration)” and enter the receiver URL (only URLs starting with https:// are accepted)

  3. (Optional but recommended) Enter a signing secret to enable source verification (see “Signature Verification” below)

Webhook, Notification Center, and Email each have independent switches and do not affect one another. They are disabled by default and enabled per inbox. This channel is separate from the inbox’s existing “Message Webhook” for sending and receiving messages.

Event Types

event

Event log API event_type

When sent

Notes

handoff.requested

transfer_triggered

AI determines a human is needed: the conversation enters the queue and AI stops replying automatically

The first event of each handoff workflow; assignee is null. If human support agents use your own system, this signals them to take over

handoff.assigned

human_assigned

The conversation is assigned to a support agent in the MaiAgent admin console (including manual assignment, self-claiming, transfer, and automatic assignment)

assignee identifies the assigned agent; transferring to another agent sends another event with a different event id

handoff.returned_to_ai

returned_to_ai

A support agent clicks “Return to AI Agent” in the admin console or returns the conversation to AI using the return-to-ai API

assignee is null (the conversation no longer has an assigned agent)

handoff.queue_timeout

queue_timeout

No agent takes over before the inbox’s configured “Waiting Timeout” expires, and MaiAgent automatically returns the conversation to AI

assignee is null. If human support agents use your own system, receiving this means MaiAgent has resumed AI replies without your awareness—treat it as an exception requiring an alert. Alternatively, select “Handover” in dispatch settings and check “No Timeout” (dispatchMode: "handover" and assignmentQueueTimeout: 0 in the API; in automatic dispatch mode, a value of 0 is changed to 300 seconds)

All four event types use exactly the same payload keys, signatures, and retry behavior. The receiver should route by the event field. New event types may be added in the future; return 2xx and ignore unknown event values rather than treating them as errors.

Both handoff.returned_to_ai and handoff.queue_timeout mean that AI has resumed automatic replies. The former is initiated by a person (an agent or your system), while the latter happens automatically after a timeout. Neither means that the conversation is closed: no event is sent when an agent directly marks a conversation as “Resolved,” or when a conversation is requeued because the agent loses inbox permissions. For complete closure signals, query status through the conversation API or observe changes in conversation.progress_status in Message Webhooks.

Event Format

Field
Type
Description

event

string

Event name (see “Event Types” above)

id

string (uuid)

Event identifier, identical to the id returned by the event log API. Retry payloads are identical; use this to deduplicate

occurred_at

string (date-time)

Event occurrence time (ISO 8601). Deliveries are not guaranteed to arrive in order; use this to sort them

conversation.id

string (uuid)

Conversation identifier

conversation.url

string (uri)

Link to the conversation page in the admin console

inbox.id

string (uuid)

Inbox identifier

organization.id

string (uuid)

Organization identifier

contact

object | null

Customer (contact) { "id" }; null if the conversation has no contact

assignee

object | null

Assigned support agent { "id" } at the time of the event—a snapshot that does not change due to delivery delays or later transfers. Only handoff.assigned has a value; all other events use null

Field names and nesting match the MaiAgent standard format of the inbox’s “Message Webhook” (snake_case, with related objects nested as { "id" }), so the same receiver can handle both Webhook groups. The payload contains only identifiers, the event time, and an admin console link. It does not include conversation text or the reason for handoff. To obtain conversation content, use the identifiers to query the conversation and message APIs.

After you configure a signing secret in the admin console, every delivery includes the following header:

The value is the hexadecimal HMAC-SHA256 digest of the original request body bytes, calculated with the secret. Always verify using the original bytes received; do not parse and reserialize them first (differences in field order or whitespace produce a different digest).

The secret is write-only: it is not displayed after saving, and the admin console shows only “Configured.” Saving with the field empty keeps the existing secret. Enter a new value to replace it, or use “Clear Secret” to remove it. If no secret is configured, deliveries do not include the signature header.

Minimal Receiver Example

The following Python (Flask) receiver can be started directly. It verifies the signature using raw bytes, routes by event, and returns 2xx before performing time-consuming work. Set HANDOFF_WEBHOOK_SECRET to the signing secret configured in the admin console.

For local testing, simulate a delivery with the following commands (calculate the signature using the same secret):

Responses and Retries

  • The receiver should respond with a 2xx status code within 10 seconds. The response body can contain anything.

  • On timeout, connection failure, or a non-2xx response, the system retries automatically up to 3 times at 60-second intervals. Retry payloads are identical to the original delivery (with the same id); deduplicate using the event id. Events are sent as separate background tasks, so handoff.requested and the immediately following handoff.assigned may arrive out of order. Sort them by occurred_at.

  • Webhook delivery failures do not affect the main handoff workflow or Notification Center and Email notifications.

External System Takeover After Human Handoff

If your human support agents reply in your own customer service system rather than the MaiAgent admin console, combine the events on this page, the conversation platform’s “Message Webhook,” and the message API for two-way synchronization during handoff. Create a ticket in your system when you receive handoff.requested, receive visitor messages through Message Webhooks, send agent replies using POST /api/v1/messages/outgoing/, and call PATCH /api/v1/conversations/{id}/return-to-ai/ when handling is complete to return control to AI. See Third-Party Customer Service System Integration (Including Human Handoff) in the technical manual for the full workflow, request examples, and considerations. Use Scenario A when the visitor’s channel is connected to your system, or Scenario B when the visitor uses a MaiAgent conversation platform and only the human support agents use your system.

Integration Workflow

See Scenario B › Integration Workflow in the technical manual.

Request Examples

See Scenario B › Request Examples in the technical manual.

Considerations

See Scenario B › Considerations in the technical manual.

Last updated

Was this helpful?