## Overview

Many platform modules emit **events** when something changes — a conversation is created, a payment is
confirmed, a deal changes stage, etc. You can react to these events via **webhooks** or through the
internal **automation rules**.

## Prerequisites

- Configured webhooks (for external consumption) or Automation access (for internal reactions).

## Step by step

1. Identify the module event you want to consume (e.g., conversation created, payment paid).
2. For external consumption: subscribe to the event in the webhook and handle the payload at your endpoint.
3. For internal reactions: create an automation rule with the matching trigger.
4. Validate and process the payload idempotently.

## Settings & options

- **Webhooks**: subscription per inbox/account.
- **Automation**: per-event triggers, with conditions and actions.
- **Payload**: contains the event context (ids and relevant data).

### New per-module events (real payloads)

The fields below come from each event's real source — don't invent the format. All are delivered to
**account webhooks**; calls and Flow responses also go to the **API channel** webhook. Delivery of
each group requires the **module feature enabled** on the account (the subscription works even with
the feature off, but nothing is delivered).

### Team Management — feature: Team Management

- `wfm_status_changed`, `wfm_break_started` — the agent changed status / started a break. Fields:
  `account_id`, `account_user_id`, `user_id`, `status_key`, `status_event_id`, `base_availability`, `family`.
- `wfm_break_breached` — the break exceeded its limit. Fields: the above plus `expected_seconds` and `over_by_seconds`.
- `wfm_break_ended` — the agent left a break (any path: manual switch, native dropdown or auto-offline).
  Fields: the break-start fields plus `duration_seconds`, `within_limit` and, when breached, `over_by_seconds`.
- `wfm_shift_started`, `wfm_shift_ended` — the agent's planned shift window opened/closed (evaluated server-side
  every minute). Fields: `account_id`, `account_user_id`, `user_id`, `shift_id`, `schedule_id` (when generated
  from a template), `date`, `starts_at`, `ends_at`. Each lifecycle event fires exactly once per shift.

### WhatsApp Hub broadcasts — feature: WhatsApp Hub

- `whatsapp_broadcast_started`, `whatsapp_broadcast_completed`, `whatsapp_broadcast_failed` — the broadcast
  changed state. Fields (no message content): `account_id`, `inbox_id`, `broadcast_id`, `display_id`,
  `title`, `status`, `target_type`, `recipients_count`. Works on Cloud and WazMeow (WhatsApp Web) inboxes.

### WhatsApp group welcome and farewell greetings — feature: WhatsApp Hub

- `whatsapp_group_member_welcomed`, `whatsapp_group_member_farewelled` — fire **only when** the welcome/farewell
  message was actually sent (idempotent, once per participant per dedup window). Fields: `account_id`, `inbox_id`,
  `whatsapp_group_id`, `group_jid`, `participant_jid`, `participant_phone`, `trigger` (`welcome` or `farewell`).
  No message content.

### Ads Manager — feature: Growth Ads or Ads Manager

- `ads_campaign_status_changed` — a mirrored campaign's effective status changed. Fields: `account_id`,
  `ad_account_id`, `campaign_id`, `remote_id`, `status`, `effective_status`, `previous_effective_status`.
- `ctwa_conversation_started` — a Click-to-WhatsApp conversation started (fired on the customer's message). At that point the ad window is awaiting the first reply, and `expires_at` is the **24-hour deadline to reply**. If the business replies within that deadline, the free window opens for up to 7 days, or until the exact end Meta reports. Fields:
  `account_id`, `conversation_id`, `contact_id`, `inbox_id`, `window_id`, `expires_at`.
- `ad_window_expiring` — that window is near expiry. Same fields.

### WhatsApp calls and Flow responses — feature: WhatsApp Inbox Suite

- `whatsapp_call_started`, `whatsapp_call_ended`, `whatsapp_call_recording_ready` — the call lifecycle. Fields
  (which are present depends on the stage): `provider_call_id`, `conversation_id`, `realtime`, `status`,
  `recording_url`. Delivered to account and API-channel webhooks.
  For browser recording, `whatsapp_call_recording_ready` is emitted after audio recording is enabled
  for the inbox and the uploaded audio is saved in storage. Ending the call alone does not emit it.
  The webhook must subscribe to this event; `recording_url` points to the available recording.
- `whatsapp_flow_response_received` — a customer completed a WhatsApp Flow. Fields: the `flow_response` object
  (`id`, `whatsapp_flow_id`, `screen`, `response`, `contact_id`, `conversation_id`) and the `conversation` object.
  Delivered to account and API-channel webhooks.

### FlowBuilder sessions — feature: Flow Builder

- `flow_session_started`, `flow_session_updated`, `flow_session_completed`, `flow_session_failed` — the flow
  session started, paused, completed or failed. Fields: `id`, `flow_id`, `status`, `current_node_id`,
  `conversation_id`, `account_id`.

### Sales closing completed — feature: Integrated closing or Proposals

- `sales_closing_completed` — a closing (with the copilot, or the accepted agreement's charges generated by the robot, a
  person or the API) has nothing left to issue: every charge, installment book and subscription of the agreement exists. It
  fires once, after everything was saved. Full payment is still the `deal_orders_fully_paid` event.

| Field | What it carries |
|---|---|
| `event` | `sales_closing_completed` |
| `account_id`, `closing_id` | account and closing |
| `source_kind`, `entry` | where the plan came from (`copilot` or `offer`) and who asked (`panel`, `robot` or `api`) |
| `conversation_id`, `contact_id`, `organization_id`, `crm_item_id`, `sales_offer_id`, `contract_id` | ids of the linked records (no name, document or message) |
| `total_amount`, `currency` | accepted total and currency |
| `completed_at` | date and time of completion (ISO 8601) |

The same event is an automation rule **trigger** (**Sales closing completed**), run on the closing's conversation with its
contact. Account webhooks must tick the event in the **Sales** group.

"Completed" means **everything issued**, not paid: the event never waits for a payment or for the contract (a contract
created after the full payment comes later), a subscription a person must create does not hold it, and with rolling
emission it is sent when the last charge is born. It is also a **Flow Builder** trigger (**Sales closing completed**),
with the same fields in `{{ trigger.* }}`.

### Robot control in the conversation — no specific feature

They say **who is answering the conversation**: the robot or a person. Use them to keep a label, a
board or an SLA such as "AI answering" up to date outside the platform.

- `automation_control_paused` — the robot stopped answering this conversation (the **Pause** button, a
  pause command from the API or from an automation, or a pause applied by the robot itself).
- `automation_control_taken_over` — the robot stopped **because a person took over**: the conversation
  was assigned to an agent, an agent replied, someone replied from the phone, the **Take over** button
  was used or the conversation was handed to human service.
- `automation_control_resumed` — the robot answers again after having stopped (the **Resume** button,
  a resume command or the end of a timed pause).

Fields (the same in the three events, **no message content**):

| Field | What it carries |
|---|---|
| `event` | event name |
| `account_id`, `inbox_id` | account and inbox of the conversation |
| `conversation_id` | conversation number, the same one the conversation endpoints use |
| `transition` | `paused`, `taken_over` or `resumed` |
| `state` | state after the change: `paused` or `active` |
| `source`, `reason` | stable codes for what wrote the change and why (for example `maestro_control` + `pause`, `conversation_assignment` + `human_assignee`, `message_created` + `human_message`) |
| `actor_type` | `human` (a person acted: an assignment or a reply), `control_command` (an explicit pause, resume or take-over command from the panel, the API, an automation or a flow), `robot` (the robot itself or a flow handed the conversation over) or `system` (state observed from the robot, such as the end of a timed pause) |
| `origin` | who caused the change: `human` (a person, including through the panel or the API), `robot` (the robot itself) or `automation` (an automation rule, a flow or another platform automation) |
| `automation_origin_type`, `automation_origin_id` | which automation caused the change (for example `automation_rule` or `flow` and its id); `null` when `origin` is not `automation` |
| `resume_at` | when the pause ends, if it is timed; otherwise `null` |
| `revision` | grows with every change of that conversation's control state; use it to discard a late delivery |
| `occurred_at` | date and time of the change (ISO 8601, UTC) |

Delivery rules:

- Each event fires **once per change**. A second agent replying in a conversation that was already
  taken over does not produce a new event.
- The initial state of a new conversation (robot active) is **not** announced; use
  `conversation_created`.
- The event fires for every conversation whose control state changes, whether or not the inbox has a
  robot. Filter by `inbox_id` if only some inboxes matter.
- **Only subscribers receive them.** Account webhooks must tick the events under **Robot control**.
  An API channel webhook receives them only if the channel's event list names the event; a channel
  with no list, which receives "every event", does not start receiving these.
- The same three events are also a **trigger** for automation rules and for the Flow Builder, with loop
  protection: see [Robot control triggers](/hc/ajuda/articles/automation-flows-gatilhos-de-controle-do-robo-en).

## Use cases

- Update an external system when a payment is confirmed.
- Trigger a follow-up cadence when a deal changes stage.

## Tips, limits & best practices

- Always check the real payload source before mapping fields (don't invent the format).
- Ensure idempotency by event identifier.

## Troubleshooting

- **Event not arriving**: confirm the subscription and the endpoint status.
- **Unexpected fields**: review the actual received payload and adjust the mapping.

## See also

- [REST API, tokens and webhooks](/hc/ajuda/articles/api-developers-rest-tokens-webhooks-en)
- [Automation rules](/hc/ajuda/articles/automation-flows-regras-de-automacao-en)
- [API channel: the structured event contract](/hc/ajuda/articles/api-developers-api-channel-contract-en)