Cannot delete message in IM channel as Slack bot - slack

I'm trying to use chat.delete on a "user" channel, the same as you do with chat.postMessage, however I keep getting a channel_not_found error.
slack.api_call(
"chat.delete",
channel=userID, # Exact same value as used with chat.postMessage
ts=ts
)
Is this a limitation in their API? Is there a way to achieve this?

Turns out chat.postMessage will use the SlackBot channel when addressing a single user. The proper way of communicating via IM with a user is to use conversations.open. When I used that everything works as expected.

Related

How to send direct message in Slackbot

I would like to send messages to users through Slackbot, just like integration apps such as Zapier.
If I set the channel ID to the user ID it sends a 1:1 message showing up in the Apps tab, but what I really would like to do is to send a message in Slackbot, as I want to create a seamless experience for a Workflow I'm creating.
Then, if I try adding the Slackbot channel ID it returns channel_not_found and there's no way to add the App there.
My current bot token scope to send messages is: chat:write and I'm sending a message using chat.postMessage
Do I need a different scope? Different API method? I've tried going through some other questions/answers, but they look outdated

forward a message with slack API getting invalid_blocks error

I'm trying to simply get a message from one channel and forward it to another.
all I do is listen to messages on the channel, get the blocks, i.e.:
[{"type":"rich_text","block_id":"AHdW3","elements":[{"type":"rich_text_section","elements":[{"type":"text","text":"z"}]}]}]
and send them to another channel
client.chat.postMessage({
blocks: blocks,
channel: context.targetChannel,
});
I'm getting an invalid_blocks error, even tho this must be valid blocks since they are generated by slack themselves.
any ideas here?
I also tried to remove the block_id but got the same result.
I'm using bolt framework btw, but that shouldn't matter.
Turns out the blocks from 1st client slack apps are rich_text, which isn't supported in the api.
so the way to go is grab the text from the message and post that as is.
See here for context
https://github.com/slackapi/bolt-js/issues/1324

How to send message proactively to Skype user through botframework output channel using Rasa

I am struggling with a problem that I have to integrate sending message to Skype users in daily. I've tried using API (https://rasa.com/docs/rasa/pages/http-api#operation/executeConversationAction) to run action and trigger intent but it didn't work. I think the problem here is botframework is not supported output channel because it worked on Telegram.
This is the result when output channel is botframework but it doesn't appear when I set it by telegram
How can I do this task? Thanks.
I believe that the botframework channel is not supported because it doesn't implement a get_output_channel method, which is used for the intent injection.
However, I'm not sure why that is the case, as I'm not familiar with the channel. It would be dependent on the type of communication connection, i.e. if in botframework Rasa is able to send messages to the channel without having received one first. In the channel code, sending a message looks like a POST request, so I would assume that is the case.
I think you could open an enhancement request in the Rasa repo for this.

How to make Slack app send a private message via an incoming webhook to someone specific?

I created a Slack app that sends a series of interactive messages to a channel. In my Slack API dashboard, I see that I can create and remove hooks. Right now the hook url that I have set up in my code is the one for the Slackbot channel.
But the problem is that such a message only gets sent to me.
I want to send the Slackbot messages to Alice in situation A, and to Bob in situation B. Not just to myself, the guy who configured the app.
What's the best way to do this?
I would suggest that you should not use hooks for this. A more sane way to do this right would be via chat.postMessage Web API method which is documented here!
This is because hooks are tied to specific conversations and that approach quickly hits a wall on what it can really achieve, especially messaging different people. Once you start using the web API it's pretty simple. Just ask for the scope during app installation (remember to add that scope in your dashboard), subscribe to the event in your API dashboard and then you are good to go.
Everytime you send a message via that method, Slack will send you a payload which you can use for testing and logging etc.
You can see all the different ways to message programmatically inside Slack here.

Open direct message channel to a user with a Slack Workspace token?

I'm working on a new Workspace app for Slack. I have a use case where I need to send notifications to users in Slack, through a direct message (or IM). Since the chat.postMessage endpoint requires a channel ID, I can get the existing IM channels using conversations.list and send them the notification.
However, if the user hasn't yet opened an IM channel from their side, I need to create one. It seems that neither Web API endpoints (conversations.open or im.open) support Workspace tokens. I keep getting not_allowed_token_type error response. I can create a public channel with conversations.create, but that's not what I need.
Is there another to open an IM channel to a user when using a Workspace token?
Took me awhile to figure this out. You need to add/request the conversations.app_home:create scope to your permissions. Then you can just specify the user ID as the channel arg in a chat.postMessage call.

Resources