How to Configure Dynamic Order Selection in Chat Workflows Using Webhooks
Integrating dynamic order selection into workflows enables personalized customer experiences and efficient data capture.
By using temporary fields and webhooks to fetch data from external systems, you can populate selection inputs with real-time order data and seamlessly tie the user’s selection to a chat field.
This guide provides step-by-step instructions for configuring a workflow that fetches customer orders, displays them as selectable options, and stores the selected order ID in a chat field for further processing.
Fetching customer orders using a webhook
Creating a workflow
-
Navigate to Admin > Chat > Chat Automation > Workflow > Conversation Created and click Add Workflow.
-
Enter the required details and click Next.
-
In the Designer, select the Initial Block, then click the plus (+) icon to open the context menu.
-
Configure how to collect the email using the Customer Details Block.
Refer here for more details: How to Request the Customer’s Email After Their First Message?
Configuring webhook to fetch the orders
- Navigate to Actions > Trigger Webhook.
- Configure request parameters as follows:
- Select the Request Type as GET.
- Enter the API endpoint (e.g., https://example.com/get_my_orders/{{chat.Requester.UserId}}) in the Destination URL.
- Click Test API Call to enable Response Mapping.
- Configure Response Mapping to store the API result in a temporary variable (e.g., orders), then click Add.
Displaying orders as selectable options and assigning the selected value to a chat field
-
In the API Success path, configure a dropdown input block by navigating to User Inputs > Drop-down > Get Choice via Drop-down. This displays the list of orders retrieved from the temporary field.
-
Provide the necessary details and enable Use Saved API Data to populate choices using temporary field data (e.g., tf_orders, created in the Trigger Webhook block).
-
From the Temporary Field Name dropdown, choose the field that contains the array of orders.
-
Map the Option properties to define how each should appear based on the structure of the array as follows:
- If the temporary field contains an array of objects: Map the object properties to the Label and Value fields.
- Label: The property name to display to the user.
- Value: The property name that uniquely identifies the item.
- If the temporary field contains an array of primitive values: No mapping is needed. Each value will be used as both the Label and the Value automatically.
- If the temporary field contains an array of objects: Map the object properties to the Label and Value fields.
-
For failed requests, configure the failure path and communicate to the customer with an appropriate message.
-
Use Action > Send Message to communicate appropriate messages for each path (failure or success).
-
Conclude each workflow path with an Exit block, and finally, Activate the workflow.
For dynamic options to be configured and function correctly, please ensure the following:
- Workflow order: The temporary field you select from the dropdown must be created in a previous step within the workflow. This ensures its data is available when this block is executed.
- Ensuring valid option assignment to chat fields: When using temporary field data to populate dropdown options, and assigning the selected value to a chat field, the value must exactly match one of the predefined options configured for that chat field. Otherwise, the value will be skipped and not saved.