Skip to content

WhatsApp Flow Handler

Automation type WhatsApp Flow handler (wa_flow_handler) is a backend flow specifically for processing data requests from Dynamic WhatsApp Flow forms synchronously. Unlike conversational automations (flow) which interact within asynchronous chat messages, wa_flow_handler works like a webhook endpoint that receives form input from Meta, fetches data from external APIs, and returns a screen response within seconds.

Automation Builder canvas for the Clinic appointment WhatsApp Flow handler (dictionaries)
Automation Builder canvas for the Clinic appointment WhatsApp Flow handler (dictionaries)

Difference between wa_flow_handler vs Conversational Flow (flow)

Section titled “Difference between wa_flow_handler vs Conversational Flow (flow)”
Aspectwa_flow_handler (Flow Handler)flow (Conversational Automation)
TriggerMeta Flow webhook (INIT or data_exchange)Inbound chat messages or calls
Execution ModelSynchronousAsynchronous (Multi-turn chat / stateful)
Time Limit (Budget)~15 seconds (per Meta’s client timeout limit)Up to a 24-hour interaction window
Terminal NodeMust end at the node Respond to Flow (waFlowRespond)Ends with a reply message, agent escalation, or completion
Input Variablesaction, screen, data.*, client_account_idText message, contact, channel, custom attributes

Execution Time Limit (Sync Budget)

Meta requires that the response from the server arrives on the user’s phone within a maximum of 10–15 seconds. Make sure the external API called by the node httpRequest responds quickly. Handlers must not usedelayor unbounded loops.

To guarantee instant and deterministic synchronous execution, the studio builder for wa_flow_handler provides a dedicated node palette:

Node TypeFunction
Start (startNode)The starting point of the handler flow when Meta sends a form interaction payload.
HTTP Request (httpRequest)Calls your backend’s or a third party’s REST API (with support for Credential Profile).
Set Variable (setVariable)Sets local variable values for temporary data manipulation.
Extract from JSON (extractFromJson)Retrieves a specific column value from an API JSON response (e.g. $.name or $.balance).
Transform JSON (transformJson)Restructures the data object before it is submitted to the Flow screen.
Condition (condition)Performs logic branching (e.g. checking the value of action, screen, HTTP status codes, or the operator empty/not_empty/in/gt).
Dictionary Lookup (dictionaryLookup)Retrieves option data or key mappings from a Flow Dictionary backed by Redis/SQL (in exact or prefix).
Respond to Flow (waFlowRespond)A mandatory end node that sends the destination screen and response data back to WhatsApp in navigate, error, or completeaction.

A tenant’s static or semi-static data catalogs (such as lists of cities, branches, or service categories) can be stored in Settings → Flow Dictionaries (/settings/flow-dictionaries) for sub-millisecond lookups via the node Dictionary Lookup (dictionaryLookup) without needing to call an external API:

  • Exact Key Mode: Direct lookup based on a unique key (e.g. jkt or bdg). It populates the variable {dict}_key, {dict}_title, and extracts JSON data fields with variable prefix support (assignPrefix).
  • Prefix Search Mode: Tiered prefix search (up to 20 options) to populate Dynamic Dropdown components based on the previous screen’s input (e.g. {{data.city}}_).
  • Automatic Option List (emitOptions): For compact catalogs (≤ 200 keys and ≤ 32 KB), the node can export the list of options directly to a context variable (e.g. city_options) for the initial form (INIT).
  • Flow from Inbox: When an agent sends a Flow from the Inbox, the platform automatically injects contact_phone_number and contact_name into the handler context.

You can read the complete guide on creating dictionaries, bulk JSON/CSV import, and capacity limits in the guide Flow Dictionaries.

When the Flow handler is executed, the system automatically populates the following variables inside the execution context:

  • action: The action type from Meta (INIT for the initial form opening, or data_exchange when the user presses an action button on a screen).
  • screen: The WhatsApp Flow screen ID where the action was triggered (for example LOOKUP, PROFILE, PAYMENT).
  • data.*: The data object submitted from the previous screen. For example, if an input field has the value user_id, you can access it via {{data.user_id}}.
  • flow_token: A unique correlation token from Meta for the active Flow form.
  • client_account_id: The tenant account ID on the platform.
  • http_handle: The execution result status of the node httpRequest.

Use the node Condition after calling httpRequest to check the variable http_handle:

  • success: The API call succeeded (HTTP 2xx code).
  • client_error: A client error occurred, such as data not found or incorrect authentication (HTTP 4xx).
  • server_error: A problem occurred on the service provider’s server (HTTP 5xx).
  • network_error: The request failed to reach the destination server due to connection issues or a timeout.

Connect each output port on the Condition node to the appropriate follow-up flow.

Returning a Response to WhatsApp (waFlowRespond)

Section titled “Returning a Response to WhatsApp (waFlowRespond)”

node branches based on handle (one outgoing edge per rule). Respond to Flow (waFlowRespond) is a closing node that every execution path must reach. This node provides 3 operation modes:

  1. Navigate (navigate): Moves to the destination screen (screen / screenTemplate) and sends a dynamic data payload (data / dataTemplate).

    Example node response data for the screen RESULT:

    {
    "user_id": "{{data.user_id}}",
    "name": "{{user_name}}",
    "plan": "{{user_plan}}",
    "status": "Aktif"
    }
  2. Error (error): Displays an error message directly on the user’s active screen without triggering a screen transition (screen is left empty). Error messages can be filled in via the general message field errorMessage or per input field mapping errorMessages.

  3. Complete (complete): Completes the Flow form and returns a success signal (screen: "SUCCESS"). The completion data is sent in the parameter object params (under extension_message_response). The system automatically injects the flow token (flow_token) into the response parameters if it has not been explicitly specified.

Screen Data Field Matching & Prohibition of Extra Keys

Property names inside the response JSON data must be exactly the same as the variable names of the control From handler → Variable in the visual Flow editor screen (name, plan).

Keys in the response object data must be a subset of the data model declared by the destination screen. Sending extra keys that are not defined on the destination screen (e.g. sending city_title when the screen only accepts city and branch_options) will cause the WhatsApp app to throw an error “Something went wrong” when landing on that screen. Read more in Meta Constraints on Dynamic WhatsApp Flow.

After the handler has been created and saved:

  1. Open Settings → Form handlers (/settings/wa-flows).
  2. Find the desired Flow, then click Connect.
  3. Select the handler you just created.
  4. Test it using the feature Test Dispatch before publishing to customers.