Slack app for the CiviForm workspace. This is designed to be run in a specific EC2 instance.
- EC2 instance with Ubuntu 24.04 (probably works fine on others, but this is what it's using now).
- Create a user called
civibotwith sudo access, using /bin/bash for the shell. - Install make, nodejs, npm, git, unzip.
- Install the AWS CLI
- In IAM (not IAM Identity Center), create a
civibotuser. Create an access key for the user. - On the host, run
aws configure, providing the access key and secret. - Requires
SLACK_BOT_TOKEN,SLACK_SIGNING_SECRET, andSLACK_APP_TOKENsecrets in AWS Secrets Manager. a. Each secret should have the given name, and the actual key in the secret should also be the given name, with the value being the Slack secret value. It should also have a tag callednamewith the value being the secret name. b. Create a policy in AWS that allows thesecretsmanager:GetSecretValuepermission on the ARNs for the three secrets (note that the ARN looks likearn:aws:secretsmanager:us-east-1:<account id>:secret:SLACK_BOT_TOKEN-<random string>so you will probably want to useSLACK_BOT_TOKEN-*in the resource definition), as well assecretsmanager:ListSecretsfor all resources ("*"). c. Apply the policy to thecivibotuser. - The civibot_github key should be in
/home/civibot/.sshwith mode0600. You can get this key from Nick. /home/civibot/.ssh/configshould have the following contents:
Host github.com
HostName github.com
User git
IdentityFile ~/.ssh/civibot_github
IdentitiesOnly yes
- Clone the repo.
- Run
make install. This will install a service that runs the bot. - Tail the log in
/home/civibot/civibot/logs/civibot.logto ensure there are no errors.
You can deploy a different branch of the civibot repo by using the !deploy command. You must be in either #civibot-admin or #civibot-test to do this, and must be on the list of CiviBot admins. If you get things stuck with the app unable to start on the new branch, contact Nick to SSH into the node and fix it (or do so yourself if you have the SSH key). There is also a !restart command in case things get weird, but it's still responding to commands.
You will need node version 18+. This is currently running on 18, but probably works fine with later versions.
Run npm install from the root of the repo to install dependencies.
Run make fmt to format your code before submitting a PR.
After merging a PR, run !deploy latest in #civibot-admin to deploy your changes.
- If you want to be able to have CiviBot respond in whatever context it was triggered in (channel, DM, thread), use
context.sayinstead of justsay. If you need to respond with custom blocks (see the xkcd script), use the regularsay. - Create a
helphash that maps command names to help text. Then, export both this and asetupfunction that does the actual meat of the script. These two things are automatically loaded by the app.