WhereIsRudi is an interactive Slack app to inform your colleagues whether your dog@work is in the office today! 🎉
Use the Slash Command \whereisrudi
in any channel, direct message or any other slack conversation. That's it!
You will get a message every (working day) morning to ask you whether you bring your dog to the office today. Just answer with one tap or click via the actions in the message. It's that easy!
Local linting may be done using the Makefile:
make install
make lint
For easier deployment, the infrastructure as code (IaC) software tool Terraform is used.
- Install Terraform: https://learn.hashicorp.com/terraform/getting-started/install.html
- Define a Google Cloud Platform (GCP) project id, i.e.
whereisrudi-<random_number>
and enter it in: - Run preparation script:
- Run
prepare_gcp.sh
:bash prepare_gcp.sh
. You may run this in the Google Cloud Shell editor. This will:- Create a Google Cloud Platform project.
- Create Service Account and bind the roles
roles/owner
,roles/iam.serviceAccountUser
,roles/storage.admin
,roles/appengine.appAdmin
,roles/cloudscheduler.admin
,roles/pubsub.editor
androles/cloudfunctions.developer
. - Create new private key for the Service Account and save in the file
account.json
. - Enable the Google Cloud Platform APIs
appengine
,cloudfunctions
,cloudscheduler
anddatastore
. - You will be asked to enable billing for the created project when running the script.
- Copy the file
account.json
into thedeployment
folder.
- Run
- Commands need to be run in
deployment
folder:cd /deployment
- Initialize the Terraform working directory:
terraform init
- Generate and show the Terraform execution plan:
terraform plan
- Build the infrastructure:
terraform apply
and confirm withyes
. This step will output the endpoint URLsslack_actions_function_url
andslack_slash_commands_function_url
that you need to enter in the Slack API console.
To destroy/delete the infrastructure: terraform destroy
and confirm with yes
The following Google Cloud Platform resources are created via Terraform:
Three cloud functions with environment variables:
gather-information
(triggered by Google Pub/Sub topicgather-information-schedule
)SLACK_API_TOKEN
: Slack App OAuth Access Token (starting withxoxp-
)USER_ID
: Slack user id of dog owner.
slack-actions
(triggered by HTTP)SLACK_API_VERIFICATION_TOKEN
: Slack App Verification Token
slack-slash-commands
(triggered by HTTP)SLACK_API_VERIFICATION_TOKEN
: Slack App Verification Token
Google Pub/Sub topic gather-information-schedule
should be triggered every working day (monday - friday) at 7:30 AM.
Therefore the frequency is set to 30 7 * * 1-5
.
The cloud functions create a entities of kind days
. The entity id is the day string (i.e. 2019-09-14
). The entities only have one boolean field in_office
, which is not indexed.
Create a new Slack app in the Slack API console: https://api.slack.com/apps.
Create a Bot User, i.e. WhereIsRudi
.
In OAuth & Permissions in Scopes, add permission scope chat:write:bot
and incoming-webhook
to Conversations and bot
and commands
to Interactivity.
Add Interactivity request URL pointing to your Google Cloud Function slack-actions
. You got this URL as output from the terraform apply
step before, named slack_actions_function_url
.
Create new Slash command /whereisrudi
with request URL pointing to your Google Cloud Function slack-slash-commands
. You got this URL as output from the terraform apply
step before, named slack_slash_commands_function_url
.
See /design.