Webhook basics

A webhook is a simple notification that is sent as an HTTPS POST request after something occurs. In Leanplum, a webhook is a type of message you can use to send real-time Leanplum user data to another server.

For example, you could send a webhook to confirm when a user reads a message. Or, you could send a webhook that triggers a third-party service to do something, like send an email, Slack someone, or store something in a database.

Create a single-message webhook campaign

To create a webhook in Campaigns, click on the Create Campaign button and select Webhook in the Create Campaign dialog.

19601960

Add a webhook to a multi-message campaign

In a multi-message campaign add a new action to an existing campaign and select Webhook as the action type.

Configure a webhook

15801580

Webhook config in Campaigns

1. Set and customize the URL

This is where Leanplum will send the webhook data. The URL can be common to all users in the audience (fixed), or it can include personalized information about each user, using user attributes and/or event parameters. For more, see Personalize a message.

14961496

📘

Authentication

Basic authentication can be used by appending the username and password to the URL in the following format: https://username:[email protected] .

2. Set the content type

The content type is an HTTP header setting used when sending the actual POST request. You can choose between application/json and application/x-www-form-urlencoded.

15581558

If the webhook is set to x-www-form-urlencoded, all the Data variables will be formatted using the x-www-form-urlencoded standard. For example, if the Data variables are set like:

first_name: Mary
last_name: Doe

Then the body will look like:

first_name=Mary&last_name=Doe

If the webhook is set to application/json, the body will look like:

{
  "first_name": "Mary",
  "last_name": "Doe"
}

🚧

Be sure to set this to the correct content type for the service or API you’re delivering the webhook to.

3. Send data with the webhook

You can send custom key-value pairs within the message that can be utilized by the server that receives the webhook. The values are set directly in Leanplum, and they can include personalized values. For more, see Message templating {{.

14721472

4. Select audience (Single-message campaign)

Since a webhook is a message, in a single-message campaign you can narrow the audience down using segment criteria. See the Audience section to see a full list of segmentation options.

15801580

5. Select delivery method (Single-message campaign)

You have similar delivery options with webhooks as you do push notifications: One-time, Recurring, Triggered, or manual. The most common method is triggered, which allows you to send a webhook when a user does something in your app.

15801580

Did this page help you?