Let's create a webhook in the Campaign Manager to send some data from Talon.One. The objective is to simulate how we can trigger an email sent by an external platform.
Let's use RequestBin as recipient of our webhook. RequestBin allows us to inspect the content of our webhook.
We want to send the following data:
- 3 attributes: the customer's email and name, and the integration Id of the session.
- 1 parameter: the body text of the email.
We recommend that you read the generic explanation about what attributes and parameters are in Webhooks before following this tutorial.
If you prefer sending the data from Talon.One as an effect, create a custom effect instead.
Creating the webhook
Let's create our webhook:
Open RequestBin and click Create a RequestBin and keep the page open. We'll need the Bin URL later.
In Talon.One, click Account > Dev Tools > Webhooks > Create webhook.
Enter the title of the webhook, for example
My webhook testand the Application which will use it.
Tick Display in Rule Builder.
bodyTextto the request.
Fill in the request verb and URL as follows:
- URL: your Bin URL
Add the following header:
Add the following payload:
sessions_integrationIdis referencing a built-in attribute.
bodyproperty references the
bodyTextproperty defined in the webhook.
How do we know what pattern to use? Read Webhooks.
The webhook is created, let's use it in a rule.
Creating the rule that uses the webhook
Open the Rule Editor and create a new rule.
Choose a condition.
In our case, we can imagine we want to trigger an email when the customer spends $500. We can use
Session total > 500and
Event Type = talon_session_closed.
Click Add effect and select Webhook: My webhook test. Our webhook has a
bodyTextparameter. Enter a value, for example
Thank you for your purchase!.
Save the rule and activate the campaign.
Now, every time a session whose total is greater than $500 and gets closed, our RequestBin receives a request containing the following body:
"name": "<name of the customer>",
"email": "<email address of the customer>",
"session_integrationId": "<the session id set from the integration layer>",
"body": "Thank you for your purchase!"
Refresh the RequestBin page to see the requests.