Events

Sending messages using event data

Once you’ve finished creating your event data in the Whispir platform, the next logical step is to deliver a notification about the event. This action can be performed using the existing /messages endpoint, with the Event ID as an attribute of the message.

Including this Event ID links the message to the event, and allow you to use any attribute of the event within your message payload.

  • Any event fields populated on the event are automatically populated within the message.
  • Any attributes that are supplied within the message take priority over any attributes that are from the event.
  • The user should not be required to enter any ‘attributes’ as these will be retrieved from the linked event.
  • The event fields automatically populate the attributes in the message body (based on the relationships set in the Admin > Settings > Attributes > Message Event Attribute Map).
  • The event label is added to the label field in the message within the Whispir application.
  • If the event doesn't contain an event field, and there is no relevant attribute field supplied in the message payload, the @@ tag will not be resolved.
  • If you don't supply an attribute in the message payload, and this has also not been supplied from the event, the field simply will not be resolved within the message.
  • JSON
  • XML

Sending messages using event data

The messages are sent using the /message end point. The added data here is the eventId. It's the id of the event whose data has to be used.

 

{{codeStart}}

HTTP1.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.message-v1+json

{

"to" : "+1000000000",

"subject" : "Event Notification",

"eventId" : "2EE7FEA3343662BE",

"body" : "An event has occurred: @@summary@@. A resolution is required by @@actionDate1@@."

}

{{codeEnd}}

  

This would resolve as:

Event Notification. 
An event has occurred: Outage of systems in Sydney.  A resolution is required by 11/09/2019 17:41:00.

 

The response to the request would be as follows:

HTTP 1.1 202 Accepted 
Location: http://api.<region>.whispir.com/messages/47707420BAE1288B?apikey=<your_api_key>  

 

Once can also use the templates to make the message more structured. 

{{codeStart}}

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

{

"to" : "+1000000000",

"subject" : "Event Notification",

"eventId" : "2EE7FEA3343662BE",

"messageTemplateId" : "BCFD647BCD83FED893"

}

{{codeEnd}}