   data = null
   switch cmd
     when "trigger"
-      data = JSON.stringify { service_key: "#{apikey}", event_type: "trigger", description: "#{args}"}
+      data = JSON.stringify { service_key: pagerDutyApiKey, event_type: "trigger", description: "#{args}"}
       pagerDutyIntergrationPost msg, data, (json) ->
         cb(json)
 

      cb json_body

pagerDutyPost = (msg, url, data, cb) ->
  user    = process.env.HUBOT_PAGERDUTY_USERNAME
  pass    = process.env.HUBOT_PAGERDUTY_PASSWORD
  baseUrl = "https://#{process.env.HUBOT_PAGERDUTY_SUBDOMAIN}.pagerduty.com/api/v1"

  json = JSON.stringify(data)
  auth = 'Basic ' + new Buffer(user + ':' + pass).toString('base64');
  msg.http(baseUrl + url)
    .headers(Authorization: auth, Accept: 'application/json')
    .header("content-type","application/json")
    .header("content-length",json.length)

#   HUBOT_PAGERDUTY_SCHEDULE_ID

pagerDutyUsers = {}
pagerDutyUsername    = process.env.HUBOT_PAGERDUTY_USERNAME
pagerDutyPassword    = process.env.HUBOT_PAGERDUTY_PASSWORD
pagerDutySubdomain   = process.env.HUBOT_PAGERDUTY_SUBDOMAIN
pagerDutyBaseUrl     = "https://#{pagerDutySubdomain}.pagerduty.com/api/v1"
pagerDutyApiKey      = process.env.HUBOT_PAGERDUTY_APIKEY

module.exports = (robot) ->
  robot.respond /pager( me)?$/i, (msg) ->
