How to create a slack bot with the events API - ruby

I have my own slack team, with its own slackbot user.
I want to create a basic slack bot that will respond to direct messages, and I since I need specific events, I need to use the Events API.
I understand that slack will POST to my server the event that happened with its parameters, but I don't understand what needs to be done with the oauth permissions.
How can I add permissions to the slack app, without submitting the app?
reading the docs, I couldn't find the answer to this..
what am I missing?

You do not need to submit your app to the Slack App Directory. That is optional and only necessary if you want to make your app available to the public.
But you need to install your app to your Slack team before you can use it. During the installation process your app will be authenticated to your Slack team and you will receive a special token based on the scopes you requested.
The authentication process follows the OAuth standard and works similar to the process used by other web services, e.g. Twitter or Facebook.
I use a mini website for each of my Slack apps that has the "Add to Slack" button and is able to run through the OAuth process with Slack. This website is basically another script in addition to the one that will handle the events coming form Slack.
Check out the excellent documentation from Slack on the Slack button and how to use Oauth with Slack.

Related

Slack - Interactive button with authentication

What I'm trying to accomplish?
Send an API (chat.postMessage) from a 3rd party app to a Slack user - Done
The message will have two buttons (approve and decline) which the user can click on - Done
Upon clicking on one of the buttons, Slack should send an API back to the 3rd party app - TBD
Before sending an API, Slack should retrieve an authentication token via API - TBD
Note: I've seen in Slack docs mentioning of /incoming endpoint (also /interactive-message). My 3rd party app has a strict set of available APIs. I'm not able to create new API endpoints. Also, I need the payload to be sent in a specific JSON structure.
I've reviewed Slack documentation but I can't figure it out.
Making notifications actionable
I'm technical but not a developer so there might be nuances which I'm missing.
Is there any section in Slack where I can add custom code to accomplish such integration?
If not, how I can accomplish it?
Edit:
I've configured a Request URL (in slack), when I click on one of the buttons in the message, I can see an API request is being sent to the URL.
I'm able to see the payload as well.
My problem is that I need the information to be sent in a different format and to a different endpoint.
What is the best approach to take for this? Do I need to develop a new service to capture and parse the payload and then generate the API request to my 3rd party app?
Ok, so here is how I've accomplished it.
Upon clicking a button in slack, Slack sends an API with a certain payload to the predefined endpoint which you configure (Request URL).
I've used free tier AWS serverless components:
API Gateway and Lambda
API gateway receives the payload and invokes the Lambda function (I used Python as it seems the easier for a non developer)
My Lambda function is processing the payload and has the logic to interact with my 3rd party app in the required way.

Facebook messenger bot cannot reply automatically to any other Facebook users instead of the admin

I have created a Facebook messenger chatbot, and is working perfectly with the admin, I mean the admin can interact with it without any issue, but all other users from Facebook can send it messages and the chatbot cannot respond to them automatically
You need to go through the app approval process.
Bots can no longer work without approval from Facebook.
You need to request specifically: pages_messaging and pages_messaging_subscriptions.
Good luck.

How to find out if workspace added or removed your Slack App?

I have some questions about Slack App after Public Distribution is activated.
Our team has developed a Slack App with bot and incoming webhook features, and we have activated public distribution for this Slack App, and added the "Add to Slack" button on our product webpage.
Questions:
Is there any way to find out what workspaces have added our Slack App? I understand that via the Add-to-Slack flow, we would know when a workspace has added the Slack App along with the resulting bot access token and webhook. But is that the only way to keep track? Is there no API to just list the workspaces, resulting bot, and webhook?
Is there any way to find out which workspaces have removed our Slack App? I can infer that information by doing an users.list API call using the bot access token. If it says token invalid, then I can guess that the workspace has removed the Slack App. Is there no other direct API to find out if a workspace has removed the Slack App?
Thank you.
Is there any way to find out what workspaces have added our Slack App?
I understand that via the Add-to-Slack flow, we would know when a
workspace has added the Slack App along with the resulting bot access
token and webhook. But is that the only way to keep track? Is there no
API to just list the workspaces, resulting bot, and webhook?
This is the only way (to track workspace during installation flow). At least for now, I saw such a feature in mid/long term plans for Slack API team.
Is there any way to find out which workspaces have removed our Slack
App? I can infer that information by doing an users.list API call
using the bot access token. If it says token invalid, then I can guess
that the workspace has removed the Slack App. Is there no other direct
API to find out if a workspace has removed the Slack App?
Take a look at app_uninstalled and tokens_revoked API events.

Passing an external user ID through MS Bot Framework

I am working on a Skype bot, using Microsoft's Bot Framework.
I have an external website, where a user can create an account, obtaining a userID. I would like to have a button on my website that allows me to link their account to a Skype conversation.
The only way I can work it at the moment is by having the Skype bot ask for the user's email, then the user has to go onto the website and confirm that that was them on Skype. Not a good UX.
I know Telegram lets you do what I want with "deep linking", and Kik can do it by scanning QR codes. Facebook Messenger can do it by including the Facebook JSSDK in the page with a "Connect to this bot" button.
Is there any way to do this on Skype?
Use the "Sign-in Card" workflow to have your users authenticate with your website before proceeding with the Skype bot conversation.
The Sign-in card enables a bot to request that a user sign-in. It typically contains text and one or more buttons that the user can click to initiate the sign-in process.
For documentation and code example, see:
https://learn.microsoft.com/en-us/bot-framework/dotnet/bot-builder-dotnet-add-rich-card-attachments#add-a-sign-in-card-to-a-message
Blog article showing sign-in card walk-through:
https://tsmatz.wordpress.com/2016/09/06/microsoft-bot-framework-bot-with-authentication-and-signin-login/
Additional code examples:
.NET SDK - https://github.com/Microsoft/BotBuilder-Samples/tree/master/CSharp/cards-RichCards#sign-in-card
Node.js SDK - https://github.com/Microsoft/BotBuilder-Samples/tree/master/Node/cards-RichCards#sign-in-card
Use individual deep link mechanism for each bot (e.g. telegram) that you wish to implement.
How to setup Telegram webhook the simple way.
Telegram webhook requirement
HOWEVER, it doesn't work on Skype.
Microsoft bot builder deep linking
he only way I can work it at the moment is by having the Skype bot ask for the user's email, then the user has to go onto the website and confirm that that was them on Skype. Not a good UX.
This is the only way so far for Skype.

Slack File Library

I really like Slack but my organization won't allow it if we cannot disable file sharing features. I'm trying to find out whether I can either disable uploads of certain file types or hide the file library all together. Their support says there's no way to do this natively but is this possible with the API?
No, not to my knowledge. The main focus of the API is not to configure your Slack team, but to enable bots and 3rd party apps to communicate with your Slack team and retrieve information. All core configuration for your Slack team has to be done in admin settings and apparently you have already learned from Slack support team that you can not deactivate file sharing in admin settings.
But I think I might have a solution for you. You can create a Slack bot that automatically blocks sharing of files in channels. (technically the bot would auto delete any message that is a file share form a user). Users would still be able to upload files, but they wont be able to share them. At least not in any public and known private channel. However there is a caveat: As I understand the bot would not be able to block users from sharing files in direct messaging channels though.
We are using a similar bot to block messages from unauthorized users in some private channels, which works nicely. Our bot is a simple Slack app with a bot user and using the Events API to receive all messages from all channels he is invited too. The bot then checks each new message and deletes the ones that does not fulfill some criteria. In our case if the message comes from a user that is not on the whitelist.

Resources