How does it work?
When a user responds to a message, we can configure a webhook to be triggered and send an HTTP request to your endpoint configured in Treble. This webhook is one of the most important for implementing complex use cases, such as process automation or integration with other applications. For example, you can configure a webhook to capture a customer’s response when asked for their identification number. Treble will send an HTTP request to your endpoint configured in Treble with the customer’s response which you can process in your application. Subsequently, you can even return information to the Treble conversation (flow) to display dynamic information obtained by your server, or route the conversation down another path.Message Response Webhook Flow Diagram
In this example, the customer responds to a WhatsApp message with their identification number. Treble sends an HTTP request to your endpoint configured in Treble with the customer’s response with the identification number. Your server processes it and returns information to Treble to continue the conversation.
How to configure a message response webhook?
2
Creating a flow
Go to the “Conversations” section and click the “Create Conversation” button. You can also configure a message read webhook in an existing flow. For this, go to the “Flows” section and click the “Edit” button of your flow.

3
Add message blocks
Let’s add the first message block. Click the “Add block” button. In this case, we’re going to add a previously created and Meta-approved message template (HSM). Then we’ll connect a simple message block with the HSM block. Here we’re going to ask for the customer’s identification number.

4
Activate webhook and add endpoint
Now, let’s double-click on the arrow that comes out of the message block and connects to the response block. A text field will appear at the top. In this field, we’re going to add the endpoint to which you want the HTTP request to be sent when this message is read.

5
Specify the variable to capture the response
It’s necessary to specify the variable to capture the customer’s response. Let’s double-click on the question block where we’re asking for the identification number. In the panel that opens on the left, let’s click on the “Save response as variable” option. Two fields will appear:
The use of variables in Treble is a key concept for process automation. You can read more about them in:
- “Response type”: Here you can choose the type of response you want to capture. In this case, we’re going to choose “Number”.
- “Variable name”: Here you can add the name of the variable you want to be saved. In this case, we’re going to add
customer_id
.

Variables in Treble
Learn more about variables in Treble.
6
Save changes
For the webhook to be activated, you must save the changes. If you’re in a new flow, click the “Publish Conversation” button to save the flow. If you’re in an existing flow, click the “Save” button to save the changes.
Ready! Now, when someone responds to your message, the webhook will be triggered and send an HTTP request to your endpoint configured in Treble. The request body will contain information about the response event.
Message Response Webhook Body
Learn more about the message response webhook body.
Advanced Tutorial - Your Server Response
In the step-by-step above, we saw how to configure a message response webhook in Treble. Now, let’s see how to process the customer’s response in your server. For this, it’s necessary that your server has a public endpoint to which the HTTP request can be sent.Step by Step
- Configure your server: Make sure your server is configured to receive HTTP requests. You can use a framework like Express in Node.js to facilitate this process.
- Create an endpoint for the webhook: Define an endpoint in your server that can receive the webhook requests.
- Process the request: Extract the relevant information from the request and perform the necessary actions, such as verifying if the user exists.
-
Send a response to Treble:
Return a response to Treble with the processed information, such as the user’s authentication status. The response must be a JSON with the following format:
user_session_keys
is an array of objects that contains the key and value of the response. For this example, the key should be server_user_valid
and the value should be yes
if the user exists or no
if they don’t exist. However, you can send back to Treble any information you need to continue the conversation. Such response can contain more variables that can be used in the flow.
Example:
Code Example
Here’s a basic example of how you could implement this in Node.js:- Back in your conversation (flow) in Treble, we connect a condition block to evaluate the server response. Note how the
server_user_valid
variable is a session variable that is saved in the flow and is the response that is sent to the server. The condition block is an “If” type block and evaluates if theserver_user_valid
variable is equal toyes
. If so, it continues on the authenticated user path. If not, it continues on another path.

Ready! We have configured a message response webhook in Treble. Now, when someone responds to your message, the webhook will be triggered and send an HTTP request to your endpoint configured in Treble with the customer’s response. Your server processes it and returns information to Treble to continue the conversation.
Keep in mind
- You must configure the response webhook for each response (arrow ) that comes out of a message block. If you configure it on a single response or the first one, it will only be triggered for the first response.

Your server’s response to the webhook cannot take more than 10 seconds. If your server takes more than 10 seconds to respond, the webhook will be marked as timeout and the conversation flow in Treble will continue. You can extend the response time with the
[REQUEST_TRIGGER]
option. For more information, you can read the article: Stop Treble conversation and wait for your server response.