Skip to content

jamestkelly/harold

Repository files navigation

Harold

Contributors Forks Stargazers Issues MIT License


Logo

Harold

A chatbot for our favourite Slack channel at Deloitte.
Explore the docs »

View Demo · Report Bug · Request Feature

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. Roadmap
  5. Contributing
  6. License
  7. Contact
  8. Acknowledgments

About The Project

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.

Blacklisting Users

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 )

Built With

( Back to top )

Getting Started

Prerequisites

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

Secrets

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.

Running Harold Locally

  1. Comment out

    - schedule: cron(15 23 ? * SUN-THU *)

    in the file, serverless.yml.

  2. Within the same file, uncomment the following line:

    - httpApi: 'GET /handler'
  3. Run the following series of commands.

    cd /path/to/repo # Change directory to the repo
    sls offline

Deploying Harold

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

Automatic Deployment is done within the serverless website here. An account is required to proceed.

  1. First make sure it is deployed manually by running the following.

    sls login
    sls deploy
  2. 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.

  3. 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.

Usage

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 )

Roadmap

  • 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 )

Contributing

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!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

( Back to top )

License

Distributed under the MIT License. See LICENSE.txt for more information.

( Back to top )

Contact

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 )

Acknowledgments

Thank you to the following for their efforts in creating and maintaining Harold over the years.

Project Board

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 )

About

A chatbot for the Deloitte CBO #under30s channel.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published