This git repository contains a suite of Slack™ integration tools to be used for interfacing with Jama Connect™ software.
This work is licensed under the MIT license. See the file LICENSE in this distribution for license terms.
Copyright © 2018 Jingyu Ye, Aleena Watson, Brent Soles, Bonden Lyons, Taisheng Guo & Lance Booth
This project has been tested using Python version 3.7.1. We strongly recommend using a Python virtual environment to manage dependencies.
- Pull down code
- (optional) Create a virtual environment
pip install virtualenv, probably
- Install the python dependencies:
- flask
- requests
- websockets
- slackclient
- mysql-connector (Even if you don't use a database. You'll run into problems otherwise.)
- (optional) For extra functionality (e.g. Jama-side OAuth), import "schema.sql" into a new database
- This application was developed on and tested with a MariaDB server, but either that or MySQL should be fine.
- The import command should be something like
mysql -u <DB username> -p <DB name> < schema.sqlfrom the command line, or importing schema.sql from your GUI if you have one.
- For instructions on running the server, see src/run.sh.template
To activate the functionality in Slack, you must first create a Slack app. In order to do this, you will need the following:
- A Slack workspace
- A Slack user, who is a member of the Slack workspace
- The URL of the server on which this code will run
- To create a new app, you need to log into your target workspace. Then you should go to the Slack Application Page and click on Create New App . Here you can edit the app name and the related workspace. You can type any app name you want; However, for the purpose of managing your Slack app, we recommend you to name this app "Jama Connect".
IMPORTANT By default, the app creator would be the only author of the app.
You can go to your app's Settings > Collaborators page and add other Slack
users in your workspace as authors. Be careful because a collaborator can change any of the app's settings, add more
collaborators, or even delete the app.
- For our Jama Slack Integration to work properly, you need to turn on some
Slack features and functionality, which are in the
Featuressection on your left-hand side of your Slack app's homepage.
In this page, you need to turn on the feature, fill in URLs, and create actions.
- Click to set the
On/Offtoggle button toOn. - Fill in the
Request URLasyour-hosting-url/SERVER_ADDRESS/dialog. For example, if the URL of your hosting server ishttps://www.jama.comand theURL_RULEsection insrc/run.shis"/jamaconnect", theRequest URLshould behttps://www.jama.com/jamaconnect/dialog. Note: the URL should not have a trailing slash. - In the
Actionssection, clickCreate New Actionto add new actions. There are two actions required for this integration and their fields are shown belows:
| Field | Value | Note |
|---|---|---|
| Action Name: | Add comment | This can be change if you want. |
| Short Description: | Adding comment to Jama item | This can be change if you want. |
| Callback ID: | comment |
| Field | Value | Note |
|---|---|---|
| Action Name: | Attach file | This can be change if you want. |
| Short Description: | Attach file to Jama item | This can be change if you want. |
| Callback ID: | attachment |
- In the
Message Menussection, fill in theRequest URLasyour-hosting-url/URL_RULE/menu.For example, if the url of your hosting server ishttps://www.jama.comand theURL_RULEsection insrc/run.shis"/jamaconnect", theRequest URLshould behttps://www.jama.com/jamaconnect/menu. Note: the URL should not have a trailing slash.
On this page, you need to click the Create New Command button to add a new
command. There is one command required for this integration and its fields
are shown below:
| Field | Value | Note |
|---|---|---|
| Command: | /jamaconnect | You can use another command. For the purpose of managing your Slack app, we recommend you to use /jamaconnect. |
| Request URL: | your-hosting-url/URLRULE | For example, if the url of your hosting server is https://www.jama.com and the URL_RULE section in src/run.sh is "/jamaconnect", the Request URL should be https://www.jama.com/jamaconnect. Note: the URL should not have a trailing slash. |
| Short Description: | Jama Connect commands | |
| Usage Hint | [help|search|create|comment] |
In this page, you need to turn on the Enable Events, fill in URLs, and subscribe to bot events.
- Click to set the
On/Offtoggle button toOn. - In the
Enable Eventssection, fill in theRequest URLasyour-hosting-url/URL_RULE/bot.For example, if the url of your hosting server ishttps://www.jama.comand theURL_RULEsection insrc/run.shis"/jamaconnect", theRequest URLshould behttps://www.jama.com/jamaconnect/bot. Note: the URL should not have a trailing slash. When you set up this URL the first time, slack will need to verify the URL. You can changeSETUP_BOTinsrc/run.shtoonto pass the verification. Once you have passed that, you can change it tooffin later use. - In the
Subscribe to Bot Eventssection, you need to add bot user event. This will effect the range of message that the Bot user can listen from. Recommendation:
| Event Name | Note |
|---|---|
| message.channels | Bot can listen when a new message has posted to a public channel. |
| message.groups | Bot can listen when a new message has posted to a private groups channel. |
| message.im | Bot can listen when you set a direct message to the Bot. |
On this page, you need to turn on the Slack Bot User.
- Click the
Add A Bot Userbutton. - Click the
Add Bot Userbutton to save the change.
On this page, you will need to add tokens to the src/run.sh (which you will have created earlier using src/run.sh.template) and also select permission scopes for this Slack app.
- In the
Scopes > Select Permission Scopessection, add the following permission scopes by typing them intoAdd permission by scope or API methodsearch box:
| Permission Scopes |
|---|
| incoming-webhook |
| files:read |
| bot |
| commands |
| users:read |
| users:read.email |
After you add all of the above scopes, click Save Changes.
- Click the
Reinstall Appbutton to add the bot user. - In
src/run.sh, store theOAuth Access Token(the token begins withxoxp-) to the environment variableSLACK_OAUTH_TOKEN. - In
src/run.sh, store theBot User OAuth Access Token(the token begins withxoxb-) to the environment variableSLACK_BOT_TOKEN. If you can not find this token, please make sure that you already added a bot user in theFeatures > Bot Usersection, added thebotpermission scopes in Step 1, and clickedReinstall App.
On this page, you need to turn on the Translate Global IDs feature by clicking to set the On/Off toggle button to On.
On this page, copy the Signing Secret token found in the App Credentials section
and store it in the environment variable SLACK_SIGNING_SECRET in src/run.sh.