Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Upload file using slackbot as Direct message

I am created slack bot, is there is any possible way send reply message as file? (I need to sent some file as reply message based on input). I tried using api file.upload it make the file as private not able access using url, but if i am upload to channel using sampe api, file is public, is there any way to send direct message as file by bot)

like image 570
laxman954 Avatar asked Oct 18 '22 17:10

laxman954


1 Answers

Yes. You can share a file directly and privately with a user by sharing it in a direct message channel with the user.

Just put the {user-id} of the user you want to share the file with in the channels parameter of the files.upload API method and you are all set.

Your slack app will need the files:write:user scope. This also works with bots.

Example for user with ID U12345678:

curl -F content="Hello" -F channels=U12345678 -F token=xoxp-your-token-here  https://slack.com/api/files.upload
like image 96
Erik Kalkoken Avatar answered Oct 21 '22 03:10

Erik Kalkoken