Sendalert code snippets

To aid your development, we have created a number of code snippets that you can cut and paste and modify to suite your application requirements.

Alert type – email

{
    "version": "latest",
    "apiKey": "abcdefghijklmnopqrstuvwxyz",
    "clientRef": "abcd-efgh",
    "options": {
        "notification": "poll",
        "notificationType": "json"
    },
    "alert": [
        {
            "alertType": "email",
            "tag": "t1",
            "to": "All staff",
            "sender": "ACME Trading",
            "replyTo": "ACME Trading",
            "subject": "This is an email subject",
            "recipientList": "somebody@somewhere.com, someoneelse@somewhere.com",
            "content": "This is an email body\n",
            "contentEncoding": "utf8",
            "emailBodyIsMultipart": false
        }
    ]
}

Alert type – voice

{
    "version": "latest",
    "apiKey": "abcdefghijklmnopqrstuvwxyz",
    "clientRef": "abcd-efgh",
    "alert": [
        {
            "alertType": "call",
            "sender": "+447777100100",
            "recipients": [
                "+447777100100",
                "+447777100101", 
                "+447777100102"
            ],
            "tag": "t1",
            "voiceFormat": "mp3",
            "contentEncoding": "base64",
            "content": "UklGRgi3AA................=="
        }
    ]
}

Schedule SMS

{
    "version": "latest",
    "apiKey": "abcdefghijklmnopqrstuvwxyz",
    "clientRef": "abcd-efgh",
    "options": {
        "notification": "poll",
        "notificationType": "json",
        "schedule": {
            "start": "now",
            "startOffset": 5,
            "startInterval": "minute",
            "end": "2021-02-01T01:02:03.0Z"
        }
    },
    "alert": [
        {
            "alertType": "sms",
            "tag": "t1",
            "content": "This is an SMS",
            "contentEncoding": "utf8",
            "sender": "+447777100100",
            "recipientList": "+447777100100,+447777100101,+447777100102"
        }
    ]
}

Voice alert using stored content

{
    "version": "latest",
    "apiKey": "abcdefghijklmnopqrstuvwxyz",
    "clientRef": "abcd-efgh",
    "options": {
        "notification": "poll",
        "notificationType": "json"
    },
    "alert": [
        {
            "alertType": "call",
            "tag": "t1",
            "storedContent": "e42b1fd0-70fc-4697-b646-9f0fab7306d0",
            "sender": "+447777100100",
            "recipientList": "+447777100100"
        }
    ]
}

Voice alert using TTS with retries

{
    "version": "latest",
    "apiKey": "abcdefghijklmnopqrstuvwxyz",
    "clientRef": "abcd-efgh",
    "alert": [
        {
            "alertType": "call",
            "sender": "+447777100100",
            "recipientList": "+447777100100",
            "tag": "t1",
            "voiceFormat": "tts",
            "content": "Hello, this is a test announcement. Please press any key and then hangup. Thank you.",
            "contentEncoding": "utf8",
            "ivrControl": 
                "ivrRequireResponse": true,
                "ivrAttempts" : 3
            }
        }
    ]
}

Combined SMS & voice alert

{
    "version": "latest",
    "apiKey": "abcdefghijklmnopqrstuvwxyz",
    "clientRef": "abcd-efgh",
    "alert": [
        {
            "alertType": "sms",
            "tag": "t1",
            "content": "This is an SMS 1",
            "contentEncoding": "utf8",
            "sender": "+447777100100",
            "recipientList": "+447777100100"
        },
        {
            "alertType": "call",
            "sender": "+447777100100",
            "recipients": [
                "+447777100100",
                "+447777100100",
                "+447777100100"
            ],
            "tag": "t1",
            "voiceFormat": "mp3",
            "contentEncoding": "base64",
            "content": "UklGRgi3.................w=="
        }
    ]
}

Snow alert

{
  "version" : "latest",
  "apiKey" : "abcdefghijklmnopqrstuvwxyz", 
  "clientRef" : "LondonSnow",
  "options": {
    "notification" : "poll",
    "notificationType" : "json"
  }
  "alert" : [ 
    {
        "alertType" : "sms",
        "tag" : "LondonSnowSMSTag",
        "recipientList" : "+447777100100,+447777100101,+447777100102",
        "content" : "Due to snow the school will be closed today",
        "contentEncoding" : "utf8"
        "sender" : "SNOW ALERT"
    }
  ]
}