Preparations
To follow along with this workshop you’ll need:
- A 46elks account
- A Notion account with admin access to
- A live server to run your script on. Here's how to set one up:
If you would like to setup a DigitalOcean live server, here's a guide on how to.
Or you could use a ngrok link to your local machine, here's a guide for that to.
Or perhaps you have it covered in another way, and that's fine too 😊
Enable the Notion API
In order to enable the Notion API we need to create a integration, here's Notions guide on how to.- Go to My integrations.
- Click the "+ New integration" button.
- Give your integration a name - We can call it "Send SMS"
- Select the workspace where you want to install this integration.
- Click "Submit" to create the integration.
- Copy the "Internal Integration Token" on the next page and save it somewhere secure. Or keep the tab up, we'll come back to this soon
Here's an example of how your integration might look like:

Set up your page in Notion
Now we are going to create our page and add some data to it. Please do the following steps:
- Create a new page and give it a title.
- Create a new text paragraph and write the message that you want to send to your users.
Please note that you must specifically create a paragraph and without linebreaks.
- Create a new inline database.
- Add two properties called “Name” and "Phone number" to the database.
The property names are case sensitive and Phone number must be the text property type in the database. - Add a few entries to the database and you should now have something looking like this:
When you are adding the phone numbers, please ensure they are formatted according to E.164.
- Share your page with your integration as you would any other user.
Set up your script
-
Get the script and save it into a file called
send-sms-notion.php
-
Set the following variables inside the file:
$notion_api_key
is your "Internal Integration Token" you got when you created your integration.$elks_api_user
and$elks_api_pass
is your 46elks API credentials.$from
could be either a phone number or a name.
-
Upload the file to your server. So that the script is available under
your-domain.com/send-sms-notion.php
Test your script
-
In our Notion document we need to copy the ID's of our database and paragraph block.
The URL structure is as follows:- Database:
/{database_id}?v={view_id}
- Block:
/{page_name}#{block_id}
- Database:
- Copy the value for
{database_id}
and{block_id}
in your own URLs. - In your database URL the marked part is our database_id:
https://notion.so/298f3ju21a60442c967fe4c3f3e52402
?v=6wm203e77ab324e38h817b44b84eb1e8 - And in the block URL this part is the block_id:
https://notion.so/Hackathon-abff640fb8274928abc9110527a07fa6#5829ea358di64b3884adef95lk4wuf28
-
Create a link in your Notion document, name it “Send SMS” and link it the following URL:
https://your-domain.com/send-sms-notion.php?database_id={database_id}&message_id={block_id}
- Change
https://your-domain.com
to your own domain. - Remove the curly brackets and change
{database_id}
to your database id. - Remove the curly brackets and change
{block_id}
to your block id.
- Change
Now to the moment of truth: Click on your link and you should have sent a SMS 🥳
Troubleshooting
A few tips for troubleshooting
- If you get the 404 error "object_not_found" while running your script, you’ve probably entered the wrong ID, check the ID's again.
- Have you removed the curly brackets { } around the database_id and the block_id in your link?
- You might have forgotten to share your page with your integration. It never hurts to check it.
- Have you checked that you have used the property type "text" for your phone number in the database in your Notion document? Check just in case.
- Is the phone number that you are sending to formatted according to E.164?
- Here’s a list of all error codes from the Notion API.