In the Freshdesk tutorial, the bridge between WhatsApp and Omilia was called by an API action and returned a piece of text. When the same agent moved to a client who works in Zendesk, the bridge stayed and the edges changed. Zendesk does not call you and wait for an answer: it sends a webhook saying a message arrived, and you reply when you are ready, through a different API.

That means more work and more control. You can show "typing", send the invoice PDF right in the conversation and hand the human agent a ticket that arrives with tags and fields already filled in. This is the walkthrough, with the code that runs and the Admin Center screens (in Portuguese, as our account is).

What you will build

ZENDESKOMILIA OCPCustomerWhatsAppWhatsApp channelMessagingSunshine ConversationsswitchboardAgent Workspacemessaging ticketYour bridgeone dialog per conversationPOST /zendesk/messagingChat API/chat/dialogsTask agentYour APIstoolswebhook v2 · X-API-Key/sc/v2/…/messagespassControl → next
Fig. 1 · The webhook only notifies; the answer goes in a separate call
  • The Zendesk WhatsApp channel, already connected. Underneath it runs Sunshine Conversations, Zendesk's messaging layer.
  • A conversations integration with a webhook, which sends every customer message to your bridge.
  • The bridge, with a POST /zendesk/messaging endpoint and the same OCP turn as in the Freshdesk tutorial.
  • The switchboard, which decides who answers the conversation right now: your bot or Agent Workspace.

Prerequisites

  • WhatsApp connected to Zendesk, listed under Admin Center › Channels › Messaging. Messaging and WhatsApp depend on a Suite plan; check yours.
  • Admin access to Admin Center.
  • An OCP app with the task agent and a Chat API key.
  • Public HTTPS for the bridge and a store that survives restarts (dialogs and seen message ids).
  • A phone with WhatsApp for testing.

Step 1: the OCP agent and the Chat API

If you did the Freshdesk tutorial, this step is done: same agent, same channel and continuity instruction, same Deploy › Deploy all after every change. The instruction is in Portuguese because the agent speaks Brazilian Portuguese:

NO WHATSAPP: quando o campo channel vale whatsapp, escreva mensagens curtas, de uma a três frases. Escreva números com algarismos (pedido 1001, R$ 1.249,90, 25/09). Não peça para o cliente falar; peça para digitar ou enviar.
CONTINUIDADE: depois de responder a qualquer assunto, termine sempre com a pergunta 'Posso ajudar em mais alguma coisa?' e aguarde a resposta do cliente. Nunca conclua a tarefa logo depois de responder ou de usar uma ferramenta: conclua somente depois que o cliente disser que não precisa de mais nada ou depois da transferência.
FALHAS: se uma ferramenta falhar, não fale em erro técnico. Tente mais uma vez; se falhar de novo, peça desculpas e ofereça um especialista.

Check the key from a terminal before touching Zendesk:

curl -s https://us1-m.ocp.ai/chat/dialogs \
  -H "Authorization: Bearer $OCP_CHAT_KEY" \
  -H "Content-Type: application/json" \
  -d '{
        "utterance": "oi",
        "input_fields": {"channel": "whatsapp", "caller_number": "+5511900000000"}
      }'

And keep the action_type contract in mind, because it decides when the handler sends text, when it nudges with "[noinput]" and when it hands the conversation on:

The bridge sends"utterance"OCP answersaction_typeASKsend the text, wait for the customerANNOUNCEMENT · BACKENDsend "[noinput]" again, up to 4 timesTRANSFERhandoff = atendente, drop the dialogEXITsend the text, drop the dialog"[noinput]", same dialog_id
Fig. 2 · Only ASK means 'wait for the customer'

Step 2: create a Conversations API key

In Admin Center › Apps and integrations › APIs › Conversations API, create a key. You get three values: the app ID, the key ID and the secret. The secret may not be shown again; put it in a vault right away.

Every outbound call uses Basic auth with the key ID and the secret:

POST https://suaempresa.zendesk.com/sc/v2/apps/{app_id}/conversations/{conversation_id}/messages
Authorization: Basic base64("{key_id}:{secret}")
Content-Type: application/json

A gotcha: this key can send messages, typing and passControl, but it gets 403 Invalid scope if you try to list or edit the switchboard through the API. That is what the screen in Step 5 is for.

Step 3: create the conversations integration with a webhook

In Admin Center › Apps and integrations › Integrations › Conversations integrations, create an integration:

  • Endpoint: https://bridge.suaempresa.com.br/zendesk/messaging.
  • Webhook version: v2.
  • Event: conversation:message. Only that one; the rest is noise.
  • Tick Include full source. Without it, the customer's number is not in the payload.
Conversations integration details in Zendesk: app ID, integration ID, webhook ID, masked shared secret, endpoint and version v2
The integration: keep the integration ID and the secret

Keep the integration ID: the handler uses it to know whether the conversation is still its own. The shared secret arrives on every webhook in the X-API-Key header, so the bridge compares it and refuses everything else.

One event, trimmed to what matters:

{
  "app": {"id": "6af2…f2ff"},
  "webhook": {"id": "6af2…b8a1", "version": "v2"},
  "events": [
    {
      "type": "conversation:message",
      "payload": {
        "conversation": {
          "id": "c91b…",
          "activeSwitchboardIntegration": {
            "name": "acme-ocp",
            "integrationId": "6af2…b8a2"
          }
        },
        "message": {
          "id": "m-41d…",
          "author": {"type": "user"},
          "content": {"type": "text", "text": "quero a segunda via da nota"},
          "source": {
            "type": "whatsapp",
            "client": {"externalId": "5511900000000"}
          }
        }
      }
    }
  ]
}

Step 4: write the handler

The handler checks the secret, walks the events and handles each message on its own, so one bad event does not take the others down. Once authenticated, it always answers 200.

import hmac
import httpx

SC = f"https://{SUBDOMAIN}.zendesk.com/sc/v2/apps/{APP_ID}"
AUTH = (KEY_ID, KEY_SECRET)                     # Basic auth, Conversations API key
NON_TEXT = {"image": "Enviei uma foto.", "file": "Enviei um arquivo.",
            "location": "Enviei minha localização."}


@app.post("/zendesk/messaging")
def zendesk_messaging(request):
    if not hmac.compare_digest(request.headers.get("x-api-key", ""), WEBHOOK_SECRET):
        return json_response(401, {"ok": False})
    for event in (request.json() or {}).get("events") or []:
        if event.get("type") != "conversation:message":
            continue
        try:
            on_message(event.get("payload") or {})
        except Exception:
            log.exception("event failed")       # one bad event must not cost the others
    return json_response(200, {"ok": True})     # any non-2xx makes Zendesk deliver again


def on_message(payload):
    conversation, message = payload.get("conversation") or {}, payload.get("message") or {}
    conversation_id, message_id = conversation.get("id"), message.get("id")
    if (message.get("author") or {}).get("type") != "user":
        return                                  # business replies come back as events too
    active = conversation.get("activeSwitchboardIntegration") or {}
    if active and active.get("integrationId") != INTEGRATION_ID:
        return                                  # an agent owns the conversation now
    if message_id and not seen.add_if_new(message_id):
        return                                  # webhook redelivery

    sc_post(conversation_id, "activity", {"author": {"type": "business"}, "type": "typing:start"}, 1.5)
    content = message.get("content") or {}
    text = (content.get("text") or "").strip() or NON_TEXT.get(content.get("type"), "")
    data = turn(f"zd-{conversation_id}", phone_of(message), text, budget=30.0)

    sc_post(conversation_id, "messages", {"author": {"type": "business"},
                                          "content": {"type": "text", "text": data["reply_text"]}}, 3.0)
    for document in data.get("attachments") or []:
        send_file(conversation_id, document)
    if data["transfer"]:
        sc_post(conversation_id, "passControl", {"switchboardIntegration": "next",
                                                 "metadata": handoff_metadata(data, message_id)}, 3.0)

The four filters at the top of on_message are not optional:

  1. Author. Replies from the bot and from agents come back as events. Without this filter, the bot answers itself.
  2. Switchboard. After the handoff, customer messages keep arriving at the webhook. If activeSwitchboardIntegration.integrationId is not yours, a human owns the conversation and the bot keeps quiet.
  3. Repeated message. If the bridge is slow or answers with an error, Zendesk delivers again. Keep the message id and ignore repeats.
  4. Non-text content. A photo becomes "Enviei uma foto." ("I sent a photo.") for OCP, which knows what to do with it.

The dialog key is zd-{conversation_id}, not the phone: the Zendesk conversation already identifies the customer and survives a number change. The turn is the one from the Freshdesk tutorial, with a 30-second budget, because nobody is waiting on the HTTP response here. It also returns attachments (documents the tools produced during the turn) and contact_id, which your backend records.

The two helpers:

def sc_post(conversation_id, path, body, timeout):
    """Best effort: a failed call is logged, never raised."""
    try:
        response = httpx.post(f"{SC}/conversations/{conversation_id}/{path}",
                              json=body, auth=AUTH, timeout=timeout)
        response.raise_for_status()
        return True
    except httpx.HTTPError as error:
        log.warning("sunco %s failed: %s", path, error)
        return False


def phone_of(message):
    """The customer's number; needs "Incluir origem completa" on the integration."""
    client = (message.get("source") or {}).get("client") or {}
    for candidate in (client.get("externalId"),
                      (client.get("raw") or {}).get("from"),
                      (client.get("info") or {}).get("phoneNumber")):
        digits = "".join(ch for ch in str(candidate or "") if ch.isdigit())
        if 10 <= len(digits) <= 15:
            return "+" + digits
    return ""

The number almost always comes from source.client.externalId; the other two fields cover payload variations. The bridge only accepts something between 10 and 15 digits.

Each call has its own timeout and its own plan B:

CallTimeoutOn failure
activity typing:start1.5 scarry on without typing
OCP turn (all calls)30 sapology
messages text3 slog; the customer gets nothing
messages file8 sa refusal becomes a link; a timeout does not
passControl3 slog; the bot stays in charge

An honest note: the handler does everything inside the webhook, so Zendesk may wait up to 30 seconds for the 200. It worked in our tests, but in production it is better to answer 200 right away and process from a queue. We did not find the webhook timeout documented.

Step 5: make the bot the first responder

The integration shows up as a bot under Admin Center › AI › AI agents › Marketplace bots:

Marketplace bots list with Omilia OCP Bot attached to the WhatsApp Atendimento channel
The integration shows up as a Marketplace bot

Open the bot, go to Channels and tick only the WhatsApp channel. The web widget and the other channels keep the responder they already had.

The bot's Channels screen with only the WhatsApp channel ticked and Omilia OCP Bot as responder
Tick only WhatsApp; the web widget keeps its responder

From now on, every new WhatsApp message goes to the webhook with your bot as the active responder.

Step 6: hand off with a pre-filled ticket

When OCP returns TRANSFER, the bridge sends the bot's goodbye and calls passControl with "next". The switchboard moves the active responder to Agent Workspace, which opens the ticket.

Your bot answersactive responder:your integrationAgent Workspaceopens the ticket withmetadataHuman agentthe bridge ignoresthe messagespassControl"next"dataCapture.systemField.tagsdataCapture.systemField.requester.emaildataCapture.ticketField.<id>first_message_id
Fig. 4 · The handoff swaps the active responder

The passControl metadata is what makes the ticket useful to the agent:

def handoff_metadata(data, first_message_id):
    metadata = {
        "dataCapture.systemField.tags": "ocp whatsapp escalado-ia",
        f"dataCapture.ticketField.{PROTOCOL_FIELD_ID}": data.get("contact_id") or "",
    }
    if data.get("customer_email"):
        metadata["dataCapture.systemField.requester.email"] = data["customer_email"]
    if first_message_id:
        metadata["first_message_id"] = first_message_id
    return metadata
  • dataCapture.systemField.tags: space-separated tags. Use them to route and to measure what the bot escalated.
  • dataCapture.systemField.requester.email: the customer's email, if OCP identified them.
  • dataCapture.ticketField.<id>: any custom ticket field, by numeric id. The case number goes here.
  • first_message_id: the message from which history goes into the ticket. We send the current message and the agent still saw the whole conversation; check the behaviour on your account.

The result, with the tags the bridge sent and the bot conversation right above:

Zendesk ticket after the handoff: area and channel tags, the bot conversation and the customer details with a masked phone
What the agent gets: the whole conversation and the tags the bridge sent

Step 7: send files and receive photos

This is the part the Freshdesk route from the previous tutorial cannot do. A file message with a public URL, and WhatsApp delivers the PDF as a document:

def send_file(conversation_id, document):
    body = {"author": {"type": "business"},
            "content": {"type": "file", "mediaUrl": document["url"], "altText": document["name"]}}
    try:
        # Zendesk downloads the file from mediaUrl before it answers: give it more time.
        httpx.post(f"{SC}/conversations/{conversation_id}/messages",
                   json=body, auth=AUTH, timeout=8.0).raise_for_status()
    except httpx.HTTPStatusError:
        # Refused: a link still gets the customer the document.
        sc_post(conversation_id, "messages", {"author": {"type": "business"},
                "content": {"type": "text", "text": f"{document['name']}: {document['url']}"}}, 3.0)
    except httpx.HTTPError:
        pass  # a timeout usually still delivers; a link on top would be a duplicate

The difference between a refusal and a timeout matters. Zendesk downloads the file from mediaUrl before it answers; on a timeout it nearly always finishes and delivers. If the bridge sends the link too, the customer gets the same document twice. Only an explicit refusal becomes a link.

Use a short-lived URL (a SAS valid for a few minutes, for instance): Zendesk copies the file, so the link does not need to outlive that.

The other way round, a customer photo arrives as content.type = image with a mediaUrl. The handler swaps it for "Enviei uma foto." for OCP, and your backend can download the image from the URL.

Step 8: test on a phone

CustomerWhatsAppZendeskSunshine ConversationsBridge/zendesk/messagingOCP/chat/dialogs"a copy of my invoice"conversation:messageauthor? switchboard? id seen?activity typing:start{utterance, input_fields}BACKEND → ASK + promptsmessages {type: text}messages {type: file}text, then the PDF200 (webhook)turn budget: 30 s
Fig. 3 · One turn with typing, text and a file
  1. "oi": "typing" shows up and the greeting arrives.
  2. Identification and a request for an invoice copy: the text arrives and the PDF follows, in the same conversation.
  3. A photo: the agent acknowledges it.
  4. "I want to talk to a person": the goodbye arrives, the ticket opens with the tags and the case number, and the bot does not answer the customer's next message.
  5. Reply from Agent Workspace: the customer gets it, and the bot does not answer the agent's reply.
  6. Stop the bridge and send a message: Zendesk delivers again once it is back, and the customer gets a single answer.

What bothers us

  • The switchboard is account-wide. Changing a channel's responder in a shared environment affects everyone using that channel. Test on a separate account.
  • "Include full source" is easy to miss. Without it nothing breaks: the bot answers, just without the customer's number. You find out when phone identification fails.
  • Redeliveries. Any slow or non-2xx answer becomes a double delivery. Without deduplication, the customer gets two answers.
  • passControl fails silently for the customer. If the call fails, the goodbye has already gone out and the bot still owns the conversation. Watch that log line.
  • A tool failing live. In one test the invoice-copy tool failed, and the agent apologised and offered a specialist, as the instruction says. The fallback worked; the cause was an output field with the wrong type on the OCP tool. Test each tool over the chat before WhatsApp.

Checklist before production

ItemWhy
Webhook secret compared in constant timeThe endpoint is public
Deduplication by message id, in a persistent storeZendesk delivers again
Author and switchboard filtersThe bot answers neither itself nor the agent
Fast 200 and queue processingThe webhook should not wait on OCP
Handoff metadata with tags and fieldsThe ticket reaches the agent ready to work
An alert on the passControl logNobody else will see the failure
Logs without text or full phone numbersPrivacy law, and you do not need them to debug

Leandro is the founder of Red Lotus Tecnologia, specialized in implementing, supporting, and evolving Freshdesk for support teams in Brazil.