 #
 #   # Triggering an incident
 #
-#   hubot who's on call - return a list of services and who is on call for them
-#   hubot who's on call for <search> - return the username of who's on call for any schedule matching <search>
-#   hubot pager trigger <user> <msg> - create a new incident with <msg> and assign it to <user>
+#   hubot who's on call                  - return a list of services and who is on call for them
+#   hubot who's on call for <search>     - return the username of who's on call for any schedule matching <search>
+#   hubot pager trigger <user> <msg>     - create a new incident with <msg> and assign it to <user>
+#   hubot pager trigger <schedule> <msg> - create a new incident with <msg> and assign it the user currently on call for <schedule>
 #
 #   ## Setup
 #

    }
    pagerDutyGet msg, "/schedules/#{schedule.id}/entries", query, (json) ->
      if json.entries and json.entries.length > 0
        cb(json.entries[0].user.name, schedule)

  pagerDutyIncident = (msg, incident, cb) ->
    pagerDutyGet msg, "/incidents/#{encodeURIComponent incident}", {}, (json) ->

        msg.send "No open incidents"

  robot.respond /(pager|major)( me)? (?:trigger|page) ([\w\-]+) (.+)$/i, (msg) ->
    fromUserName   = msg.message.user.name
    userOrSchedule = msg.match[3]
    reason         = msg.match[4]
    description    = "#{reason} - @#{fromUserName}"

    # Figure out who we are
    campfireUserToPagerDutyUser msg, msg.message.user, (triggerdByPagerDutyUser) ->
      triggerdByPagerDutyUserId = triggerdByPagerDutyUser.id
      return unless triggerdByPagerDutyUserId

      # Figure out what we're trying to page
      pagerDutyUserFromNameOrSchedule msg, msg.match[3], (userToPage) ->
        if !userToPage
          msg.reply "Couldn't find a user or unique schedule matching #{userToPage} :/"
        else
          pagerDutyIntegrationAPI msg, "trigger", description, (json) ->
            query = {
              incident_key: json.incident_key
            }
            msg.reply ":page: triggered! now assigning it to the right user..."
            setTimeout () ->
              pagerDutyGet msg, "/incidents", query, (json) ->
                if json?.incidents.length == 0
                  console.log inspect query
                  console.log inspect json
                  msg.reply "Couldn't find the incident we just created to reassign. Please try again :/"
                else
                  data = {
                    requester_id: triggerdByPagerDutyUserId,
                    incidents: json.incidents.map (incident) ->
                      {
                        'id':               incident.id,
