JSON IO is one of the intelligent nodes of Campaigns. You can integrate Agile with other applications on the fly. GET or POST data with valid REST URL endpoints are currently supported.
It consists of three input fields, namely:
-
URL - It should be a valid REST URL from which you can GET or POST data. URL can have query params as part of it. You can send dynamic params (eg: ?email={{email}}) under Params section.
-
Method type - GET or POST.
-
Params
‘Key-Value’ pairs which are appended as Query Params to URL later. More params can be added using ’Add’ button.
At least one Key-Value param should be present. Each param can be edited or deleted. Any Agile Contact Merge Field like {{email}} can be added as Value
The output from the URL (JSON format) are stored as user parameters and are available in the rest of the workflow.
For an example response such as {"firstName": "John", "lastName": "Smith"} You can use {{firstName}} in your workflow as merge fields anywhere.
Here is a quick example (weather) to illustrate JSON IO usage:
The following REST URL fetches weather data of London city http://api.openweathermap.org/data/2.5/weather?q=London&lat=42.98&lon=-81.23
We follow the simple below steps in JSON IO node to get weather data:
-
URL - http://api.openweathermap.org/data/2.5/weather (without query params).
-
Method type - GET
-
Params:
Key Value q London lat 42.98 lon -81.23
Note:
URL with query params is also supported. But at least one param under ‘Params’ is mandatory. For URL which do not take any parameters, you can send a dummy param.
The node has two exit paths - Success & Failure
If URL request was Successful (a valid JSON response for GET or a successful POST) , then it goes through ‘success’ path, and takes the ‘failure’ path otherwise.
The response JSON data can be used in subsequent nodes in the campaign using merge field.
For example, if the response data from the above request is as below, this data can be accessed using merge fields like {{name}}, {{main.humidity}}
{ "dt": 1399279349, "id": 6058560, "name": "London", "cod": 200, "coord": { "lon": -81.23, "lat": 42.98 }, "weather": [ { "id": 802, "main": "Clouds", "description": "scattered clouds", "icon": "03n" } ], "base": "cmc stations", "main": { "temp": 274.05, "humidity": 83, "pressure": 1012, "temp_min": 273.15, "temp_max": 275.15 }, "wind": { "speed": 1.76, "deg": 326.505 }, "clouds": { "all": 36 } }
Using response data in ‘Condition’ node
Using response data in ‘Send Email’ node
Agile supports advanced Mustache templates. You can use Mustache syntax in your email content or other places.
Refer - http://mustache.github.io/mustache.5.html for conditions or loops.
You can test your mustache template code using this tool - http://trymustache.com/