I currently am working on a project called Amici that aims at making it easier to schedule with your friends through an app and web platform. We're a group of seven college students and young professionals, so we're learning lots every day.
One of our favorite channels in Slack is our #standup channel, where we post short updates when we finish a task, have a good meeting, or just have something to share about work. Its great to see what people are up to across departments and see updates in a central place.
We originally started doing standups in Notion through a database, but staying up to date with the page was difficult so we decided to move to a Slack channel. Our Notion page retired, and we moved to a purely Slack standup.
I recently had the idea of sending the slack messages to a Notion database automatically, which I thought would be super helpful. We only have the free Slack plan, so that means a lot of our past messages have been deleted. Also, there's no way to really go back and sort messages through tags, and Notion is also very helpful to visually see topics.
I had planned on doing this through code, working with the Slack API and the new Notion API. However, after doing some preliminary research, I found Zapier, and figured I'd give it a go.
Creating a workflow in Zapier was super easy. Just connect a couple apps and then you can start creating your integration. It took a little bit (and some help from Ben Potter) to figure out the actions and triggers, but eventually we got it.
Our goal was to take a message from Slack, extract a title, person, date, link to the parent message, and tags and put that into a card in a Notion database. We then wanted a bot to send the link to the Notion page into the thread in Slack, and append any additional threads into the Notion page body. It took a lot of figuring out to extract the right information and put it in the right place, but it wasn't necessarily hard. Zapier made it really easy to do things with zero coding experience.
We were able to figure out almost everything. We did not get to appending additional text to a Notion body, it seems like this is possible in the Notion API using blocks, but Zapier doesn't support blocks in their finite list of notion actions. Additionally, we only set up adding a single tag, so you wouldn't be able to add multiple tags to an item.
Our first thing was to get any new message posted to a certain channel in Slack. We previously had a channel named "standup", so it was as easy as selecting from a dropdown. We also chose for it to not trigger with Bot messages.
Our next two actions were to extract the title. Firstly, we took the first line of the incoming message using the
string.split function. We separated on a newline (using [:newline:], and took the first segment (0).
We also decided to limit the character count in the next action in case someone forgot it was the title. For this, we used
string.truncate and set the max length to 100 characters. The input for this is Step 2, the first line we extracted.
This was definitely the hardest part of the entire process. In order to add a person into the Notion page, Notion wants a specific User ID. However, you can only see the User ID of the admin members of Notion through Notion software. So we had to get creative, and this is what we came up with.
Go to your main Notion page and go to the developer tools using inspect. Navigate into the "Network" tab on the top of the console, and then refresh the page. It should look like this when you're done.
On the left hand side near the blue funnel thingy, there's a search icon. Search a team member username. In our experience, the team members that showed up depended on who's name you searched, so in order to find everyone you might have to search a few different names.
Click on the syncRecordValues request and go into the response tab. Copy all text.
Cleaning up the JSON with a JSON Beautifier makes it easier to understand what we're looking at (we used this site).
Gather all your teammates ID's within the "notion_user" brackets. Again, if all your teammates aren't there, you may have to search a couple different names.
In order to match the Notion ID to Slack user, I found it easier to use the Slack user ID too. You can find this by going into the teammates profile page, clicking on "More" (three dots), and "Copy member ID".
We can now populate our table! In order to create this action, choose "Utilities" for the event, and then "Lookup Table". Your lookup key will be the Slack user ID, and you can populate the table with the Slack IDs in the "key" columns and the Notion ID in the "values" columns.
The following part is extracting the tag. Unfortunately, I was only able to get it to find a single tag, but I think having more than one tag would be possible using the
string.split function with spaces as the split criteria.
The format for this is going to be "Tags: Text", where Notion will only pick up the "Text" part. I thought it would be helpful to have some sort of indicator in the Slack message for the tags, but feel free to leave that out.
We're going to do a similar thing for the title, and split it on a new line, but this time we want to get the second line. I also chose to do a character limit of 25 characters for the tag, and the input value is the output from step 5. In order to have it only pick up on the text after "Tags: ", I skipped 6 characters in action 6.
This next part was a little bit of a fail. The idea was to have it create the database item if it was the parent message or append the message to the item's body if it was in a thread. We were not able to get it to append the thread message, but I'll explain what we went through anyways.
First, we set up a path to be able to conditionally run different steps. We'll start with the original (parent) message.
The first thing we do is check if the message is the parent message. In Slack, the Thread TS (timestamp) does not exist on parent messages, so we'll use that as our criteria.
(note: We had trouble with this because there seems to be different ideas about this on different internet pages. However, this seemed to work, so we stuck with it.)
We can finally create our database item in Notion. For this, you want to chose the Notion app when you make a new action. You'll have to choose an account and database, but you should already have this set up when you set up Zapier.
The name of the event would be the output from step 3, our limit of 100 characters step of the first line. The person will be the output from step 4, the table that we made. The link to Slack will be the Permalink that you can find by searching the 1st step's items. Tags will be the output from step 6, our limit of 25 characters of the second line step. You'll want to add a property item in your Notion (you can hide it) for the TS (there's a type in the title of the Notion property item, it should be "TS" not "Thread TS"). Finally, the content will be the text from step 1.
Finally for the parent message steps, we want to send a channel message in Slack with the link for the Notion page. For this, we can choose the Slack app from the new action page and set up the account and choose our "standup" channel. You can customize the text, and then insert the link made in step 9 for the Notion page. Send as a bot, and set up a name and a custom icon. You can add the TS in the Thread section to have it be messaged in the thread.
For the thread message part, we want to set up the opposite of the parent message, so we will put "if the Thread TS exists".
Next, we need to find the database item in Notion. Choose your account and database, and then use the "Thread Ts" from step 1 to match the thread Ts already inputted in the Notion database item from the parent message.
(note: there's an error here, don't include the permalink in the link section, just use the thread Ts)
Next, we want to update our Notion database item. Again, this didn't actually end up working, but this is what we tried. The item is the thread message from step 2, and you can customize the content added.
This seemed to work on Zapier's end, but Notion wouldn't add it to the body. Seems like its possible with the API using blocks, but Zapier may not yet support that.
And so when you send a message in Slack, it will create an item in the Notion database!
Only... not so yay. Zapier's free plan only allows you do do one step integrations, which I didn't quite realize before setting this up. Amici isn't in the pace to spend $20 a month right now for this feature, so we wouldn't be able to afford the paid plan. All is good though, because now I get to do a part 2 of coding it myself.
These are some things I would have done differently or added if I were to do it again:
- added the beginning actions to the original action to save on action slots
- figured out why it wouldn't append a text body to the end of the notion page
- tried to get it to be able to add multiple tags, separated by spaces or commas
- solely had the body of the message be added to the body of the page using another action, so the title and tags wasn't in the body of the Notion item too
I can't share the Zapier template, but here's the notion template.
This was super fun to do, and I look forward to working with Notion and Slack more. Sorry Zapier 😭