 
   robot.adapter.client.on "raw_message", (msg) ->
     robot.emit "jira_ticket_created_message", msg if msg.type is "message" and msg.user is robot.adapter.self.id and msg.text is TICKET_CREATED_TEXT
-    return unless msg.type is "reaction_added"
     return unless msg.item_user is robot.adapter.self.id
     return unless msg.user isnt robot.adapter.self.id
-
-    switch msg.item.channel[0]
+    if msg.type is "reaction_added"
+      handleReactionAdded msg
+    else if msg.type is "reaction_removed"
+      handleReactionRemoved msg
+
+  getTicketInChannelByTs = (channel, ts) ->
+    switch channel[0]
       when "G"
         endpoint = "groups"
       when "C"

        return

    params =
      channel: msg.item.channel
      latest: msg.item.ts
      oldest: msg.item.ts
      inclusive: 1
      count: 1
      token: process.env.HUBOT_SLACK_TOKEN

    fetch("https://slack.com/api/#{endpoint}.history#{buildQueryString params}")
    .then (json) ->
      message = json.messages?[0]
      throw "Cannot find message at timestamp provided" unless message? and message.type is "message"
      attachment = message.attachments?[0]
      throw "Message does not contain an attachment with a title link" unless attachment?.title_link?
      ticket = attachment.title_link.split "#{jiraUrl}/browse/"
      throw "Cannot find jira ticket" unless ticket and ticket.length is 2
      return ticket[1]
    .catch (error) ->
      robot.logger.info error

  handleReactionRemoved = (msg) ->
    getTicketInChannelByTs(msg.item.channel, msg.item.ts)
    .then (ticket) ->
      switch msg.reaction
        when "watch"
          handleWatchRequest
            message: room: msg.item.channel
            match: [ "", ticket, robot.adapter.client.getUserByID(msg.user).name ]
          , no, yes
        when "raising_hand"
          handleUnassignRequest
            message:
              room: msg.item.channel
              user: id: msg.user
            match: [ "", ticket]
          , no

  handleReactionAdded = (msg) ->
    getTicketInChannelByTs(msg.item.channel, msg.item.ts)
    .then (ticket) ->
      switch msg.reaction
        when "+1", "-1"
          handleRankRequest
