Macros¶
DIY Surveys supports the ability to insert values into a message using macros. Macros can be used during the recipient upload process and the messaging process.
Warning
Macro parameters are not currently represented in the API 3.2 OpenAPI MessageModel. The API-call example on this page describes the API 3.0 contract. Validate a 3.2 payload against the Scalar reference.
Formatting macros¶
Macros use the following basic format:
'{' name [ '(' parameters ')' ] '}'
| Part | Description |
|---|---|
name |
The macro name. |
parameters |
Optional parameters depending on the macro type. |
Example:
{tiny(https://diysurveys.com)}
This converts the long URL into a short version using either the default TinyUrl configured for your account or a specific one associated with your account.
Parameters¶
Parameters are separated by commas. If a parameter includes a parameter, surround it with double quotes.
{tiny(https://diysurveys.com, 1pt.mobi)}
This converts the long URL into a tiny URL using the supplied domain as the TinyUrl.
Parameters can also refer to values supplied with a method call:
{tiny({long}?id={RequestID}, {short})}
In this example, the {long} and {short} references must be included in the message send method.
Note
If there is a conflict between the macro list supplied in the API call and the standard macros, the API call macro list takes precedence.
Example message¶
URL: https://api.diysurveys.com/api/v3.0/Message/Send
Method: POST
{
"Source": "DIY Surveys",
"Destination": "12345678901",
"Message": "Please click on the link {tinyurl({long}, {short})} to get your reward",
"Reply": false,
"When": "2020-02-04T11:47:33.645773+00:00",
"Window": [{ "From": "09:00", "To": "16:00", "Days": "1,2,3,4,5" }],
"Callback": "https://yourco.com/api/messagetracker",
"Lookup": true,
"Test": false,
"MetaData": [
{ "long": "https://diysurveys.com" },
{ "short": "1pt.mobi" },
{ "RequestID": "1234567890DEFED" },
{ "OrgID": 1010 },
{ "Instance": "ETRERT" },
{ "Campaign": 1242 },
{ "TimeStamp": "2020-02-04T11:47:33.645773+00:00" }
]
}