Skip to content

A simple notification pattern based on apprise

In my current role I try to learn and experiment with side projects whenever I can. One of these regards the need to notify a developer as soon as an update has been made to internal tools (e.g. the latest release of a private Python library, a new page in the team's knowledge base, etc.).

After some research I came up with a simple solution based on a pub-sub architecture, Microsoft Teams webhook and the awesome Apprise.

As shown in the diagram, the solution consists in:

  • Git repositories as publishers, each with a dedicated topic;
  • a worker as the single subscriber;
  • forward passing of each commit metadata from the publishers to the subscriber, which format the metadata in Markdown and publish the message to a dedicated Microsoft Teams channel through Apprise.

I implemented this blueprint with AWS services: CodeCommit repos forward commit events to a Lambda function thanks to several EventBridge rules, and the function reads the target webhook stored in Secrets Manager.

The cherry on top!

Since Apprise support Markdown format, if the committer inserts Markdown syntax in the commit body, all the worker has to do is read the commit message, parse the body and forward it as a message to the recipient!

In my case, I implemented the worker to search for a @teams tag within the commit message and applying the following two rules:

  1. if the tag is not found, do not notify anything (to prevent unwanted spam to the recipients);
  2. if the tag is found, everything before must be ignored, and the notification body is made only of what follows the tag within the commit message (to allow splitting between short commit message and rich commit text to be forwarded as notification message).