Easily restore your project to a previous version with our new Instant One-click Backup Recovery

Get Notified by SMS when a new Content Entry is Ready for Review

In this tutorial, we will build a SMS notification workflow for growing content teams using Pipedream and Twilio.
Jamie Barton

Jamie Barton

Feb 14, 2022
get-notified-by-sms-when-content-entry-read-for-review

As your content team grows, you will likely create a process for publishing content with multiple stakeholders. You may currently copy/paste links from preview URLs or to the Hygraph UI to ask for a review from your team, but today I will show you a quick and easy way to automate this process.


Hygraph provides Content Stages that let you publish content to multiple stages. Every project comes with DRAFT and PUBLISHED. We see many teams create stages for QA and RFR (Ready for Review) as well.


In this post, we’ll work with the base DRAFT stage, which is available on our free tier, so even if you aren’t paying for custom content stages, you can benefit from this guide. If you’re on a paid plan, you can alter this guide to work with any custom content stage, as we’ll see later…


We’ll be using the low-code API platform Pipedream that lets us connect multiple triggers and sources.


You’ll need to create an account with these providers to continue:

#Step 1: Create a new Pipedream Workflow

Once logged into Pipedream, you’ll want to create a new workflow.


From here, select HTTP API from the available triggers.


Pipedream add a trigger


Once added, you’ll be given a unique immutable endpoint for your HTTP trigger. You’ll need this to connect Hygraph.

#Step 2: Connect Hygraph

Before we continue configuring the Pipedream workflow, let’s create a webhook inside Hygraph using the URL to our Pipedream trigger.


Once logged into Hygraph, Create a new Webhook.


You’ll want to name it, give it an optional description, enable including the payload, and set the URL to be the same as what Pipedream gave for the HTTP trigger.


Then, you’ll want to configure the Hygraph triggers. These triggers are the conditions that will invoke the webhook, and send the payload to Pipedream in a request.


We’ll configure the webhook, so when new Episodes are Created in the Draft stage by a Project member, it will trigger the specified URL.


Configure Hygraph webhook

#Step 3: Send Test Trigger

Now, we will create a new Episode in the Draft stage to trigger the webhook. You’ll see why this is helpful when configuring the Pipedream workflow with autocompletion on our payload data.


Head over to the content model you selected inside of the Content Editor, and Save a new entry. Hygraph by default will Save this to the Draft content stage.


Save new draft


You should now see inside of Pipedream a new event you can inspect:


View Pipedream event trigger payload

#Step 4: Connect Twilio to Pipedream

Next, we can use the results from the test above to check our workflow trigger is working, and we can now connect Twilio.


You’ll need to create a new Twilio API Key, and know your Account SID to add Twilio.


Inside your new Pipedream workflow, you’ll want to click the + to add another stage in your workflow.


From the list of available actions, search for Twilio, and select Send SMS:


Add Twilio to workflow


Twilio send SMS action


Next from the Twilio Account area, you’ll want to Connect Twilio.


Connect Twilio


Here you will now need to add your API Key SID + Secret, and Account SID. Follow the instructions in the modal to learn how to create an API Key.


Connect Twilio API keys

#Step 5: Configure Twilio Message Contents

Now that Twilio is configured and ready to go, we can set the contents of our message to include a link to a preview of the new content entry.


Where you send people to preview your post is entirely up to you. Here I’m using a staging subdomain that has Hygraph API access to fetch from the Draft stage, so I know that when I send this link to someone, they’ll be able to see what I have just saved inside of Hygraph.


You could opt to send a Next.js Preview Link, or link them to the Hygraph content editor itself.


You’ll need to set the From phone number you created in your Twilio account and who this message is sent To.


You could add a field inside of your Hygraph content model to include a phone number, but for the purposes of this post, let’s add a static phone number.


Then, all that’s left to do is set the Message Body. Here you can include a custom message, AND use special characters to inject content from the payload sent from Hygraph.


Here you can see I’m using {{event.body.data.slug}} which will include the slug of the new Episode I created.


Twilio send sms body


Now all that’s left to do is Save & Deploy.


Deploy and save


#Step 6: Try it out!

Now all that’s left to do is head over to Hygraph; and create a new content entry, save it, and wait for the message to arrive!


Save new draft


A few moments later…


Success SMS

Success!

Blog Author

Jamie Barton

Jamie Barton

Jamie is a software engineer turned developer advocate. Born and bred in North East England, he loves learning and teaching others through video and written tutorials. Jamie currently publishes Weekly GraphQL Screencasts.

Share with others

Sign up for our newsletter!

Be the first to know about releases and industry news and insights.