Creating webhooks
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 Webhook.site as recipient of our webhook. Webhook.site 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 Webhook.site and, from the Your unique URL section, click Copy to clipboard. Preserve the copied URL for use in step 6.
In Talon.One, click Account > Tools > Webhooks > Create Webhook.
Enter the title of the webhook, for example
My webhook test
and the Application which will use it.Tick Display in Rule Builder.
Add a
string
parameter namedbodyText
to the request.Fill in the request verb and URL as follows:
- Verb:
POST
- URL: the Webhook.site URL you copied in step 1.
- Verb:
Add the following header:
Content-Type: application/json
In Request payload, add the following payload:
Request payload{
"name": "${$Profile.Attributes.name}",
"email": "${$Profile.Attributes.email}",
"session_integrationId": "${$Session.IntegrationId}",
"body": "${$bodyText}"
}Important- The
name
andemail
properties are referencing custom attributes. - Then
sessions_integrationId
is referencing a built-in attribute. - The
body
property references thebodyText
property defined in the webhook.
How do we know what pattern to use? Read Webhooks.
- The
Click Create.
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 > 500
andEvent Type = talon_session_closed
.Click Add effect and select Webhook: My webhook test. Our webhook has a
bodyText
parameter. Enter a value, for exampleThank 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 Webhook.site 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!"
}