     "#{prefix}/#{crypto.randomBytes(20).toString('hex')}.png"
 
   # Fetch an image from provided URL, upload it to S3, returning the resulting URL
-  fetchAndUpload = (msg, title, url, link) ->
+  uploadChart = (msg, title, url, link, site) ->
     if grafana_api_key
         requestHeaders =
           encoding: null,

#   HUBOT_GRAFANA_S3_SECRET_ACCESS_KEY - Optional; Secret access key for S3
#   HUBOT_GRAFANA_S3_PREFIX - Optional; Bucket prefix (useful for shared buckets)
#   HUBOT_GRAFANA_S3_REGION - Optional; Bucket region (defaults to us-standard)
#
# Dependencies:
#   "knox": "^0.9.2"

          imageUrl = "#{grafana_host}/render/#{apiEndpoint}/db/#{slug}/?panelId=#{panel.id}&width=1000&height=500&from=#{timespan.from}&to=#{timespan.to}#{variables}"
          link = "#{grafana_host}/dashboard/db/#{slug}/?panelId=#{panel.id}&fullscreen&from=#{timespan.from}&to=#{timespan.to}#{variables}"

          sendDashboardChart msg, title, imageUrl, link

  # Process the bot response
  sendDashboardChart = (msg, title, imageUrl, link) ->
    if (isUploadSupported)
      uploadChart msg, title, imageUrl, link, site
    else
      sendRobotResponse msg, title, imageUrl, link

  # Get a list of available dashboards
  robot.respond /(?:grafana|graph|graf) list\s?(.+)?/i, (msg) ->
