Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can you upload a file to the Slack API using files.upload as a different user?

Tags:

slack-api

I'm trying to find a way to have an application post a text snippet to our support channel through the Slack API. Using the files.upload method, I can create a text snippet and share it with the channel, but the post appears to come from me (because the token used to authenticate the request is mine).

I'm looking for a way to do this, but make it appear with a custom user name and icon, like you can with the chat.postMessage method's username and icon_url parameters. Is there a way to achieve this?

like image 683
neal Avatar asked Jun 03 '16 21:06

neal


1 Answers

There are two ways.

Way 1. - If you only want to upload in a channel and don't need to listen to any conversation, then you can use incoming-webhooks. And then override the username and icon. Read "Customizing your username and icon" in Here.

Way 2 - You can create a bot user and let the bot user type post this message for you. I guess right now you are using test tokens generated by Slack so you are getting your name only. But if you use bot-user then you can use custom Name and icon_url for your bot.

I hope this answers your question.

like image 88
Abhinav Rai Avatar answered Sep 22 '22 16:09

Abhinav Rai