title: How to upload Google Spreadsheet chart to Slack channel
body: <p>I am writing an app script for my Google Spreadsheet and I am wondering how to send charts as an image attachment to Slack?</p>
  
  <p>This is the function for getting the chart:</p>
  
  <pre><code>function getChart(){
    var sheet = SpreadsheetApp.getActiveSheet();
    var chart = sheet.getCharts()[0];
    var pic = chart.getAs('image/png');
    if (chart){
      msg(pic);
      return pic;
    }
  }
  </code></pre>
  
  <p>And this is my "dashbot" function which sends a text message to slack:</p>
  
  <pre><code>function dashbot() {
    var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
    var content = {"channel": "XXX", //edit
                   "username": "XXX",
                   "text": "XXX"};
    var params = {
       "method": "post",
       "payload": JSON.stringify(content)
     };
     UrlFetchApp.fetch('https://hooks.slack.com/XXXXX', params)
  }
  </code></pre>
  
  <p>Any ideas how to get forward on that?</p>