A slack bot that automates show notes creation for Les Cast Codeurs podcast.
This bot is using the Socket Mode and can be set up without much hassle.
First you need to create a Slack app and install it in your workspace :
- go to https://api.slack.com/apps,
- create a new Slack app using this manifest.yml,
- optionally set an app icon in Settings > Basic Information,
- create an app-level token with the scope
connections:write
in Settings > Basic Information and save it for later (it will be referred asSLACK_APP_TOKEN
), - install the app using the Install to workspace button in Settings > Basic Information,
- save the Bot User OAuth Token for later in Features > OAuth & Permissions (it will be referred
as
SLACK_BOT_TOKEN
).
Then you need to add customised emojis to your workspace. Those will allow you to categorize news using reactions.
The following emojis must be added (suggested emojis can also be found in this directory) :
Note also that aliases does not work because the name returned by the Slack API is not the name of the alias (it is the name of the aliased emoji).
Then you need to create a GitHub personal access token and a publication repository (a repository where the show notes will be published) :
- go to https://github.com/settings/tokens/new,
- create a new personal access token with the scope
repo
and save it for later (it will be referred asGITHUB_TOKEN
), - create, if needed, a new publication repository and keep its coordinates (it will be referred
as
GITHUB_REPOSITORY
).
Warning This way of deploying
lcc-slack-bot
is fragile and will soon be modified. The ultimate goal is to deploy the bot on Google Cloud.
First install Java 17 on the target server and create the dedicated user that will run the bot (every instruction below must be executed with this user from its home directory).
Then download the latest lcc-slack-bot
jar from
the com.lescastcodeurs.lcc-slack-bot
Maven repository
and copy it on your server.
You also need to create the launch script using the following template (do not forget to make the script executable) :
#!/usr/bin/env bash
# GitHub credentials and repository used for the publication of the show notes.
# See the "Create the GitHub token" section for an explanation of how to get this token.
export GITHUB_TOKEN='ghp_xxx'
export GITHUB_REPOSITORY='lescastcodeurs/staging.lescastcodeurs.com'
# Credentials used to retrieve the show notes in Slack. See the "Register the bot in your workspace" section for an
# explanation of how to get those tokens.
export SLACK_BOT_TOKEN='xoxb-xxx'
export SLACK_APP_TOKEN='xapp-xxx'
# Name of the GitHub repository used to retrieve the conferences list, and criteria used for filtering the list.
# Those properties are already set to those values by default.
#export CONFERENCES_JSON_URL='https://developers.events/all-events.json'
#export CONFERENCES_SELECTION_CRITERIA='(France),Devoxx'
# Criterion used to retrieve the record date. Any top-level message of a thread containing this criterion is a
# candidate for guessing the record date (the last one wins).
# This property is already set to this value by default.
#export LCC_RECORD_DATE_CRITERION='recording.zencastr.com'
export JAR=$(find . -name 'lcc-slack-bot-*-runner.jar' | sort | tail -n 1)
java -Xmx128m -jar "$JAR" | tee -a 'lcc-slack-bot.log'
Finally, you can start the bot in a screen using the following command :
screen -S lcc-slack-bot -d -RR ./lcc-slack-bot.sh
> __ ____ __ _____ ___ __ ____ ______
> --/ __ \/ / / / _ | / _ \/ //_/ / / / __/
> -/ /_/ / /_/ / __ |/ , _/ ,< / /_/ /\ \
> --\___\_\____/_/ |_/_/|_/_/|_|\____/___/
> 2022-09-04 21:33:28,921 INFO [io.quarkus] (main) lcc-slack-bot 1.4.0 on JVM (powered by Quarkus 2.12.0.Final) started in 4.069s.
> 2022-09-04 21:33:29,118 INFO [io.quarkus] (main) Profile prod activated.
> 2022-09-04 21:33:29,119 INFO [io.quarkus] (main) Installed features: [cdi, qute, smallrye-context-propagation, vertx]
> 2022-09-04 21:33:33,846 INFO [com.sla.api.soc.SocketModeClient] (Grizzly(2)) New session is open (session id: 123e4567-e89b-12d3-a456-426614174000)
Once the bot is started, you can verify it is working using the following message : @lcc Are you there !?
.