Skip to main content

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.

note

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:

  1. Open Webhook.site and, from the Your unique URL section, click Copy to clipboard. Preserve the copied URL for use in step 6.

  2. In Talon.One, click Account > Tools > Webhooks > Create Webhook.

  3. Enter the title of the webhook, for example My webhook test and the Application which will use it.

  4. Tick Display in Rule Builder.

  5. Add a string parameter named bodyText to the request.

  6. Fill in the request verb and URL as follows:

    • Verb: POST
    • URL: the Webhook.site URL you copied in step 1.
  7. Add the following header:

    Content-Type: application/json
  8. 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 and email properties are referencing custom attributes.
    • Then sessions_integrationId is referencing a built-in attribute.
    • The body property references the bodyText property defined in the webhook.

    How do we know what pattern to use? Read Webhooks.

  9. Click Create.

The webhook is created, let's use it in a rule.

Creating the rule that uses the webhook

  1. Open the Rule Editor and create a new rule.

  2. 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 and Event Type = talon_session_closed.

  3. Click Add effect and select Webhook: My webhook test. Our webhook has a bodyText parameter. Enter a value, for example Thank you for your purchase!.

  4. 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:

Request payload example
{
"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!"
}