Receiving User Input and Completing Dynamic WhatsApp Flows
Updated
In addition to sending data from Sprinklr to WhatsApp Flow screens, Dynamic WhatsApp Flows also support sending user-entered data back to Sprinklr. This enables use cases such as product selection, form submissions, OTP validation, lead capture, appointment booking, and other interactive workflows.
When a user interacts with a Flow component, the Flow can invoke the qualifying bot and pass user-entered values through a payload. These values can then be accessed within the Dialogue Tree to drive business logic, perform validations, fetch additional data, or determine the next screen in the journey.
This article explains how to send user input from WhatsApp Flow screens to Sprinklr and how to properly configure terminal screens to complete a Flow.
Receiving Data from WhatsApp Flows
How User Input is Passed to Sprinklr
Whenever a user performs an action within a Flow, such as the given actions, the Flow can send the entered data to Sprinklr using a data exchange action.
Selecting a dropdown option
Clicking a button
Submitting a form
Choosing a product
Entering text into an input field
The payload is transmitted to the qualifying bot and becomes available within the Dialogue Tree for further processing.
Data Exchange Structure
To send user-entered data from a Flow screen to Sprinklr, the action must use:
"name": "data_exchange"Within the payload, define key-value pairs where:
The key represents the variable name that will be available within the Dialogue Tree.
The value references a form field using:
"${form.field_name}"
The form object provides access to values entered by the user on the current screen. General structure:
{"name": "data_exchange","payload": {"variableName": "${form.field_name}"}}
Sending User Input Using on-select-action
The on-select-action event is triggered when a user selects a value from a supported component, such as a dropdown. This mechanism is commonly used when the selected value needs to be processed immediately without requiring the user to click a separate button.
Example: Product Selection
Assume a dropdown field exists with the following name:
"name": "productChoice"To send the selected value to Sprinklr:
{"name": "productChoice","on-select-action": {"name": "data_exchange","payload": {"selectedProduct": "${form.productChoice}"}}}
Result
When the user selects a product:
The Flow invokes the qualifying bot.
The selected value is sent in the payload.
Within the Dialogue Tree, the value can be accessed using the key: selectedProduct.
This can then be used for validation, product lookups, pricing retrieval, or navigation decisions.
Sending User Input Using on-click-action
The on-click-action event is typically associated with buttons and footer actions. This is the most common method used when:
Submitting a form
Moving to the next screen
Confirming user selections
Triggering backend processing
Example: Sending Selected Product on Button Click
{"type": "Footer","label": "Continue","on-click-action": {"name": "data_exchange","payload": {"productSelected": "${form.productChoice}"}}}
Result
When the user clicks Continue:
The selected product value is collected from the form.
The Flow invokes the qualifying bot.
The value is passed in the payload.
The Dialogue Tree receives: productSelected.
Backend logic can determine the next screen or perform any required processing.
This pattern is commonly used when transitioning from one screen to another while preserving user-entered information.
Accessing User Input in the Dialogue Tree
Once a payload is sent through a data_exchange action:
The qualifying bot is invoked.
Payload values become available within the Dialogue Tree.
These values can be referenced in:
Decision Boxes
Update Properties Nodes
Custom Groovy Code
API Calls
Variable Assignments
This allows the Dialogue Tree to dynamically respond based on user selections and inputs.
Completing a WhatsApp Flow
Every Dynamic Flow must eventually reach a terminal state. A terminal screen represents the final screen in the user journey and signals to WhatsApp that the Flow interaction has been completed. Both the Flow JSON and the qualifying bot must be configured correctly to ensure successful completion.
Configuring a Terminal Screen
Any screen intended to be the final screen of the Flow must include:
"terminal": trueExample:
{"id": "FINAL_SCREEN","terminal": true}
This identifies the screen as the endpoint of the Flow journey.
Configuring the Final Button Action
For terminal screens, the footer button configuration differs slightly from regular navigation buttons. Instead of using: "name": "data_exchange", the action must use: "name": "complete".
Example:
{"type": "Footer","label": "Fetch","on-click-action": {"name": "complete","payload": {"productSelected": "${form.productChoice}"}}}
What Happens?
When the user clicks the button:
The Flow is marked for completion.
The payload is sent to Sprinklr.
WhatsApp prepares to close the Flow session.
The qualifying bot processes the final request.
Any final user selections or inputs can still be included in the payload and processed before the Flow ends.
Configuring the Dialogue Tree for Flow Completion
The Flow JSON alone does not complete the journey. The qualifying bot must also explicitly return a success response. Within the Dialogue Tree path corresponding to the final screen:
Add an Update Properties node.
Set: GUIDED_WORKFLOW_NEXT_SCREEN to: SUCCESS.
Example:
return "SUCCESS"This informs WhatsApp that the Flow has completed successfully.
Flow Completion Sequence
The complete termination process follows this sequence:
User reaches the terminal screen.
User clicks the final button.
The button triggers the complete action.
The qualifying bot is invoked.
Final payload values are passed to Sprinklr.
The Dialogue Tree processes the request.
GUIDED_WORKFLOW_NEXT_SCREEN is set to SUCCESS.
WhatsApp closes the Flow session.
The user is returned to the conversation thread.