KosmoKrator

communication

WhatsApp Business CLI for AI Agents

Use the WhatsApp Business CLI from KosmoKrator to call WhatsApp Business tools headlessly, return JSON, inspect schemas, and automate workflows from coding agents, scripts, and CI.

6 functions 4 read 2 write Bearer token auth

WhatsApp Business CLI Setup

WhatsApp Business can be configured headlessly with `kosmokrator integrations:configure whatsapp`.

# Install KosmoKrator first if it is not available on PATH.
curl -fsSL https://raw.githubusercontent.com/OpenCompanyApp/kosmokrator/main/install.sh | bash

# Configure and verify this integration.
kosmokrator integrations:configure whatsapp --set access_token="$WHATSAPP_ACCESS_TOKEN" --set phone_number_id="$WHATSAPP_PHONE_NUMBER_ID" --enable --read allow --write ask --json
kosmokrator integrations:doctor whatsapp --json
kosmokrator integrations:status --json

Credentials

Authentication type: Bearer token bearer_token. Configure credentials once, then use the same stored profile from scripts, coding CLIs, Lua code mode, and the MCP gateway.

KeyEnv varTypeRequiredLabel
access_token WHATSAPP_ACCESS_TOKEN Secret secret yes Access Token
phone_number_id WHATSAPP_PHONE_NUMBER_ID Text string yes Phone Number ID
base_url WHATSAPP_BASE_URL URL url no API Base URL

Call WhatsApp Business Headlessly

Use the generic call form when another coding CLI or script needs a stable universal interface.

kosmo integrations:call whatsapp.whatsapp_send_message '{
  "to": "example_to",
  "body": "example_body",
  "preview_url": true
}' --json

Use the provider shortcut form for shorter human-facing commands.

kosmo integrations:whatsapp whatsapp_send_message '{
  "to": "example_to",
  "body": "example_body",
  "preview_url": true
}' --json

Agent Discovery Commands

These commands return structured output for coding agents that need to inspect capabilities before choosing a function.

kosmo integrations:docs whatsapp --json
kosmo integrations:docs whatsapp.whatsapp_send_message --json
kosmo integrations:schema whatsapp.whatsapp_send_message --json
kosmo integrations:search "WhatsApp Business" --json
kosmo integrations:list --json

All CLI Functions

Every function below can be called headlessly. The generic form is stable across all integrations; the provider shortcut is shorter but specific to WhatsApp Business.

whatsapp.whatsapp_send_message

Write write

Send a text message to a WhatsApp recipient. Use this for replying within an existing 24-hour customer service window. For new conversations, use the send_template tool instead.

Parameters
to, body, preview_url

Generic CLI call

kosmo integrations:call whatsapp.whatsapp_send_message '{"to":"example_to","body":"example_body","preview_url":true}' --json

Provider shortcut

kosmo integrations:whatsapp whatsapp_send_message '{"to":"example_to","body":"example_body","preview_url":true}' --json

whatsapp.whatsapp_get_message

Read read

Retrieve a specific WhatsApp message by its ID. Returns the message content, status (sent, delivered, read), and timestamps.

Parameters
message_id

Generic CLI call

kosmo integrations:call whatsapp.whatsapp_get_message '{"message_id":"example_message_id"}' --json

Provider shortcut

kosmo integrations:whatsapp whatsapp_get_message '{"message_id":"example_message_id"}' --json

whatsapp.whatsapp_list_templates

Read read

List approved WhatsApp message templates. Templates are required to initiate new conversations outside the 24-hour service window.

Parameters
limit, after

Generic CLI call

kosmo integrations:call whatsapp.whatsapp_list_templates '{"limit":1,"after":"example_after"}' --json

Provider shortcut

kosmo integrations:whatsapp whatsapp_list_templates '{"limit":1,"after":"example_after"}' --json

whatsapp.whatsapp_list_contacts

Read read

List WhatsApp contacts for the business phone number. Returns WhatsApp IDs and profile names.

Parameters
limit, after

Generic CLI call

kosmo integrations:call whatsapp.whatsapp_list_contacts '{"limit":1,"after":"example_after"}' --json

Provider shortcut

kosmo integrations:whatsapp whatsapp_list_contacts '{"limit":1,"after":"example_after"}' --json

whatsapp.whatsapp_send_template

Write write

Send a template-based WhatsApp message. Use this to initiate new conversations outside the 24-hour window. The template must be pre-approved in the WhatsApp Business Manager.

Parameters
to, template_name, language, components

Generic CLI call

kosmo integrations:call whatsapp.whatsapp_send_template '{"to":"example_to","template_name":"example_template_name","language":"example_language","components":"example_components"}' --json

Provider shortcut

kosmo integrations:whatsapp whatsapp_send_template '{"to":"example_to","template_name":"example_template_name","language":"example_language","components":"example_components"}' --json

whatsapp.whatsapp_get_current_user

Read read

Get the authenticated WhatsApp Business user info — name, email, and business ID. Useful for verifying which account is connected.

Parameters
none

Generic CLI call

kosmo integrations:call whatsapp.whatsapp_get_current_user '{}' --json

Provider shortcut

kosmo integrations:whatsapp whatsapp_get_current_user '{}' --json

Function Schemas

Use these parameter tables when building CLI payloads without calling integrations:schema first.

whatsapp.whatsapp_send_message

Send a text message to a WhatsApp recipient. Use this for replying within an existing 24-hour customer service window. For new conversations, use the send_template tool instead.

Operation
Write write
Schema command
kosmo integrations:schema whatsapp.whatsapp_send_message --json
ParameterTypeRequiredDescription
to string yes Recipient phone number in international format without + (e.g. "15551234567").
body string yes Text content of the message (max 4096 characters).
preview_url boolean no Whether to render URLs as link previews in the message (default: false).

whatsapp.whatsapp_get_message

Retrieve a specific WhatsApp message by its ID. Returns the message content, status (sent, delivered, read), and timestamps.

Operation
Read read
Schema command
kosmo integrations:schema whatsapp.whatsapp_get_message --json
ParameterTypeRequiredDescription
message_id string yes The WhatsApp message ID (e.g. "wamid.HBgM...").

whatsapp.whatsapp_list_templates

List approved WhatsApp message templates. Templates are required to initiate new conversations outside the 24-hour service window.

Operation
Read read
Schema command
kosmo integrations:schema whatsapp.whatsapp_list_templates --json
ParameterTypeRequiredDescription
limit integer no Maximum number of templates to return (default: 100).
after string no Cursor for pagination — pass the value from a previous response to get the next page.

whatsapp.whatsapp_list_contacts

List WhatsApp contacts for the business phone number. Returns WhatsApp IDs and profile names.

Operation
Read read
Schema command
kosmo integrations:schema whatsapp.whatsapp_list_contacts --json
ParameterTypeRequiredDescription
limit integer no Maximum number of contacts to return (default: 100).
after string no Cursor for pagination — pass the value from a previous response to get the next page.

whatsapp.whatsapp_send_template

Send a template-based WhatsApp message. Use this to initiate new conversations outside the 24-hour window. The template must be pre-approved in the WhatsApp Business Manager.

Operation
Write write
Schema command
kosmo integrations:schema whatsapp.whatsapp_send_template --json
ParameterTypeRequiredDescription
to string yes Recipient phone number in international format without + (e.g. "15551234567").
template_name string yes Name of the approved WhatsApp template (e.g. "hello_world").
language string no Language code for the template (e.g. "en_US", "en"). Defaults to "en".
components array no Template components — an array of objects with "type" (header, body, button) and corresponding parameters. Pass as a JSON string or array.

whatsapp.whatsapp_get_current_user

Get the authenticated WhatsApp Business user info — name, email, and business ID. Useful for verifying which account is connected.

Operation
Read read
Schema command
kosmo integrations:schema whatsapp.whatsapp_get_current_user --json
ParameterTypeRequiredDescription
No parameters.

Permissions

Headless calls still follow the integration read/write permission policy. Configure read/write defaults with integrations:configure. Add --force only for trusted automation that should bypass that policy.