top of page

How to build a custom function in Bolt for use in the new Slack workflow builder

At #TDX24, the Slack dev team shared some exciting news: full Enterprise Grid sandboxes are now accessible, as detailed in my previous post and, for those of us accustomed to building apps with JavaScript or Python in Bolt, there's been an update that allows the creation of custom functions in Bolt using these languages. Based on these exciting updates, I decided to put together a simple function to try it out in one of the sandbox environments and this article is to share how you can try it yourself!



The function I developed sends random emojis to a user, utilizing JavaScript and Bolt for the task. You can view the code on GitHub here. Feel free to clone it and give it a try yourself — I'm confident you can get it up and running locally in less than 15 minutes assuming all dependencies are in place. This code was adapted from Slack's sample template code, an excellent starting point for anyone looking to build their own custom functions. Should you encounter any difficulties getting the code up and running, I strongly recommend starting with the official Slack documentation as the main resource for assistance though feel free to Slack Connect me at daniel@21b.app as well.


So, after you've successfully set up the code and it's running in a workspace, you'll notice a new custom function appearing in the Slack Workflow Builder.


When you add the new custom step into a workflow, there's a "User" field available for your workflow to use, tailored to fit your specific use case!



Now this function/step can be integrated into any workflow you desire to build. I've experimented with it in two ways: as a link trigger and as a scheduled trigger. For instance, in the link trigger scenario, you could set up a workflow that opens a form for the person to select another user to gift them 5 random emojis.



Meanwhile, with the scheduled trigger, think about creating an emoji digest that sends 5 random emojis to someone—perhaps they'll discover a new favorite emoji!



Either way, it’s a fun way to add more enjoyment to the Slack experience for your users around emojis - which everyone on Slack loves. Once sent, it looks like this:



Clearly, a sandbox might not have a vast collection of custom emojis, but in your actual Slack environment, I bet there's plenty!


Note, while this is a lot of fun locally, just a heads-up, at the time this article was written, it's not possible to deploy custom functions in Bolt directly to Slack's infrastructure, unlike Slack Deno apps developed in TypeScript. Will this change down the line? It's hard to say! However, you can still host these steps on your own infrastructure, much like previous Bolt apps. Slack suggests Heroku and you can read more here.


Summary

The introduction of accessible Enterprise Grid sandboxes and the ability to use JavaScript or Python for custom Bolt functions at #TDX24 marks a significant enhancement for Slack developers. This article explored creating a fun, emoji-sending function, easily set up and experimented with in various workflows. Although deployment to Slack's infrastructure is not currently available, the possibility of hosting on external infrastructure keeps the door open for creative Slack app development. This not only enriches the Slack experience but also underscores the evolving landscape of Slack app creation.



29 views

Comments


bottom of page