Resources

Sending messages using template and resources

In addition to their use in dynamic/bulk messages, resources can be used when sending dynamic messages with or without a template.

Let's assume that:

  • A template has already been created and it has a template ID (for example, templateID: BCD384BC3847CD3484CD), and
  • A resource has already been created with a resource ID (for example, resourceID: ABD435DBFCD663DEDEFF).
  • JSON
  • XML

{{codeStart}}

TemplateID: BCD384BC3847CD3484CD

{

"messageTemplateName" : "Delivery Plan",

"subject" : "Delivery Plan:",

"body" : "Hi @@name@@ @@surname@@, Your planned mail delivery is at @@MsgData.POBDetail.DateAndTime@@. @@MsgData.POBDetail.Message@@. Any questions, please call 1300 WHISPIR."

}

{{codeEnd}}

 

Now we have the templateId (for content) with the resourceID (for recipients). Using these two key pieces of information, developers can submit an API request to kick off the dynamic messaging process.

  • JSON
  • XML

Sending the bulk message

The resource type here is application/vnd.whispir.bulkmessage-v1+xml, application/vnd.whispir.bulkmessage-v1+json. It's not the usual application/vnd.whispir.message-v1+xml, application/vnd.whispir.message-v1+json.

 

{{codeStart}}

HTTP 1.1 POST https://api.<region>.whispir.com/messages?apikey=[your_api_key]

Authorization: Basic asdf98nf89asdvasd2r398h8sdf

x-api-key: your_api_key

Content-Type: application/vnd.whispir.bulkmessage-v1+json

{

"resource" :{

"resourceId" : "ABD435DBFCD663DEDEFF",

"smsMappingField" : "mobile",

"emailMappingField" : "email",

"voiceMappingField" : ""

},

"messageTemplateId": "BCD384BC3847CD3484CD"

}

{{codeEnd}}

 

The smsMappingField should be mapped to the column or key that holds the number that the SMS message is to be sent to. The emailMappingField should be mapped to the email address that the message is to be sent to. See Dynamic and bulk messages for more details on mapping.

  • JSON
  • XML

Final message delivered to the customer (individually)

The message when combined with the data will be:

Hi Franco Thimboli, Your planned mail delivery is at 09-Sep-2019 12:15 PM. Please let us know if the time slot is acceptable. Respond with a 'No' to get alternative time slot. Any questions, please call 1300 WHISPIR.

Hi Jordan Windsor, Your planned mail delivery is at 09-Sep-2019 12:30 PM. Please let us know if the time slot is acceptable. Respond with a 'No' to get alternative time slot. Any questions, please call 1300 WHISPIR.

 

Response

HTTP 1.1 202 Accepted

Location: http://api.<region>.whispir.com/messages/CDB938478CD6DBC3784C?apikey=[your_api_key]