A Slack bot to help create a Notion page from a Slack message. This bot sends back a reply to the Slack message with a link to the Notion page it just created and adds a ✅ reaction as a marker.
You can customise the bot to add specific properties for the pages. By default, the bot will show you a form to customise the page it's going to create.
This bot is made to be deployed to AWS Lambda using Serverless framework.
In our workplace, we use Slack as our discussion platform and Notion as our kanban board and for any discussion notes. We have a channel on Slack specific for reporting issues and sharing feedbacks for our application, which a lot of the times we want to put them as tickets on Notion.
We like to put a ✅ reaction to the discussion to let the team know that we have created a ticket for it, then link the URL to the ticket as a reply to the discussion. To give the ticket more context, we also put a backlink to the Slack discussion as its description.
As we implement more features and we have more to give feedbacks on, creating these tickets become tedious, hence why we created this bot to automate the task.
This bot provides an interactive command to create a ticket from a Slack message. Simply select the "more" button on a message and choose "Create a ticket". The bot will then show you a form to customise your ticket as shown in the previous image.
- Set up a Slack app if you haven't already
- On your Slack app configuration, create a shortcut under the Interactivity and Shortcuts and set
shortcut_ticket
as its Callback ID - Under Slash Commands, create a new
/user-ids
command
-
Create a Notion integration to your workspace and take note of the integration token
-
Create a database in your Notion if you haven't. In this database, add the properties of the database entry like so: Note: Do not mistake the screenshot above as the database. That's just an example of the database entry
-
You don't have to exactly match what we have there, the important properties for setting up are:
- Status (Select)
- Type (Select)
- Categories (Multi-select)
Make sure to have at least one selection for each property
-
Share your database to your Notion integration by pressing the share button on the top right of your database
At the root of the project, create a .env
file and put all the required tokens and your database ID like so:
There are a few files you will need to edit in the project to customise the bot to your own need:
- Edit this file to customise your Slackbot form interface
- Edit this file and this file to customise the ticket creation logic
- Edit this file if your tickets have properties needing an external Notion database (e.g. "Assigned to" and "Project" properties)
You will need this method if you want the bot to be able to assign users into the ticket
- Set up a separate database to map the Notion users to the Slack users
- Create the database like so: Note that the property names have to be the exact match (Name, User, SlackID)
- Fill in all your Notion users into the database
- To get the Slack User IDs, you can run
/user-ids
on your Slack channel once the bot is running - Copy the Ticket Bot User Mapping database ID and put it into the
.env
and name itNOTION_USER_DATABASE_ID
- Open up a terminal at the root of this project, and run
npm run start:local
- Hook up another terminal and run
ngrok http 3000
- Ngrok will give you the URL for the bot, copy it
- Follow this guide to tell your Slack bot to use your Ngrok URL
- Change the AWS region to suit you in serverless.yml
- Follow this guide if you're new to AWS Lambda and Serverless framework
- If you already have your AWS CLI set up, run
npm run deploy
- Follow this guide to tell your Slack bot to use your Lambda URL
- The bot is a little bit slow, an error message may come up when loading the form. This does not affect the ticket creation and you can ignore the errors from Slack
- The ticket form may not close on submission. Submitting the form for the second time or just simply closing the form should be fine. No ticket duplications will be made.