Requirements on the Slackbot
Simply creating a new page every week would have been fairly easy, even without a Slackbot, just by creating a Confluence template. However, at the end of every sync page is the facilitator for the next sync mentioned – which needs to be transferred. Apart from this, some other adjustments need to be done which in total still results in some work and sometimes being forgotten. The basic work for the bot can roughly be described as followed.
- Find the latest sync page in Confluence (sync isn’t every week and other pages on the same level exist)
- Get all information needed from the last page (next facilitator, last sync date and next sync date)
- Create a new page with the available information in Confluence (make the best of the information available)
- Send a message, including the link to the new page, and preferably mentioning the next facilitator to our Slack channel
Let me stress that even though AWS is used, other services can be used just as well. Listed down are the dependencies used or needed for the bot to perform its task. Besides those, other configuration data is stored as variables. For example, the Confluence space key, the parent page id of all sync pages, a template for sync pages or the Slack-channel name where messages will be sent to.
- AWS Lambda (or anything else to execute code) – since the Slackbot does not need to be permanently online, this was a cost-effective way. Furthermore, there are some tutorials on how to create a serverless Slackbot if you want to make usage of commands or events.
- AWS Cloud Watch to trigger the code.
- AWS Signing Secret (or any other way to store your credentials) – Confluence username, password, and Slackbot token are stored here.
- Installed Slack App in your workspace with either a webhook or bot (bot needs to be installed in the preferenced channel and will use Slack API). A webhook is enough for only posting messages – I changed to a bot at some point to be able to schedule messages and retrieve information about channels as well.
- Confluence Server API to retrieve and post pages. (There might be changes in the workflow when using Confluence Cloud API)
Workflow between Slackbot, Confluence, and AWS
Since there was no need for the Slackbot to react on events, it is in fact only a script executed upon being triggered. Below is the overall workflow with some comments afterward.
- (3) Response data might be limited, so the request is being performed as long as not all sync pages are retrieved. ‘Sync page’ is actually every page below a pre-defined parent page and is not necessarily a sync page.
- (5) This step could have been done along with (3). It’s done afterward, to cut unneeded response overhead in step 3. The content is retrieved in internal storage as well as Html format since some information such as a user-id can be found in internal storage format but no username.
- (6) Through specified search keys the next facilitator (user id and username) and eventually next sync date, as well as the last date are filtered. A template is used to create the new page with that information – which will be sent along in step 7.
- (8) After asking for all users within a predefined channel, their e-mail addresses are heuristically looked through to find out if the mentioned facilitator on the Confluence page is a member of the Slack channel. This allows mentioning the facilitator in messages.
- (10) One message is sent right away with a link to the new sync page (part of the response in 7), mentioning the next facilitator if possible. Other reminder messages are scheduled a few days or directly before the sync.
Pros and Cons
Less work for facilitator
No chance of the task being forgotten
Time and cost-effective compared to someone doing it manually
– Functionality is based on predefined variables and trigger words that make changes like page layout, parent page, channel or Confluence space difficult.
It’s a pretty custom solution but can be – depending on the use case – easily be transferred with the right adjustments. However, I am sure, given more time and resources, this could be improved to become a more generic solution. The Slackbot could, for instance, ask for needed configuration upon being added to a channel and offer a command for changing the configuration.
Let me know your opinion and don’t hesitate to ask how this is done in detail in the comments below or via email at email@example.com.