       callback JSON.parse(body)
 
 deploy = (options) ->
-  { appName, appData, blobRef, msg } = options
+  { appName, appData, blobRef, env, msg } = options
 
-  requestUrl = "https://kolkrabbi.herokuapp.com/apps/#{appData.staging.id}/github/push"
+  requestUrl = "https://kolkrabbi.herokuapp.com/apps/#{appData[env].id}/github/push"
 
   body = JSON.stringify
     branch: blobRef
 
   sendRequest msg, requestUrl, body, (responseBody) ->
-    msg.send "**Staging** deployment of **#{appName}** started - [Click here to watch](https://dashboard.heroku.com/apps/#{appData.staging.name}/activity/builds/#{responseBody.id})"
+    msg.send "**#{env}** deployment of **#{appName}** started - [Click here to watch](https://dashboard.heroku.com/apps/#{appData.staging.name}/activity/builds/#{responseBody.id})"
 
 promote = (options) ->
   { appName, appData, msg } = options

    repo: "cadecairos/mattermost-heroku"
    staging:
      name: "chat-mozillafdn-org-staging"
    production:
      name: "chat-mozillafdn-org-production"
  donate:
    role: "deploy_donate"
    defaultBlobRef: "master"
    repo: "mozilla/donate.mozilla.org"
    staging:
      name: "donate-mozilla-org-us-staging"
    production:
      name: "donate-mozilla-org-us-prod"
  publish:
    role: "deploy_publish"
    defaultBlobRef: "master"

AUTH_HEADER = "Bearer #{process.env.HEROKU_API_TOKEN}"

module.exports = (robot) ->
  robot.respond /deploy ([a-zA-Z\d\-]+)(?:@([a-zA-Z\d\-]+))? to (staging|production)?$/i, { id: "heroku.deploy" }, (msg) ->
    [ appName, blobRef, env ] = msg.match[1..]

    appData = VALID_APPS[appName]

