A chatbot for our favourite Slack channel at Deloitte.
Explore the docs »
View Demo
·
Report Bug
·
Request Feature
Table of Contents
This project is deployed using the serverless framework.
Harold runs as a NodeJS Lambda which is triggered on a Cron Schedule. He uses the groups.info
Slack API to retrieve a list of user's for a channel and then sends a question to the channel via a web-hook. You can access Harold's slack integration options from here.
The list of questions that Harold selects from is provided as a separate text file resource to the main application logic. If you do not have access PM @sean
or @Jim Kelly
on Slack to be added as a contributor.
Since the groups.info
returns all members of a group, it will also return inactive users and bots. To rectify this, Harold utilises a simple blacklist mechanism which takes an array of userIDs and reselects a user in the instance where a blacklisted user is chosen. To blacklist any user, fetch their userID and add it to the memberBlackList
array in handler.js
. An example of this can be seen below.
const memberBlacklist = [
"U037L59QX0R", // Derek
"U0375TKH0LU", // Jimmy
// "U0370KT3VRC" // Aaron
];
( Back to top )
( Back to top )
You'll require both an AWS and Serverless account to deploy Harold, whereas you'll only require Serverless to run the bot locally.
- serverless
brew install serverless # Install serverless
serverless login # Login via the serverless dashboard in a web browser
- aws-cli
brew install aws # Install AWS
aws configure
AWS Access Key ID [None]: AKIAIOSFODNN7EXAMPLE
AWS Secret Access Key [None]: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
Default region name [None]: us-east-1
Default output format [None]: json
Additionally, you'll need to either have a copy of the .env
file containing secrets, or you can create one yourself with the following structure.
OAUTH_TOKEN=X
ENVIRONMENT=prod
U30_SLACK_CHANNEL_ID=X
U30_WEBHOOK_URL=X
All of these can be found through the Slack API portal.
-
Comment out
- schedule: cron(15 23 ? * SUN-THU *)
in the file,
serverless.yml
. -
Within the same file, uncomment the following line:
- httpApi: 'GET /handler'
-
Run the following series of commands.
cd /path/to/repo # Change directory to the repo sls offline
To deploy Harold, configure the serverless and AWS credentials locally as outlined previously in the Prerequisites section. Then enter the following commands.
cd /path/to/repo # Change directory to the repo
sls deploy --aws-profile default --verbose
( Back to top )
Automatic Deployment is done within the serverless website here. An account is required to proceed.
-
First make sure it is deployed manually by running the following.
sls login sls deploy
-
The app should appear in the apps section in the website. Click on the deployment stage called prod. Then click on the settings in the top right.
-
Connect the git repo to the serverless account from this window. Connect the AWS account to the serverless account from this window too. In the branch deploys section add the master branch on stage prod.
Harold will follow a cron
schedule as is outlined in the serverless.yml
file. Currently, the bot runs from Monday to Friday; sending a message at 10:15AM AEDT.
( Back to top )
- Complete handover of Harold to the new team.
- Update the README.
- Imlpement automatic deployments (GitHub Actions) when any PR/MRs are approved to
master
branch. - Perform an audit of the questions and remove any bad ones.
- Develop outline for future features and improvements.
- Add additional plans and updates here.
See the open issues for a full list of proposed features (and known issues).
( Back to top )
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
( Back to top )
Distributed under the MIT License. See LICENSE.txt
for more information.
( Back to top )
All contributors and project maintainers are available on Slack via their handles as can be seen below:
@Aaron Douglas
@Houston
@Jimmy Houang
@Jim Kelly
@Pat Randell
@Rebecca Ye
@ying
( Back to top )
Thank you to the following for their efforts in creating and maintaining Harold over the years.
The previous project board can be seen here as hosted on Trello. This is now out of date and is yet to be updated regarding further developments.
( Back to top )