HTTP requests

About HTTP triggers

HTTP triggers send data from Hero Outbound to external systems. We commonly refer to these as "trigger based web service calls". This is a smooth, elegant way to send (push) data from Hero Outbound to external systems - the sky is the limit.

It effectively allows anybody to create systems integrations, without writing a single piece of code. It does, however, require you to understand some things about configuration (not development), to set up the HTTP triggers correctly.

HTTP triggers - calls to REST interface (JSON)

As always with triggers, define initially what the trigger should react on: User processed leads, manually created leads, only certain closures etc. This applies to all trigger types.

For trigger based web service calls to a REST API - i.e. the language we are "speaking" is JSON - select "Make an HTTP request", select method POST, and enter the endpoint - this is the interface we are sending data to.

In headers, have AT LEAST one line with the following: Content-Type: application/json

The content template field is the actual web service call. Here, you set up the JSON object with merge fields from Hero.

JSON objects are "surrounded" by { and }.

IMPORTANTLY, when you set this up in the content template field, you need to add a backslash in front of these characters in the top and in the end, so the first line becomes

\{

and the last line becomes

\}

Otherwise, your JSON object will not be interpreted correctly, when processed by Hero as a trigger.

Merge fields, which are replaced with lead data when the web service call is made, have to follow the syntax: {Lead.Data.FIELDNAME} - for example {Lead.Data.phonenumber}. If the field name contains spaces, you just write them: {Lead.Data.my phone number}.

Below is an example. The article continues below the example.

\{
  "Username": "MyUser",
  "Password": "MyPass",
  "SourceID": "179",
  "Origin": "HeroOutbound",
  "Forename": "{Lead.Data.Fornavn}",
  "Lastname": "{Lead.Data.Efternavn}",
  "Address": "{Lead.Data.Adresse}",
  "Zip": "{Lead.Data.Postnr}",
  "City": "{Lead.Data.By}",
  "Telephone1": "{Lead.Data.Telefon}",
  "ExtFields": "
    {Lead.Data:{Key#json}={Value#json};|
    }
"
\}

How to set it up precisely, depends on what the service expects. You may ask your client to send you an example of a real call.

The brilliant thing:

We have made a magic piece of code, looping through ALL fields on the lead, and setting these up in a key-value pair format according to how you define the call. In the above example, this is:

{Lead.Data:{Key#json}={Value#json};|
    }

The {Key#json} is field name (in JSON format) and the {Value#json} is the corresponding value in JSON format.

So the above will, with two fields "name" and "phonenumber" become:

"ExtFields": "
     name=Simone;
     phonenumber=22112211;
"

This specific example is tailored to HeroFlow’s way of understanding extra fields - a more common way to use this code to arrange all lead fields in more standard JSON would be:

{Lead.Data: "{Key#json}": "{Value#json}"|,
    }

Importantly, we identified, that since HeroFlows's API to receive leads splits up ExtFields based on ; fields will not be correctly interpreted by HeroFlow if there is a whitespace in front of field names.

In order to avoid this, the closing bracket has been moved to the same line as the rest of the expression, meaning that it should look like:

(...)

  "PersonID": "",
  "ExtFields": "{Lead.Data:{Key#json}={Value#json};|}
Sælger1={Lead.lastModifiedByUser.orgCode};A-kasse={Lead.Data.Nuværende a-kasse};over25timer={Lead.Data.Er du i arbejde mere end 25 timer i ugen};Aften={Lead.Data.Kontaktes kun efter kl 16};Intern kommentar={Lead.Data.Kommentar - 705};Ase kontakt={Lead.Data.Ase kontakt};Jobstatus={Lead.Data.Jobstatus - 705};Alder={Lead.Data.Alder};Stillingsbetegnelse={Lead.Data.Stillingsbetegnelse}
"
\}

(...)

This sends data in a readable format for ExtFields to HeroFlows. 

---

...which again, if the JSON object should ONLY consist of this, i.e. be surrounded by {}, would completely look like:

\{  
    {Lead.Data: "{Key#json}": "{Value#json}"|,
    }
\}

HTTP triggers - calls to SOAP interface (XML)

As always with triggers, define initially what the trigger should react on: User processed leads, manually created leads, only certain closures etc. This applies to all trigger types.

For trigger based web service calls to a SOAP API - i.e. the language we are "speaking" is XML - select "Make an HTTP request", select method POST, and enter the endpoint - this is the interface we are sending data to.

In headers, have AT LEAST one line with the following: Content-Type: text/xml

You may want to include additional headers, if you are making calls to a specific function, for example, the following: SOAPAction: "http://tempuri.org/ICrmDataConnector/ReceiveData"

If you are including both the above examples, it will simply mean that your "Headers" field will contain:

Content-Type: text/xml
SOAPAction: "http://tempuri.org/ICrmDataConnector/ReceiveData"

The content template field is the actual web service call. Here, you set up the XML request body with merge fields from Hero.

As this is SOAP, you write XML. Merge fields, which are replaced with lead data when the web service call is made, have to follow the syntax: {Lead.Data.FIELDNAME} - for example {Lead.Data.phonenumber}. If the field name contains spaces, you just write them: {Lead.Data.my phone number}.

Below is an example. The article continues below the example.

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/" xmlns:arr="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<soapenv:Header/><soapenv:Body><tem:ReceiveData>
<tem:entityId>{Lead.Data.phone call id}</tem:entityId>
<tem:data>
    {Lead.Data: <arr:KeyValueOfstringstring><arr:Key>{Key#xml}</arr:Key><arr:Value>{Value#xml}</arr:Value></arr:KeyValueOfstringstring>|
    }
</tem:data>
</tem:ReceiveData></soapenv:Body></soapenv:Envelope>

How to set it up precisely, depends on what the service expects. You may ask your client to send you an example of a real call - or ask for a so-called XSD, which stands for "XML Service Description" - this is basically the template for the call, you need to create.

The brilliant thing:

We have made a magic piece of code, looping through ALL fields on the lead, and setting these up in a key-value pair format according to how you define the call. In the above example, this is:

    {Lead.Data: <arr:KeyValueOfstringstring><arr:Key>{Key#xml}</arr:Key><arr:Value>{Value#xml}</arr:Value></arr:KeyValueOfstringstring>|
    }

The {Key#xml} is field name (in XML format) and the {Value#xml} is the corresponding value in XML format.

So the above will, with two fields "name" and "phonenumber" become:

<arr:KeyValueOfstringstring><arr:Key>name</arr:Key><arr:Value>Simone</arr:Value></arr:KeyValueOfstringstring>
<arr:KeyValueOfstringstring><arr:Key>phonenumber</arr:Key><arr:Value>22112211</arr:Value></arr:KeyValueOfstringstring>

Still need help? Contact Us Contact Us