Reputation: 135
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)
Upvotes: 5
Views: 6489
Reputation: 11
Per https://api.slack.com/methods/files.upload#markdown, the files.upload
method is deprecated and will stop functioning on March 11, 2025. You'll need to use the newer methods:
It would seem that the arguments for file.completeUploadExternal (https://api.slack.com/methods/files.completeUploadExternal#args) do not support sharing in a DM, only in a channel or as a reply to an existing message via it's timestamp.
Once a file is uploaded, it would seem in the response data you get a permalink
to the file that you can subsequently DM to whomever you need with a Slack bot
Upvotes: 0
Reputation: 32698
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
Upvotes: 4