Send message to another slack bot [duplicate] - ruby

I'm writing a simple slack bot which should execute other slack commands upon being called. Everything is up and running, however the slack commands this bot issues don't seem to be executed.
For instance my bot posts /giphy kitten every hour and the message appears just like that in the channel (so the sending side seems to work), but the slash command itself isn't executed. If I post the same command into the same channel myself it works as expected. Are bots not allowed to execute slash commands?

Bots can use the undocumented API method chat.command to invoke slash commands.
See here for an unofficial documentation page of this API method.
This question was also answered here.

The command chat.command needs the permission scope post, which only legacy tokens have and which is not available for Slack apps.
I just asked the Slack customer support if sending slash commands programmatically is still possible and received the following reply:
I'm afraid not. Slash commands can only be triggered by human-sent
messages from the client. Apologies.

Related

How to use slash commands in Discum

I want to use it to trigger slash commands from other bots. As an example, I want to let the self bot write /ping and the Dankmemer should recognize that and respond. I have already tried to do this.
My first problem is the script runs error free, but nothing happens (the selfbot doesn't write the message or command to the channel).
The second problem is when I try to do the same with the disboard bot or other bots, the reading of the commands from the bot no longer works. In other words if I let the script read all commands from the Dankmemer bot, I get the whole list of slash commands.
But when I read the disboard bot I get
{'message': 'You are not authorized to perform this action on this application', 'code': 20012}
as an output. When I try the whole thing on the Mee6 bot I only get [ ] this empty bracket out.
How can I do this?
https://gist.github.com/BinBeiNetto/63806b1a516507f01fc551f8b6e65945
Bots cannot interact with bots. If you used a normal user as a bot that’s against the TOS.

Slack slash command: Respond as user, not app

When sending the response to a Slack slash command, I would like to send it under the user that has launched the slach command.
I have created a Slack app with a slash command. It calls my Flask webservice and I use the "response_url" webhook to write something back to the channel. The response in the channel is given by my app. This works as expected. But I would like for the response to be displayed as if a user has given it.
An example would be the Slack plugin from giphy. If I call it, I get an ephemeral message to choose the gif I would like. But then it is posted in the channel under my name.
So I have 2 questions:
How does the API call look like to respond to the slash command as a specific user?
What permissions for my app are required to allow for such behaviour of the app?
The Slack API documentation is comprehensive, but much research didn't yield the result I wanted.
Thanks!
When you are using response_url, you can't customize your username or icon. For this, you'll need to use chat.postMessage API method. There are now two ways to achieve what you need here:
Use user token: This gives you access to take actions on the behalf of the user. Although, you'll need to take authorization from every user you want post the message as.
Request chat:write.customize scope with your bot token: You can post a message with icon_url and username parameters where you can provide the user's icon and name respectively for both the parameters. This is much easier, as this only requires one-time authorization.
More information in the official documentation.

Trigger slack commands programmatically from slack app [duplicate]

I'm writing a simple slack bot which should execute other slack commands upon being called. Everything is up and running, however the slack commands this bot issues don't seem to be executed.
For instance my bot posts /giphy kitten every hour and the message appears just like that in the channel (so the sending side seems to work), but the slash command itself isn't executed. If I post the same command into the same channel myself it works as expected. Are bots not allowed to execute slash commands?
Bots can use the undocumented API method chat.command to invoke slash commands.
See here for an unofficial documentation page of this API method.
This question was also answered here.
The command chat.command needs the permission scope post, which only legacy tokens have and which is not available for Slack apps.
I just asked the Slack customer support if sending slash commands programmatically is still possible and received the following reply:
I'm afraid not. Slash commands can only be triggered by human-sent
messages from the client. Apologies.

Slack bot responds to slash commands only in first channel

I have created a bot with a slash command that works, but it only responds to the channel in which the first Incoming Webhook was created. I would like it to respond in whatever channel (public or private) in which it was invoked.
I've tried creating a webhook for each channel and reinstalling the bot in my workspace, but it still reverts to the first channel.
I can see how I could hard code a webhook -> channel mapping in my code (php on my webserver) but that seems like a lot of very specific coding, and how would I ever release the bot to another workspace? I'm sure I'm missing something basic, but I can't work it out.
How do I deploy my bot so that it will respond to a slash command in whichever public or private channel it was invoked?
Fixed it. The example I was following had the webhook URL hard coded in the script. I just realised, upon re-reading the docs, that the actual webhook is passed in the POST data as response_url. Now it's all working fine. RTFM next time

Using Slack slash command to run local app

I want to write a Slack command to open Skype For Business (SfB).
The command will be something along the lines of:
/sfb my.colleague#company.com
SfB recognises the sip protocol, so I can type sip:my.colleague#company.com in my browser and it will open a conversation with my colleague in SfB.
However, on inspection of the Slack Integration pages, it seems that commands have to call a public url starting with http://.
There is an official Skype command for Slack, so I assume that what I'm trying to do is possible, and I'm just missing a step.
Slash commands work a bit differently.
Once a users issues your slash command, the request URL you specified will receive a special HTTP POST request from Slack (see here). You need an app running on that request URL (e.g. a Python script) that understands the format of the the slash request coming from Slack. And that URL needs to be reachable from the public Internet.
You can however open URLs on your local browser through Slack, albeit not in one step. Here is how it could work:
Use enters slash command
App responds with a message containing text link or link button, with your sip link.
User clicks on the link

Resources