How to Connect a Bot to Slack
Through Bot Libre, you can now send and receive messages on Slack with your own bot. You can use this to chat with your bot through Slack or have your bot monitor and response to users in a Slack channel. This "How To" will give you a step by step process to connect your bot with Slack.
Step 1 - Create a Bot
First you must create a bot that you want to connect to Slack, or you can use one of your existing bots. To create a bot, follow the instructions here: How to create your own chat bot in 10 clicks.
Step 2 - Create a Slack team
Go to http://www.slack.com and create a team.
You will receive a confirmation code via e-mail which you will need to enter on the next page.
Finish filling out information for your username and team name and then continue.
Step 3 - Setup Custom Integration
You will now need to set up a custom Slack integration for your bot. Click your team name in the top-left part of the screen and select "Apps and integrations" from the dropdown menu that appears.
Click the "Build" button at the top-right.
Next, click the "Make a Custom Integration" button to continue.
Step 4 - Create Outgoing Webhook Integration
Setting up an Outgoing Webhook integration will allow your bot to converse with other users in a Slack channel.
Click "Outgoing Webhooks" to begin.
Click the "Add Outgoing Webhooks integration" button to begin.
Scroll down to the Integration Settings section.
You can either have your bot listen to all channels, or listen only in a specific channel. If you select "Any", you will have to enter one or more "trigger words" that your bot will respond to. If you select a specific channel though, your bot can respond to any messages in the channel, although you may still enter "trigger words" if you only want the bot to respond to certain messages. Further down on the page you can customize the name and icon that your bot will use when posting to Slack.
We will connect your bot to Slack in the next step. Take note of the "Token" and "Customize Name" from this page, you will need them in the next step.
Step 5 - Setup Bot
Return to the Bot Libre website and proceed to your bot's admin panel. Click on "Slack" to view Slack settings for your bot.
Enter the "Token" from the previous page into the "Slack Outgoing WebHook Token" field. You may enter the custom name you set on Slack into the "Slack Bot Username" field to have your bot only respond to messages directed at it or mentioned in.
Next, copy the URL from the "Slack Outgoing Webhook URL" field to your clipboard. Press "Save" to save your bot settings.
Return to the Slack Outgoing Webhooks integration settings page on the Slack website from the previous step. You will need to paste the URL from your clipboard into the "URL(s)" field.
Press the "Save Settings" button at the bottom to complete the setup. At this point, your bot will be now be able to communicate with users on the Slack channel you have set up above! You may stop here if that is all you want your bot to do.
If you want your bot to automatically post from an RSS feed or make other automatic posts, continue with the steps below.
Step 6 - Create Incoming Webhook Integration
Return to the Make a Custom integration screen on Slack, and select "Incoming WebHooks".
Select the channel you would like the bot to post to, then click the "Add Incoming Webhooks integration" button.
Scroll down to "Integration Settings". You can customize the name and icon that your bot will post as here.
Copy the "Webhook URL" here to your clipboard. Click the "Save Settings" button, and then return to the Bot Libre website and to your bot's Slack admin page.
Step 7 - Setup Bot RSS Feeds and Autopost
Paste the "Webhook URL" from your clipboard into the "Slack Incoming WebHook URL" field.
Enter the URL's of RSS feeds you would like your bot to post into the "RSS Feeds" field, each separated by a new line. You may enter keywords into the "RSS Keywords" field to have your bot only posts RSS feeds that have one of your keywords in the title. You can also optionally enter a different Bot Username or Channel to post the RSS feeds to that will override the bot name and channel set up on the Incoming Webhooks settings on the Slack Website.
Select the "Auto Post" checkbox if you want your bot to automatically post to a Slack channel at set intervals. You can set the time between auto posts in the "Auto Post Hours" field. In the "Auto Posts" field, you can enter posts that your bot will select from when it autoposts. Each post should be on a new line. You may use 'Self' or 'AIML' templates in these posts. You can also optionally enter a different Bot Username or Channel to auto post to that will override the bot name and channel set up on the Incoming Webhooks settings on the Slack Website.