Slack App Commands

App commands, like custom commands, have been developed by 3rd parties and trigger an action (like posting a gif, or starting a video conference, or adding something new to your todo list). Because they are intended to be shared with other teams, they are easy to attach to an app and require minimal configuration to install.

In order to protect data on teams, commands installed as part of a Slack app also have some additional restrictions:

They only support HTTP POST requests.
The external URLs that the command posts message data to must use TLS (https) with a valid certificate. Self-signed certificates are unsupported.
They inherit the icon and name of the app that they're attached to, and these properties can't be overwritten in the command response message.
Only users with permission to install apps can add an app to their team.
(By default, all users on a Slack team can install apps, but sometimes Team Owners and Admins restrict those privileges to certain users.)
On free teams, slash commands that are installed as part of a Slack App count as one towards the ten integration limit, that is to say: the app as a unit counts as one.
(By comparison, custom slash commands installed as custom integrations are counted together categorically as a single integration.)

Since custom commands on your own team have fewer restrictions than app commands, we recommend that developers start by creating a custom command for testing and development and import it to an app when they are ready to release it. Learn more about building and distributing your own Slack apps.

Creating the bot, steps taken at dev.botframework.com

  1. in cmd or terminal cd to project directory and do heroku apps:create <appname>. Remember to change the app name as you wish.

    https://.herokuapp.com/ | https://git.heroku.com/.git

  2. botframework register bot with handle as <appname>
  3. Add botframework endpoint as https://<appname>.herokuapp.com/
  4. Create APP_ID and CLIENT_SECRET. Once that is done, make sure CLIENT_SECRET is kept safe.
  5. Create bot. (Registration in botframework is done now)
  6. In cmd or terminal push the already coded project to heroku. git push heroku master
  7. Go back to botframework app's page and click on test connection. If you see Endpoint authorization succeeded then everything has gone well.

Add slack channel to the app

  1. Click on Add next to slack in Add channel for app. A new tab should open to Configure the application.
  2. Now you have to Create a slack app:

Creating a slack app, steps taken at https://api.slack.com/slack-apps

  1. Scroll down and click on Create slack app
  2. On the apps page, click on create new app
  3. Enter app handle autonomyx1
  4. copy APP_ID and APP_SECRET to config.ini
  5. In the slack page, go to OAuth & permissions and you need to add the botframework redirect URL here. To get the redirect URL, click on Create application and set redirect uri in Configure page.
  6. Copy the link and paste it in redirect URLs field in OAuth & Permissions page. Save changes.
  7. Add a bot user to your app. go to Bot users in the slack page and click on add bot user. Choose default bot handle @<appname>
  8. In the slack page Skip interactive buttons setup for now and jump to slash commands. In this app we have many commands. All commands go through one /autonomyx1 command.
  9. Add new command and give command as /autonomyx1

Note: Slash commands attached to apps must point to URL on your servers with a valid secure certificate.

  1. As the last step to add slack channel to app, add the slack credentials to botframework Configure page. Submit credentials.

Obtaining SSL cert for /slack/command endpoint for Heroku.

  1. Go to https://www.sslforfree.com/
  2. Sign up for a SSL cert with the slack app heroku link above.
  3. Follow site instructions: Download the following verification files by clicking on each link below Download File #1 Create a folder in your domain named ".well-known" if it does not already exist Create another folder in your domain under ".well-known" named "acme-challenge" if it does not already exist Upload the downloaded files to the "acme-challenge" folder Verify successful upload by visiting the following links in your browser
     http://<appname>.herokuapp.com/.well-known/acme-challenge/RltH98vNYUVdvwcz6ftWCNJo1aBQ5LPht0Rru5iVrFw
    
    If the files do not show random alphanumeric characters or shows an error then recheck that you are uploading in the correct place. If you use IIS then you may have to change your server config so that files without an extension (or the wildcard MIME type) serves as text/plain. Contact your host if you are unsure. Click Download SSL Certificate below.

Git workflow

  1. Make sure you make changes to master or develop branch
  2. Before heroku deploy merge those changes to production branch
  3. Make sure sensitive info files like config.ini are present
  4. To push production to heroku's master branch, do
git push heroku yourbranch:master