Twilio phone integration for Splunk On-Call

This guide will help you set up your Twilio phone number to allow SMS messages to create incidents in Splunk On-Call.

In Splunk On-Call

Navigate to the Integrations Tab and under 3rd Party Integrations enable the Twilio Integration. Copy the API key to your clipboard for late.

Next, click on the API tab and make sure the API ID and KEY have been enabled.

In Twilio

  1. First, you will need to purchase a Twilio phone number.

    Once a number has been purchased in Twilio, the next step is to set up the SMS function.

  2. Under Functions > Functions (Classic) > List, click Add a New Function.

  3. Name the Function Splunk-On-Call-SMS and name the path SpOC-SMS.
  4. Under Configuration, the Event should be Incoming Messages and the code should be pasted from below:

    Note: next to got.post be sure to replace the {VICTOROPS_TWILIO_SERVICE_API_KEY}/${ROUTING_KEY
    
                 const qs = require(‘qs’); const got = require(‘got’); 
                 const _ = require(‘lodash’);
                 exports.handler = function(context, event, callback) { 
                    const {ROUTING_KEY, VICTOROPS_TWILIO_SERVICE_API_KEY} = context; 
                    console.log(${ROUTING_KEY} ${VICTOROPS_TWILIO_SERVICE_API_KEY});
                    var got = require(‘got’);
                    let twiml = new Twilio.twiml.MessagingResponse(); 
                    twiml.message({ to: event.From }, ‘Incident Created’);
                    {event.From} };
                    console.log(alert);
                    got.post(https://alert.victorops.com/integrations/generic/20131114/alert/:math:{VICTOROPS_TWILIO_SERVICE_API_KEY}/{ROUTING_KEY}, { body: alert, headers: { 'accept': 'application/json', 'Content-Type': 'application/json' }, json: true }).then(function(response) { console.log(response.body); callback(null, twiml);
                    }).catch(function(error) { 
                        console.log(error); callback(error); 
                    }); 
                };
                    
  5. Save the Function.

  6. Next, under Functions > Functions (Classic), configure check the box to Enable ACCOUNT_SID and AUTH_TOKEN.

    Note: If you already have Live Call Routing set up with Environment Variables and Dependencies skip this step and keep your current configuration.
  7. Set up the Environment Variable and Dependencies.

    Environment Variables:

    VICTOROPS_API_ID

    ********

    VICTOROPS_API_KEY

    *********

    VICTOROPS_TWILIO_SERVICE_API_KEY

    ****************

    Dependencies:

    xmldom

    0.1.27

    lodash

    4.17.10

    fs

    0.0.1-security

    twilio

    3.6.3

    got

    9.6.0

    util

    0.11.0

  8. Save the configuration.

  9. Next, set up your phone number to be able to receive SMS messages.

    1. Under Messages, under Configure with, select Webhooks, TwiML,....
    2. Under A message comes in, select Function.
    3. Under Service select default.
    4. Under Function Path, select SpOC-SMS.
  10. Save the properties.

  11. Test by sending an SMS to your Twilio phone number. Make sure whoever might get paged for the test is aware they will receive a test Splunk On-Call incident.