Courier Live: Designing Slack Notifications using Block Kit and Jsonnet
Earlier this summer, Riley Napier from our engineering team joined me for our June 24th Courier Live to help me build a Slack Slash Command to display estimated departure times for BART Stations. We created a Glitch ExpressJS app to accept the commands and Courier to handle the responses. We designed the messages by dynamically generating Block Kit using Jsonnet.
Check out the video below to watch us:
Walk through setting up a Glitch App that handles Slack Slash Commands
Create a notification for Slack
Use the Jsonnet Block to dynamically create Block Kit elements
Find the full project code on the Courier Slack Slash Bart Glitch App.
Be sure to Like the video and Subscribe to our YouTube channel.
What is Jsonnet?
Jsonnet is a powerful data templating language for JSON. It has a Python-like syntax that allows you to build JSON output using variables, functions, conditionals, etc. This comes in handy when dynamically creating Block Kit elements for Slack. Courier provides the following functions that allow you to grab data and profile information.
For an overview of the basics of Jsonnet syntax, check out Learn Jsonnet in Y minutes.
Displaying BART Station Departure Times
To display the Departure Times passed to the notification, we used variables, functions, and list comprehensions to generate the resulting Block Kit sections. We started with the following data originating from the BART API:
Using a Jsonnet block, we used the following Jsonnet code to render the Block Kit Sections
This results in Block Kit that looks like the following:
Feel free to remix our Glitch app and create your own Slack Slash Command. Be sure to let us know what you create.
Is there something you’d like to see us do using Courier? Let us know and it might be the subject of our next Courier Live. We stream a new Courier Live every Wednesday at noon Pacific. Follow us on Twitch to be notified when we go live.
More from Courier Live
Courier April Product Release Updates: In-app Inbox, Preferences, and Automations
In this update, Aydrian and Nate (Head of Customer Success) as cohosts cover what is new with the in-app...
May 20, 2021
Courier Live: Content, Notifications, and IoT
On February 2nd and 3rd, Shy Ruparel joined Aydrian for another Courier and Contentful crossover stream....
February 10, 2021