Skip to main content
Webhook Connection code examples
Updated over a year ago

The Webhook connection allows you to pass BlueConic data to webhooks of external marketing automation platforms and import data returned. The Webhook connection also allows you to define incoming webhooks to BlueConic so external marketing automation platforms can pass data into BlueConic. This page shows examples of outgoing and incoming webhook code requests.

Configuration examples

Here are a few configuration examples to get you started. Click a service to see its settings.

Examples of outgoing webhook requests

The webhook connection can trigger a request and send BlueConic data to external applications.
Here is a list of all possible data that can be sent including examples.

Profile properties

{
"id" : ##{{id}},
"Name" : ##{{name}},
"Last_name" : ##{{surname}},
"Email" : ##{{email}},
"Phone_number" : ##{{phone.0}} //The first value for the property (nth value),
"Phone_number_2" : ##{{phone.1}} //The second value for the property (nth value)
}

Lifecycle information

{
//Array of lifecycle objects the profile is in
"All_lifecycles" : ##{{lifecycles}},
//Array of all lifecycle names the profile is in
"All_lifecycle_names" : ##{{lifecycle_names}},
//Array of all lifecycle ids the profile is in
"All_lifecycle_ids" : ##{{lifecycle_ids}},
//Array of all stage names the profile is in
"All_lifecycle_stage_names" : ##{{stage_names}},
//Array of all stage id's the profile is in
"All_lifecycle_stage_ids" : ##{{stage_ids}},
//Array of all names of the lifecycles and stages the profile is in
"All_lifecycle_names_stages" : ##{{lifecycle_stage_names}}
}

Segment information

{
//Array of all segments the profile is in
"All_segment_names" : ##{{segments}},
//Array of all segment ids the profile is in
"All_segment_ids" : ##{{segments_ids}}
}

Timeline events

Both front-end and timeline events can be sent to the external application. A prefix is used when including. events in the request body to reduce potential conflicts between event names andies.

Example event:

{
"id" : 124,
"order_value" : 1234,
"order_date" : "1-1-2000"
"products" : [{
"id" : 374856,
"name" : "socks"
},
{
"id" : 1241245,
"name" : "shoes"
}],
"stores" : [{
"id" : 1982749124,
"address" : "someaddress"
},
{
"id" : 0917241lks,
"address" : "streety1"
}]
}

Example request body:

{
//Complete event object including sub-events
"Order_event" : ##{{event}},
//Order id property
"Order_id" : ##{{event.id}},
//Array of product objects within the order
"Products" : ##{{event.products}},
//The first product within the order event (nth value)
"First_product" : ##{{event.products.0}},
//The name of the first product within the order event (nth value)
"First_product_name" : ##{{event.products.0.name}},
//The address of the second store within the order event (nth value)
"Second_store_address" : ##{{eventevent.stores.1.address}}
}

Helper blocks

Sometimes the external application likes to receive data in a different format, like stringified JSON, hashed data, or something else. To accommodate for this, data can be encapsulated with helper blocks to transform the data to the desired format.

{
//Normal profile id
"id" : ##{{id}},
//Array of segment names as stringified JSON
"Segments_as_JSON" : ##{{#JSON}}##{{segments}}##{{/JSON}},
//Date of birth property as datetime string
"DoB_as_datetime" : ##{{#DATETIME}}##{{date_of_birth}}##{{/DATETIME}},
//Email property base64 encoded
"Email_as_Base64" : ##{{#BASE64}}##{{email}}##{{/BASE64}},
//Email property URI encoded
"Email_as_URI" : ##{{#URIENCODE}}##{{email}}##{{/URIENCODE}},
//Email property Sha256 hashed
"Email_sha" : ##{{#SHA256}}##{{email}}##{{/SHA256}},
//Email property MD5 hashed
"Email_md5" : ##{{#MD5}}##{{email}}##{{/MD5}},
}

The helper blocks also work with the newly supported timeline events.

{
//Normal profile id
"id" : ##{{id}},
//Complete order event as stringified JSON
"Order_as_JSON" : ##{{#JSON}}##{{e.Order}}##{{/JSON}},
//Order date as datetime string
"Order_date" : ##{{#DATETIME}}##{{e.Order.order_date}}##{{/DATETIME}}
}

Example mustache functions

The following table lists various mustache template tokens that can be used within the Webhook Connection request body template to specify profile attributes to include in the request as well as to perform various actions on the data before the request is sent to the external system.

Variable

Description

Usage

Output Example

id

Profile ID

##{{id}}

f1174ca5-84e8-46b9-afba-66b568dba698

<profile property id>

The value(s) of a profile property

##{{email}}

<profile property id>.<index>

The nth value of a profile property

##{{email.0}}

For a property with multiple email addresses, it returns the first value:

event id

The Timeline Event ID for webhooks triggered by events

##{{event.id}}

12345

event date

The Timeline Event date for webhooks triggered by events

##{{event.eventDate}}

Wed Dec 06 2023 19:56:11 GMT+0000 (Coordinated Universal Time)

event property

The Timeline Event property for webhooks triggered by events

##{{event.myProperty}}

value from event property

segments

Segment names that the profile is part of

##{{segments}}

[
"All Visitors",
"Known Visitors",
"Engagement: High",
"Visitors with a high momentum",
"Visitors with a high intensity",
...
]

segments_id

Segment IDs that the profile is part of

##{{segment_ids}}

[
"05e7d74f-bb91-458e-8fec-b8098383dbe2",
"449b940e-a579-44f1-9820-5939b333f3bb",
"67321855-06aa-41a9-a32e-cc28d3a13f3d",
"3596f3e9-dbfe-4407-8f72-1622b1c7c2d8",
"3ae93c9f-d4c0-4711-98d7-e582297207b0",
...
]

lifecycles

Returns an array of lifecycle objects the profile is in

##{{lifecycles}}

[
{
lifecycleId: "85cb01ff-6f48-4a09-9bd1-429ef54de85b",
lifecycleName: "Lifecycle name 1",
stageId: "90a01c3b-07e5-4426-b90b-27bde5de8889",
stageName: "Stage 1"
},
{
lifecycleId: "84704b40-b8ff-463f-85a5-5e7b2e658420",
lifecycleName: "Lifecycle name 2",
stageId: "2cd3f857-b6fe-4880-ad97-f0591476f503",
stageName: "Stage 2"
}
]

lifecycle_names

Returns an array of all the names of the lifecycles the profile is in

##{{lifecycle_names}}

[
"Lifecycle name 1",
"Lifecycle name 2"
]

lifecycle_ids

Returns an array of all the IDs of the lifecycles the profile is in

##{{lifecycle_ids}}

[
"85cb01ff-6f48-4a09-9bd1-429ef54de85b",
"84704b40-b8ff-463f-85a5-5e7b2e658420"
]

stage_names

Returns an array of all the names of stages the profile is in

##{{stage_names}}

[
"Stage 1",
"Stage 2"
]

stage_ids

Returns an array of all the IDs of stages the profile is in

##{{stage_ids}}

[
"90a01c3b-07e5-4426-b90b-27bde5de8889",
"2cd3f857-b6fe-4880-ad97-f0591476f503"
]

lifecycle_stage_names

Returns an array of all the names of lifecycles and stages the profile is in

##{{lifecycle_stage_names}}

[
"Lifecycle name 1: Stage 1",
"Lifecycle name 2: Stage 2"
]

JSON

Function to convert values to JSON string

##{{#JSON}}##{{segments}}##{{/JSON}}

"[\"All V isitors\", \"Known Visitors\", \"Engagement: High\", \"Visitors with a high momentum\", \"Visitors with a high intensity\"]"

DATETIME

Function to convert timestamp to ISO DateTime string

##{{#DATETIME}}##{{visitdate}}##{{/DATETIME}}

2022-07-21T22:04:13.217Z

BASE64

Function to convert a value to a base64 encoded string

##{{#BASE64}}##{{email.0}}##{{/BASE64}}

ZXJpYy5naWxyZWF0aEBibHVlY29uaWMuY29t

URIENCODE

Function to convert a value to a URI encoded string

##{{#URIENCODE}}##{{email.0}}##{{/URIENCODE}}

john.smith%40blueconic.com

SHA256

Function to convert a value to a SHA256 hashed string

##{{#SHA256}}##{{email.0}}##{{/SHA256}}

23d27c6435e080171cbcc19f830a1e5f35fd78258d64c0005e9034e33b07add7

MD5

Function to convert a value to a MD5 hashed string

##{{#MD5}}##{{email.0}}##{{/MD5}}

acef13b224fb37365160a9dcd0a098f6

JOIN

#separator

Function to concatenate array data without trailing separator, will use the array between the first brackets

##{{#JOIN}}##{{#lifecycles}}##{{lifecycleName}}##{{#separator}} / ##{{/separator}}##{{/lifecycles}}##{{/JOIN}}

Lifecycle name 1 / Lifecycle name 2

conditional

Print a value

##{{#email}}##{{email}}##{{/email}}

When the profile has a value for email

conditional inverse

Print a value when there is no value for another property

##{{^global_id}}##{{id}}##{{/global_id}}

f1174ca5-84e8-46b9-afba-66b568dba698

When the profile does not contain a value for global_id

Did this answer your question?