Slack: Upload File (Bots)
This item uploads files to Slack with Bots.
Configs: Common
  • Step Name
  • Note
  • C1-deprecated: OAuth2 Setting (To change scopes)
  • C1: OAuth2 Setting *
  • C2: Slack Channel Name *
  • C3: Data item whose attached files will be uploaded (File) *


  • If C1-deprecated is set, you must set C1: OAuth2 Setting
  • If you specify more than one channel to upload to, the channel names must be separated by commas


See also

Script (click to open)
  • An XML file that contains the code below is available to download
    • slack-file-upload-bots.xml (C) Questetra, Inc. (MIT License)
    • If you are using Professional, you can modify the contents of this file and use it as your own add-on

function main() {
  const oauth2 = configs.get("conf_OAuth2");
  const channel = configs.get("ChannelName");
  const filesDef = configs.getObject("File");
//check whether files exist or not

  const files = engine.findData( filesDef );
  if (files === null){
    engine.log ("No File to upload");
  //check whether number of files is under the limit
  const numOfFiles = files.length;
  if (numOfFiles > httpClient.getRequestingLimit()){
    throw "Number of Files is over the limit.";
  for (let i = 0; i < numOfFiles; i++){
  * Upload File
  * @param {String} oauth2
  * @param {String} token 
  * @param {QfileView} file
  * @param {String} channel
function upload (oauth2,file,channel){ 

  const url = '';
  const response = httpClient.begin()
  const status = response.getStatusCode();
  const responseTxt = response.getResponseAsString();

  let responseJson;
  try {
    responseJson = JSON.parse(responseTxt);
  } catch(e) {
    engine.log("failed to parse as json");
    engine.log(`status: ${status}`);
    throw `Failed to upload. status: ${status}`;
  if (responseJson.ok !== true) {
    const filename = file.getName();
    const error = `Failed to upload\n filename: ${filename} error: ${responseJson.error}`;
    engine.log(`status: ${status}`);
    throw error;

%d bloggers like this: