Zapier: A Notion/Slack Integration for Standups
Tags: javascript
Published: 2021-08-27 17:55:01

## Part 1: Trying with Zapier

I currently am working on a project called [Amici](https://amici.ai) 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.  

![Our past Notion standups database](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nz9j311l26hkmcubfzhc.png)

![An example of a Slack standup message](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0hsnq2un4mvl9qt2q2wz.png)

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](https://zapier.com), 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.  

### The steps: 

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.  

![new message posted to Slack](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3huzu8pysy9463ftmdwt.png)  

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.  

![first line](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ilqzryeqzk3lu0mks2zl.png)  
![first 100 characters](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/md9kgwf35xwoi9x0ob9o.png)  

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.  

### Step 1: 
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. 

![network tab](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/psnbfdwok5eb2uvknrm0.png)  

### Step 2: 
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.  

![search](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ox9bzaurdsnv1usngpw8.png)  

### Step 3:
Click on the syncRecordValues request and go into the response tab. Copy all text.

![sync record values](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ueymetgeiv6zt5j7q6r7.png)  

### Step 4: 
Cleaning up the JSON with a JSON Beautifier makes it easier to understand what we're looking at (we used [this site](https://codebeautify.org/jsonviewer)).  

![json beautifier site](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e4uulwesnf49cf9hhnjp.png)

### Step 5: 
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.  

### Step 6: 
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.  

![Name to ID table](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7oz0zgnrtr8ipfl3w6cu.png)  

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.  

![tag, second line](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/412znc9qp15djaj8cav4.png)  

![tag, first 25 characters](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wf0gql5tf2lu3eb7mph2.png)  

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.

![conditionally run path](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dc06an3tg47atvc2u6wr.png)  

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.)  

![if original message](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fyzq7dw19475tstp5d7s.png)  

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.  

![create a database item in Notion](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3v9ui6a6s0d0rotwdyc0.png)  

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.     

![send message to channel in Slack](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ibyobnp2xz98ou1hz9si.png)  

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".  

![if thread message](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8rfi7k0q6ffjhz0nf105.png)  

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)  

![find database item in Notion](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8bbbhfd20ooicl6rdx6u.png)  

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.  

![update database item in Notion](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mbg2u6hc30pnpx4tdp2m.png)  

### This is the final product: 

![entire flow](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sv83r5ycku133euvyj0w.png)  

![flow for parent (original) message](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/110272ncl53ohc3443ga.png)  

![for for thread message](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wwjvosea0wy22unwzg8a.png)  

And so when you send a message in Slack, it will create an item in the Notion database!

![standup Slack message](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o69p0cjd2p8d838y59vj.png)  

![Notion database item](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yufj90iz0x3oytp6x6p0.png)  

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](https://www.notion.so/25bd354bfe6b45a0943f52a4896e661b?v=9ad2a74ee2a44c22b78eb541d75c0f5a). 

This was super fun to do, and I look forward to working with Notion and Slack more. Sorry Zapier 😭