Drip Automation

Getting Started

Introduction

Drip autoresponder is used to send a notification or a series of notification to the users depending upon the criteria specified in the drip campaign. Drip campaign criteria are evaluated whenever a subscriber opt-in for push notification or an existing subscriber is added to a segment.

A drip campaign is initialized when a subscriber satisfies the criteria specified in the drip autoresponder.

Creating Drip Automation

Request URL

https://api.pushengage.com/apiv1/drips
Method

POST
Request Parameters

Required Parameters

Parameter Name Parameter Type Description
campaign_name String Title of the campaign.
notification Array Array of notification to be displayed in the drip campaign.

Optional Parameters

Parameter Name Parameter Type Description
send_to Object Drip criteria for which the drip will be initialized.
utm_params Objects UTM params to be added in the notification url for Google Analytics tracking.

Notification

Parameter Name Type Description
title String Title of the notification.
message String The message to be displayed in the notification.
url String URL to be opened, on clicking the received notification.
image_url String The URL of an image to be displayed as notification icon.
big_image_url String The URL of an image to be displayed as part of the notification.
require_interaction Number This defines whether notification remains in browser without user interaction. Value can be either 1 or 0.
expiry Number Expiry time in seconds after which the notification will not be sent to subscribers. The default time is 28 days.
schedule_options Object schedule_options is params which accepts parameters which will decide when to send the notifications.
actions Array Details of action button to be displayed in the notification. It accept maximum two actions.

Send To Parameters

Parameter Name Parameter Type Description
include_segments array of string include_segments accepts value as an array of segment name. Notifications will be sent to only those subscribers, which are subscribed to in this segment.
exclude_segments array of string exclude_segments accepts value as an array of segment name. Notifications will be sent to only those subscribers, which are not subscribed to in this segment.
include_countries array of string include_countriesaccepts value as an array of countries. Notifications will be sent to only those subscribers, which are not subscribed to these countries.
exclude_countries array of string exclude_countries accepts value as an array of countries. Notifications will be sent to only those subscribers, which are not subscribed to these countries.
include_states array of string include_states accepts value as an array of states. Notifications will be sent to only those subscribers, which are subscribed from these states.
exclude_states array of string exclude_states accepts value as an array of states. Notifications will be sent to only those subscribers, which are not subscribed from these states.
include_cities array of string include_cities accepts value as an array of the city. Notifications will be sent to only those subscribers, which are subscribed to these cities.
exclude_cities array of string exclude_cities accepts value as an array of the city. Notifications will be sent to only those subscribers, which are not subscribed to these cities.

Note

For the drip campaign sent_to option contains either a custom segment or geo segments at a time.

Example

// Custom Segments

"send_to": {
        "include_segments": ["segmentName1", "segmentName2"],
        "exclude_segments": ["segmentExcludeName1", "segmentExcludeName2"],
    }

// Geo Segments

"send_to": {
        "include_countries": ["India"],
        "exclude_countries": ["Nepal"],
        "include_states": ["Karnataka"],
        "include_cities": ["Bengaluru"]
    }

Utm Parameters

Parameter Name Parameter Type Description
enabled Boolean Indicates whether UTM params is enabled or not. Value can be either 'true' or 'false'.
source String Identify the source of your traffic.
medium String Identify the medium the link was used.
campaign String Identify a strategic campaign or specific promotion.
term String Suggested for paid search to identify keywords.
content String Suggested for additional details for content-targeted content.

Schedule Options Parameters

Parameter Name Parameter Type Description
type String type accepts two values rightaway and after.The type of first notifications can be either rightaway or after and the rest of the following notifications it should be after.
value Number value accepts a number and that number will define when to send this notification to subscribers. Maximum allowed value is 365 days.
unit String unit accepts the values in minutes, days and hours.
at String at accepts the time in the format of (HH:MM:SS) and it only works when unit is days.

Action Parameters

Parameter Name Parameter Type Description
label String Text to display on action button.
url String URL to be opened, on clicking the button when received a notification.
image_url String Icon to be displayed in the button as part of the notification.

Sample Code

{
    "campaign_name": "Drip Campaign Autoresponder",
    "send_to": {
       "include_segments": ["segmentName1", "segmentName2"],
        "exclude_segments": ["segmentExcludeName1", "segmentExcludeName2"]
    },
     "utm_params": {
        "enabled": true,
        "source": "pushengage",
        "medium": "pushengage medium",
        "campaign": "pushengage campaign",
        "term": "pushengage term",
        "content": "pushengage content"
    },
    "notifications": [
        {
            "schedule_options": {
                "type": "rightaway"
            },
            "title1": "Notification Title 1",
            "message": "Notification Message 1",
            "url": "https://www.pushengage.com",
            "image_url": "https://assetscdn.pushengage.com/site_assets/frontend/revamped_assets/img/logo.png",
            "big_image_url": "https://assetscdn.pushengage.com/site_assets/frontend/revamped_assets/img/homepage/homepage-banner.png",
            // require_interaction must be 0 or 1.
            "require_interaction": 1,
            "expiry": 300,
            "actions": [
                {
                    "label": "Button 1",
                    "url": "https://www.pushengage.com",
                    "image_url": "https://assetscdn.pushengage.com/site_assets/frontend/revamped_assets/img/logo.png"
                },
                {
                    "label": "Button 2",
                    "url": "https://www.pushengage.com",
                    "image_url": "https://assetscdn.pushengage.com/site_assets/frontend/revamped_assets/img/logo.png"
                }
            ]
        },
        {
            "schedule_options": {
                "type": "after",
                "value": 2,
                // unit accepts only minutes, days, hours
                "unit": "days",
                // Schedule the notification by giving time in the format (HH:MM:SS)
                "at": "23:20:13"
            },
            "title1": "Notification Title 2",
            "message": "Notification Message 2",
            "url": "https://www.pushengage.com",
            "image_url": "https://assetscdn.pushengage.com/site_assets/frontend/revamped_assets/img/logo.png",
            "big_image_url": "https://assetscdn.pushengage.com/site_assets/frontend/revamped_assets/img/homepage/homepage-banner.png",
            // require_interaction must be 0 or 1.
            "require_interaction": 1,
            "expiry": 360,
            "actions": [
                {
                    "label": "Button 1",
                    "url": "https://www.pushengage.com",
                    "image_url": "https://assetscdn.pushengage.com/site_assets/frontend/revamped_assets/img/logo.png"
                },
                {
                    "label": "Button 2",
                    "url": "https://www.pushengage.com",
                    "image_url": "https://assetscdn.pushengage.com/site_assets/frontend/revamped_assets/img/logo.png"
                }
            ]
        }
    ]
}

Response Objects

Property Name Property Type Description
success Boolean Indicates whether drip request succeeded or not. Value can be 'true' or 'false'.
drip_id Number Indicates unique id of drip.
message String Present in case of failure. Indicates the reason of failure.

Example

Request

curl -X POST \
  https://api.pushengage.com/apiv1/drips \
  -H 'Accept: */*' \
  -H 'Accept-Encoding: gzip, deflate' \
  -H 'Connection: keep-alive' \
  -H 'Content-Type: application/json' \
  -H 'Host: api.pushengage.com' \
  -H 'api_key: <your_pushengage_api_key>' \
  -H 'cache-control: no-cache' \
  -d '{
    "campaign_name": "Drip Campaign Autoresponder",
    "send_to": {
       "include_segments": ["segmentName1", "segmentName2"],
        "exclude_segments": ["segmentExcludeName1", "segmentExcludeName2"]
    },
     "utm_params": {
        "enabled": true,
        "source": "pushengage",
        "medium": "pushengage medium",
        "campaign": "pushengage campaign",
        "term": "pushengage term",
        "content": "pushengage content"
    },
    "notifications": [
        {
            "schedule_options": {
                "type": "rightaway"
            },
            "title": "Notification Title 1",
            "message": "Notification Message 1",
            "url": "https://www.pushengage.com",
            "image_url": "https://assetscdn.pushengage.com/site_assets/frontend/revamped_assets/img/logo.png",
            "big_image_url": "https://assetscdn.pushengage.com/site_assets/frontend/revamped_assets/img/homepage/homepage-banner.png",
            "require_interaction": 1,
            "expiry": 300,
            "actions": [
                {
                    "label": "Button 1",
                    "url": "https://www.pushengage.com",
                    "image_url": "https://assetscdn.pushengage.com/site_assets/frontend/revamped_assets/img/logo.png"
                },
                {
                    "label": "Button 2",
                    "url": "https://www.pushengage.com",
                    "image_url": "https://assetscdn.pushengage.com/site_assets/frontend/revamped_assets/img/logo.png"
                }
            ]
        },
        {
            "schedule_options": {
                "type": "after",
                "value": 2,
                "unit": "days",
                "at": "23:20:13"
            },
            "title": "Notification Title 2",
            "message": "Notification Message 2",
            "url": "https://www.pushengage.com",
            "image_url": "https://assetscdn.pushengage.com/site_assets/frontend/revamped_assets/img/logo.png",
            "big_image_url": "https://assetscdn.pushengage.com/site_assets/frontend/revamped_assets/img/homepage/homepage-banner.png",
            "require_interaction": 1,
            "expiry": 360,
            "actions": [
                {
                    "label": "Button 1",
                    "url": "https://www.pushengage.com",
                    "image_url": "https://assetscdn.pushengage.com/site_assets/frontend/revamped_assets/img/logo.png"
                },
                {
                    "label": "Button 2",
                    "url": "https://www.pushengage.com",
                    "image_url": "https://assetscdn.pushengage.com/site_assets/frontend/revamped_assets/img/logo.png"
                }
            ]
        }
    ]
}'
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.pushengage.com/apiv1/drips",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => "{\n    \"campaign_name\": \"Drip Campaign Autoresponder\",\n    \"send_to\": {\n       \"include_segments\": [\"segmentName1\", \"segmentName2\"],\n        \"exclude_segments\": [\"segmentExcludeName1\", \"segmentExcludeName2\"]\n    },\n     \"utm_params\": {\n        \"enabled\": true,\n        \"source\": \"pushengage\",\n        \"medium\": \"pushengage medium\",\n        \"campaign\": \"pushengage campaign\",\n        \"term\": \"pushengage term\",\n        \"content\": \"pushengage content\"\n    },\n    \"notifications\": [\n        {\n            \"schedule_options\": {\n                \"type\": \"rightaway\"\n            },\n            \"title\": \"Notification Title 1\",\n            \"message\": \"Notification Message 1\",\n            \"url\": \"https://www.pushengage.com\",\n            \"image_url\": \"https://assetscdn.pushengage.com/site_assets/frontend/revamped_assets/img/logo.png\",\n            \"big_image_url\": \"https://assetscdn.pushengage.com/site_assets/frontend/revamped_assets/img/homepage/homepage-banner.png\",\n            \"require_interaction\": 1,\n            \"expiry\": 300,\n            \"actions\": [\n                {\n                    \"label\": \"Button 1\",\n                    \"url\": \"https://www.pushengage.com\",\n                    \"image_url\": \"https://assetscdn.pushengage.com/site_assets/frontend/revamped_assets/img/logo.png\"\n                },\n                {\n                    \"label\": \"Button 2\",\n                    \"url\": \"https://www.pushengage.com\",\n                    \"image_url\": \"https://assetscdn.pushengage.com/site_assets/frontend/revamped_assets/img/logo.png\"\n                }\n            ]\n        },\n        {\n            \"schedule_options\": {\n                \"type\": \"after\",\n                \"value\": 2,\n                \"unit\": \"days\",\n                \"at\": \"23:20:13\"\n            },\n            \"title\": \"Notification Title 2\",\n            \"message\": \"Notification Message 2\",\n            \"url\": \"https://www.pushengage.com\",\n            \"image_url\": \"https://assetscdn.pushengage.com/site_assets/frontend/revamped_assets/img/logo.png\",\n            \"big_image_url\": \"https://assetscdn.pushengage.com/site_assets/frontend/revamped_assets/img/homepage/homepage-banner.png\",\n            \"require_interaction\": 1,\n            \"expiry\": 360,\n            \"actions\": [\n                {\n                    \"label\": \"Button 1\",\n                    \"url\": \"https://www.pushengage.com\",\n                    \"image_url\": \"https://assetscdn.pushengage.com/site_assets/frontend/revamped_assets/img/logo.png\"\n                },\n                {\n                    \"label\": \"Button 2\",\n                    \"url\": \"https://www.pushengage.com\",\n                    \"image_url\": \"https://assetscdn.pushengage.com/site_assets/frontend/revamped_assets/img/logo.png\"\n                }\n            ]\n        }\n    ]\n}",
  CURLOPT_HTTPHEADER => array(
    "Accept: */*",
    "Accept-Encoding: gzip, deflate",
    "Cache-Control: no-cache",
    "Connection: keep-alive",
    "Content-Type: application/json",
    "Host: api.pushengage.com",
    "api_key: <your_pushengage_api_key>",
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
?>

Response

{
  "success": true,
  "drip_id": 12345
}
{
  "success": false,
  "message": "API KEY Invalid"
}
{
  "success": false,
  "error": {
        "name": "InvalidRequestException",
        "message": "Error Message"
    }
}