Webhook category autoresponder - Heyloyalty/api GitHub Wiki

This method requires that you are authenticated against Heyloyalty. Check here first if you have yet to authenticate yourself (https://github.com/Heyloyalty/api/wiki/Getting-started)

This feature is created to make Heyloyalty send transactional emails. You set up most of the design in our editor along with any dynamic content or merge fields that you want in the email. When the specific URL is called Heyloyalty uses the data to render an HTML email to the specified recipient.

Getting started:

Setting up the list:

Before you can get started sending different type of transactional emails with Heyloyalty you have to specify Heyloyalty as your lists business intelligence: This can either be done through the frontend or through an api call.

Via GUI:

Go to "listeintegrationer" and choose "Opsæt Webhook" in the "skræddersyede triggers" feature tab. On the next page, 2 fields are required: Please define:

  • Liste: The list you want to use
  • Billed Format: The view of product feed images (if not important leave as default)

BI settings

Setting up the autoresponders:

With the list set up and ready we need to create one or more autoresponders to be used for sending the emails. These can currently only be set up using the frontend.

When logged in Chose "automatisering" and inside that chose "opret ny autoresponder" Select options as displayed below instead of testValue enter whatever category you want this autoresponder to trigger on (you can have multiple autoresponders with different categories on the same list).

Category path settings

On design you can setup the design in any way you might want do note that custom data fields can be parsed into the data using mergetags of the form {ExternalFields.myfield}. We will show an example about how to use these fields in a second.

When done setting up the design save and quit.

With the autoresponder setup and ready as well as the api key setup we are ready to start sending mails using Heyloyalty.

Sending emails through HL webhook-category.

The base endpoint for the category-path trigger is: POST https://api.heyloyalty.com/loyalty/v1/webhooktrigger The data must be formatted as form-data.

Responses:

When calling the endpoint the system returns a HTTP 204 if everything went as it should. If you recieve this code the email should be out shortly. Errors are returned with an HTTP 400. the error results contains a message inside "Error" key that explains what's missing.

Required:

key named "Data" where the value is a JSON body.

Optional parameters:

Files[] This key can be used to add one or more PDF documents to your email.

Structure of the Data json body

the JSON body of Data has some required data as well. A minimum example that can trigger an e-mail is setup here below:

{
    "TriggerDisplayName": "webhook-category",
    "EventDateTime": "2016-12-20T13:00:00Z",
    "Context": {
        "UserId": "[email protected]",
          "Category": "testValue",
        "ListId": -1
    },
    "Content": [{}]
}

An example using CURL:

**Note: Example are missing authentication header **

curl -X POST -H "Content-Type: multipart/form-data;" -H "Cache-Control: no-cache" -F 'Data={ "TriggerDisplayName": "webhook-category", "EventDateTime": "2016-12-20T13:00:00Z", "Context": { "UserId": "[email protected]", "Category": "testValue", "ListId": 14 }, "Content": [{}] }' "https://api.heyloyalty.com/loyalty/v1/webhooktrigger"

This example will send an e-mail to [email protected] if theres an autoresponder with the Category "testValue" on the list with id -1. This e-mail will be entirely the already inserted data in the design step, without any dynamic content from the call. If you want to add some products that should be included in the mail it can be specified as below:

{
    "TriggerDisplayName": "webhook-category",
    "EventDateTime": "2016-12-20T13:00:00Z",
    "Context": {
        "UserId": "[email protected]",
        "Category": "testValue",
        "ListId": -1
    },
    "Content": [{
        "ProductNumber": 1,
        "ProductName": "hello world",
        "ImageUrl": "http://branding.arnsbomedia.com/heyloyalty/logo/without-tagline/as_white.png",
        "ProductUrl": "www.heyloyalty.com"
    }, {
        "ProductNumber": 2,
        "ProductName": "hello world again",
        "ImageUrl": "http://branding.arnsbomedia.com/heyloyalty/logo/without-tagline/as_white.png",
        "ProductUrl": "www.heyloyalty.com"
    }]
}

Note: To display content you need to add dynamic content inside the autoresponder design by using the following modal:

Modal

CURL example:

**Note: Example are missing authentication header **

curl -X POST -H "Content-Type: multipart/form-data;" -H "Cache-Control: no-cache" -F 'Data={ "TriggerDisplayName": "webhook-category", "EventDateTime": "2016-12-20T13:00:00Z", "Context": { "UserId": "[email protected]", "Category": "testValue", "ListId": 14 }, "Content": [{ "ProductNumber": 1, "ProductName": "hello world", "ImageUrl": "http://branding.arnsbomedia.com/heyloyalty/logo/without-tagline/as_white.png", "ProductUrl": "www.heyloyalty.com" }, { "ProductNumber": 2, "ProductName": "hello world again", "ImageUrl": "http://branding.arnsbomedia.com/heyloyalty/logo/without-tagline/as_white.png", "ProductUrl": "www.heyloyalty.com" }], "ExternalFields": { "name": "test", "area": "Denmark" } }' "https://api.heyloyalty.com/loyalty/v1/webhooktrigger"

Note: Default parameters in content is: ProductUrl, ProductName, ProductDescription, ImageUrl, OriginalPrice, OnSalePrice, ProductNumber if you want to use more or other parameters create a custom template there you can use whatever parameters you want (remember to surround them with {})

If you have some custom data that should be used inside other text in the email (for example if you want to send a name along so the first line of text could be "Hello myName your order has been recieved!" you can use ExternalFields:

{
    "TriggerDisplayName": "webhook-category",
    "EventDateTime": "2016-12-20T13:00:00Z",
    "Context": {
        "UserId": "[email protected]",
        "Category": "testValue",
        "ListId": -1
    },
    "Content": [{}],
    "ExternalFields": {
        "name": "test",
        "area": "Denmark"
    }
}

CURL example:

**Note: Example are missing authentication header **

curl -X POST -H "Content-Type: multipart/form-data;" -H "Cache-Control: no-cache" -F 'Data={ "TriggerDisplayName": "webhook-category", "EventDateTime": "2016-12-20T13:00:00Z", "Context": { "UserId": "[email protected]", "Category": "testValue", "ListId": 14 }, "Content": [{}], "ExternalFields": { "name": "test", "area": "Denmark" } }' "https://api.heyloyalty.com/loyalty/v1/webhooktrigger"

This example allows you to replace all occurrences of {ExternalFields.name} in the email body with test and {ExternalFields.area} with Denmark.

Note: Any mergetags not specified in ExternalFields but that exists in the email will not by default be deleted so if you want to send an email to a customer without a name use: "name": "" instead of leaving the field out.

Example of Data for sms

{
	"TriggerDisplayName": "webhook-category",
	"EventDateTime": "2022-01-26T02:20:42+0100",
	"Format": "sms",
	"Context": {
		"UserId": "12345678",
		"Category": "sms-test",
		"ListId": -1
	},
	"Content": [{}],
	"ExternalFields": {
		"name": "Heyloyalty",
		"area": "Aarhus",
		"body":"Sms content"
	}
}