Сourses

Courses

Security and Compliance

GDPR Compliance

Integration

Website integration

Webhooks in workflows

Webhook workflows allow working with parameters from events and from the contact’s card in our platform.

Webhook workflow

This request uploads and sends the contact’s data from our CDP to other systems and contrariwise collects data into our platform from external systems. Using this as a part of a workflow, you can:

  1. Address your own resource, which will process the request and return data for personalization (for example, a personal promo code or a token for authorization) in the message.

  2. Send data from an event or from the contact’s card (for example, order id, additional field “contact’s id in messenger” or “Birthday”) to an external resource.

Note:

Only the contact’s data (fields + additional fields) and the parameters from an event that triggered a workflow with a webhook can be sent through a webhook.

In most cases, the data transfer in webhooks is configured in JSON format, but XML and text formats are also available.

How to create a webhook in a workflow

1. From the Dashboard page, select Automation > Workflows in the top menu.

2. Click the New workflow button.

Webhook workflow

3. Open the Actions menu on the left panel.

4. Select Webhook.

Adding webhook block

5. Click the Create webhook button on the Settings panel on the right side.

Create webhook

Webhook configuration window opens. There you can see it is possible to select GET or POST request type.

How to work with GET request

Use this request type when you want to request data on an external resource using the link to use the data in a workflow and insert it inside the workflow. The data is transmitted to an URL as “name-value” pairs. In order to configure the webhook:

Configuring GET request

  1. Enter the webhook name using any symbols (required field) and description (optional field).

  2. Enter the resource’s URL through secured HTTPS protocol (if you enter HTTP the system does not save the link). Type in variables you want to return after the interrogation symbol. In this example, we transmit the email parameter’s value from an event triggering the workflow and address the EMAIL field related to the contact’s card on the resource to which we sent the GET request.

  3. If your resource reads parameters from headers, enable Pass parameters in headers slide button.

  4. Enter corresponding variables and values you want to address.

  5. Enable the Authentication slide button.

  6. Select authentication connector.

  7. If you need to configure a new one, click the New connector button to open Create connector window.

  8. In Create connector window:

a. Enter Connector name.

b. Select Authentication type from the dropdown list:

  • Basic
  • Bearer token
  • API key

Creating connector

c. Enter login and password/token/key.

d. Click the Done button to apply the new connector in the webhook automatically.

Now you can test the request. 

Click the Send test button. Click Select contact to select a suitable contact for testing webhook’s functionality. In the opened window, use the search bar to find a contact.

You can also find a contact using segment. For that, select View contacts from the selected group.

To view the contact’s card, click the ‘eye’ icon. To confirm contact selection, click the highlighted line with the contact from the list. Click Next, then Send request.

In the same window, you get the response.

Sending GET request

If the test is successful, click the Back arrow in the top left corner of the dialog window, and 

  1. Click the Done button.

Now the new webhook is available for selection in your workflow. 

New workflow

Note:

There are three fields in the Webhook block settings for identification of a contact by a parameter from an event: “Contact ID”, “Phone” and “Contact Email”. It is sufficient to enter one of those three parameters for a workflow to identify which contact’s data shall be received/transmitted in a webhook. In our example, the workflow triggers an event with an email variable. Therefore, ${email} shall be indicated in the Webhook block for the “Contact Email” field.

Now you can show the received data in a message using the expression in Velocity language. Go to Messages → Messages → Create Email or choose your template.

Insert the expression with the value of the received variable to output dynamic data into any text area.

Example: $!mathTool.toInteger($data.contacts_get_by_email.get(0).id)

where contacts_get_by_email is the name of your webhook (here it plays the role of a data source),

get(0).id is a call to a variable in the source pointing to the required parameter. In this case that is contact id.

When testing, the contact id is inserted into the message that has been found by the email from an event using the webhook.

Test example

How to work with POST requests

Let’s see the example of when it is necessary to send the data about the contact’s city to get a promo code for him/her from an external source.

Follow the steps below to configure a webhook with the POST request:

  1. In the webhook block settings, click the Create webhook button.

  2. In the webhook configuration window, enter the webhook name.

  3. Select the POST request type.

  4. Enter the URL of a resource using the secure HTTPS protocol. In this link, you can use variables calling event parameters or contact fields. In the example, we call TOWN – the standard contact field in our system.

  5. If your application reads parameters from headers, enable the Pass parameters in headers slide button.

  6. Enter corresponding variables and their values.

  7. Enable the Authentication slide button to configure authentication parameters.

  8. Select from existing connectors or create a new one.

To create a new authentication connector:

a. Select New connector from the dropdown list.

b. In the opened window, enter the new connector name.

c. Select the required authentication type from the available ones:

  • Basic

  • Bearer token

  • API key

d. Enter login and password/token/key.

e. Click the Done button.

  1. In the body of the POST request, you can send a random amount of data. For that, enable the corresponding slide button, select the format of the data to be inserted and insert it below. Available formats: JSON, XML, text.

  2. Test the webhook to check whether the settings are correct. Press the Send test button in the Settings window

Post webhook settings

The system suggests where to take the data for testing – from the contact’s card or from an event. If the webhook URL is configured to address a parameter from an event, then during testing the system suggests choosing an event from the list of those received by the system at any time, or to enter the event’s body manually.

Sending PORT request

Since in our example we indicate addressing to the contact field, then it is necessary to select a contact from the base in the account.

Sending POST request

You can choose another contact ① or view the selected one ②.

Upon pressing the Next and Send request buttons you receive the response:

POST request promo

To show the promo code in the message, enter the following expression into the text area:

$data.get('WH5').get('promocode')

where

  • WH5 is the source name (webhook name).

  • promocode is the name of the variable containing the promo code value.

Promo code example

The result of a promo code inserted in the letter:

Promo code inserted in a letter

Webhook management

Press Manage Webhook in the webhook block settings. The window containing the list of webhooks opens. There you can:

  • create a new webhook
  • edit existing webhooks
  • test webhooks
  • delete webhooks
  • view the list of deleted webhooks

Webhook management

Any Questions?
We’re always happy to help!
Request a Callback
Fill in the form, and our specialists will call you back as soon as possible.
Request a Callback
Chat Support
We’re waiting for your questions!
Send a Chat Message
Email
Contact the eSputnik support team
Send an Email