Channels

How to Connect OpenClaw to Zalo

5 min read

Browse more in Channels.

All channels guides →

This guide walks you through connecting OpenClaw to the Zalo Bot API so your agent can chat with users on Zalo. You will create a Zalo bot token, wire it into the OpenClaw gateway, and choose between long-polling or webhook delivery.

By the end, your OpenClaw agent will respond to Zalo direct messages using the Marketplace-bot flow.

Setup flow

Prerequisites

  • An existing OpenClaw gateway deployment with access to install and configure plugins.
  • Access to the Zalo Bot Platform at https://bot.zaloplatforms.com with permission to create a bot.
  • A Zalo Bot Creator / Marketplace bot (this guide reflects Marketplace-bot behavior, not Zalo Official Account bots).

Steps

  1. 1

    Ensure the Zalo plugin is available in your OpenClaw install

    OpenClaw bundles the Zalo channel plugin in current packaged releases, but older or custom builds may exclude it. Verify that your build includes the plugin, and if not, install it so the gateway can speak to the Zalo Bot API.

    Use the CLI install path for most setups, or the local path variant if you work from a source checkout.

    bash
    openclaw plugins install @openclaw/zalo
  2. 2

    Install the Zalo plugin from a local source checkout (optional path)

    If you maintain a custom OpenClaw build or a forked Zalo plugin, install it from your local filesystem instead of the registry. This keeps your gateway aligned with your source tree while still using the standard plugin mechanism.

    Only use this path if your packaged build does not already include Zalo.

    bash
    openclaw plugins install ./path/to/local/zalo-plugin
  3. 3

    Create a Zalo bot and obtain the bot token

    You need a bot token from the Zalo Bot Platform so OpenClaw can authenticate to the Zalo API. Create a new bot, configure its basic settings, then copy the full token string.

    For Marketplace bots, Zalo may surface the runtime token in the bot’s welcome message after creation, so make sure you grab that exact `numeric_id:secret` value.

    text
    1.   Go to https://bot.zaloplatforms.com and sign in.
    2.   Create a new bot and configure its settings.
    3.   Copy the full bot token (typically `numeric_id:secret`). For Marketplace bots, the usable runtime token may appear in the bot’s welcome message after creation.
  4. 4

    Configure the Zalo bot token in OpenClaw

    Wire the Zalo bot token into your gateway config so the Zalo channel can start. botToken` config.

    The minimal config below enables the channel, sets the token, and keeps DM access on the default pairing policy.

    json
    {
      channels: {
        zalo: {
          enabled: true,
          accounts: {
            default: {
              botToken: "12345689:abc-xyz",
              dmPolicy: "pairing",
            },
          },
        },
      },
    }
  5. 5

    Set the Zalo bot token via environment variable (default account only)

    If you prefer environment-based secrets, set `ZALO_BOT_TOKEN` instead of hardcoding the token in your config file. This works for the default Zalo account and keeps the token out of version control.

    Make sure your process manager or shell exports this variable before starting the gateway.

    bash
    ZALO_BOT_TOKEN=...
  6. 6

    Restart the OpenClaw gateway to bring up the Zalo channel

    After you add the token via env or config, restart the gateway so it can resolve the Zalo credentials and start the channel. Zalo initializes when a valid token is present, so a restart is required for changes to take effect.

    Once it’s up, DM access defaults to pairing, and you will approve the first contact with a pairing code.

    text
    1.   Restart the gateway. Zalo starts when a token is resolved (env or config).
    2.   DM access defaults to pairing. Approve the code when the bot is first contacted.
  7. 7

    Approve DM access using the pairing flow

    By default, unknown Zalo senders must be paired before the agent responds, which protects your bot from random traffic. When a user first messages the bot, they receive a pairing code that you approve from the CLI.

    Use the pairing commands below to list pending codes and approve the ones you trust.

    bash
    openclaw pairing list zalo
    openclaw pairing approve zalo <CODE>
  8. 8

    Optionally enable webhook mode instead of long-polling

    OpenClaw uses long-polling for Zalo by default, which avoids exposing a public URL. webhookSecret`.

    Remember that webhook and getUpdates polling are mutually exclusive per the Zalo API, and the secret must meet the documented length requirements.

    text
    Webhook mode: set `channels.zalo.webhookUrl` and `channels.zalo.webhookSecret`.
        *   The webhook secret must be 8-256 characters.
        *   Webhook URL must use HTTPS.
        *   Zalo sends events with `X-Bot-Api-Secret-Token` header for verification.
        *   Gateway HTTP handles webhook requests at `channels.zalo.webhookPath` (defaults to the webhook URL path).
        *   Requests must use `Content-Type: application/json` (or `+json` media types).
        *   Duplicate events (`event_name + message_id`) are ignored for a short replay window.
        *   Burst traffic is rate-limited per path/source and may return HTTP 429.
  9. 9

    Send a test message to a Zalo chat from the CLI

    Once the channel is live, verify end-to-end delivery by sending a message from the OpenClaw CLI to a known Zalo chat id. This confirms that your token, routing, and delivery mode are all working.

    Use the `--channel zalo` and `--target` flags to direct the message to the right Zalo conversation.

    bash
    openclaw message send --channel zalo --target 123456789 --message "hi"

Configuration

OptionDescriptionExample
ZALO_BOT_TOKENEnvironment variable for the default Zalo bot token used by the gateway.ZALO_BOT_TOKEN=12345689:abc-xyz
channels.zalo.enabledEnables or disables startup of the Zalo channel in the gateway.true
channels.zalo.botTokenLegacy single-account shorthand for the Zalo bot token from Zalo Bot Platform.12345689:abc-xyz
channels.zalo.tokenFilePath to a regular file containing the Zalo bot token; symlinks are rejected./etc/openclaw/zalo-bot-token
channels.zalo.dmPolicyControls DM access policy for Zalo: pairing, allowlist, open, or disabled.pairing
channels.zalo.allowFromDM allowlist of Zalo user IDs; set to "*" when using the open policy.[123456789,987654321]
channels.zalo.groupPolicyControls group inbound handling (open, allowlist, or disabled); present but not usable for Marketplace bots.allowlist
channels.zalo.groupAllowFromAllowlist of sender IDs permitted to trigger the bot in groups, falling back to allowFrom when unset.[123456789]
channels.zalo.mediaMaxMbMaximum size in megabytes for inbound and outbound media on Zalo.5
channels.zalo.webhookUrlHTTPS URL that enables webhook mode for receiving Zalo events.https://gateway.example.com/zalo/webhook
channels.zalo.webhookSecretSecret token (8–256 characters) used to verify incoming Zalo webhooks.s3cr3tTok3n
channels.zalo.webhookPathHTTP path on the gateway server where Zalo webhook requests are handled./zalo/webhook
channels.zalo.proxyProxy URL used for outbound Zalo API requests.http://proxy.internal:8080
channels.zalo.accounts.default.botTokenBot token for the default Zalo account when using the multi-account config structure.12345689:abc-xyz
channels.zalo.accounts.default.tokenFileRegular file path containing the token for the default Zalo account; symlinks are rejected./etc/openclaw/zalo-default-token
channels.zalo.accounts.default.nameDisplay name for the default Zalo account in multi-account setups.primary-zalo-bot
channels.zalo.accounts.default.enabledEnables or disables the default Zalo account.true
channels.zalo.accounts.default.dmPolicyDM policy for the default Zalo account, overriding the global Zalo DM policy.pairing
channels.zalo.accounts.default.allowFromPer-account DM allowlist for the default Zalo account.[123456789]
channels.zalo.accounts.default.groupPolicyPer-account group policy for the default Zalo account; schema exists even though Marketplace bots lack group support.allowlist
channels.zalo.accounts.default.groupAllowFromPer-account group sender allowlist for the default Zalo account.[123456789]
channels.zalo.accounts.default.webhookUrlPer-account webhook URL for the default Zalo account.https://gateway.example.com/zalo/default-webhook
channels.zalo.accounts.default.webhookSecretPer-account webhook secret for the default Zalo account.defaultAccSecret
channels.zalo.accounts.default.webhookPathPer-account webhook path for the default Zalo account./zalo/default-webhook
channels.zalo.accounts.default.proxyPer-account proxy URL for the default Zalo account.http://proxy.internal:8080

Troubleshooting

Bot doesn’t respond to Zalo messages.

This usually means the token is invalid, the sender is not approved, or the gateway is not processing events. Probe the channel with the status command, confirm the pairing or allowlist rules, and tail the gateway logs to see what Zalo events are doing.

bash
openclaw channels status --probe
openclaw logs --follow

Webhook not receiving events from Zalo.

When webhook mode is enabled, Zalo requires an HTTPS URL, a valid 8–256 character secret, and a reachable HTTP endpoint on the configured path. Also ensure you are not running getUpdates polling at the same time, since polling and webhooks are mutually exclusive for Zalo.

Frequently asked questions

Powered by Mem0

Add persistent memory to OpenClaw

Official Mem0 plugin for OpenClaw keeps context across chats and tools. Smaller prompts, lower cost, better continuity for your agents.

More in Channels