I'm working in a slack bot(scope chat:write, commands, and users:read), after initiating the bot, a modal opens up, and on submission, the response should be sent to that bot's DM. I'm using chat.postMessage API to achieve this(something like this https://api.slack.com/tutorials/message-action). Below is the sample code, this works in a workspace from where I created the bot but when I tried the same on a different workspace in getting {"ok"=>false, "error"=>"channel_not_found"}
response = JSON.parse(params[:payload])
user_id = response["user"]["id"]
args = {channel: user_id ,text: "A message"}
@options = { body: args}
HTTParty.post("https://slack.com/api/chat.postMessage",
{
:body => args.to_json,
:headers => { 'Content-Type' => 'application/json', 'Authorization' => 'Bearer Bot User OAuth Access Token'}
})
What the best way to achieve this? I can't submit it to the app directory because the bot needs to be added in at least two workspaces.