Are you looking to send email newsletter to your blog subscribers when a new blog post is published on your site built with Ontraport custom object and dynamic CMS? This step by step guide will take you through the process and automations on how to send latest blog post/podcast updates to your subscribers.
There are mainly 3 steps involved
Step 1 : A new blog post object is created or updated
Step 2 : The above update triggers a webhook to update an Contact Owner field
Step 3 : The above Contact Owner field update triggers an automation in Contact object to add contacts as blog subscribers.
If you are already an Ontraport user, you probably know that you'd need a custom object created for blog posts or podcast episodes.
Everything is an object in Ontraport. "Contact" is the most used object. Ontraport also comes with Deals, Company, Virtual events and other pre-built objects. So any object that didn't come pre-built which you have created to suit your requirement can be called as a custom object.
For example, Ontraport doesn't come with pre-built objects to support Podcasts. Even though it doesn't have that, you can build it because Ontraport is a very flexible system where you can build anything you want depending on your business process.
So all you have to do is create a new custom object according to your requirement and create appropriate relationship between the objects.
In this particular case, where we create blog posts and send out the email updates, we have to switch on the blog post app to create that object or to create a custom object like Podcast episode. Then create a relationship between the objects that you'd want to connect.
That would be Blog post object and Contacts object in the case of sending newsletters to the blog subscribers.
Let's get into the steps and see how it is done.
First thing is to create the custom object. So let's call the custom object as "Blog"
[Note: Ontraport provides a built in Blog post custom object. So you don't have to create it. You just have to turn it on from the Apps section]
Go to Your Account >> Admin >> Custom Objects >> New Object
Follow the prompts to create the new custom object.
In the next step you will be asked to create a relationship.
The relationship that we want to set up is a Many to Many relationship between our custom object - Blog and Contacts. We create new sections called Blog subscribers in the Blog side of records and 'Blog posts received' section in the contact side of records.
Now we have a new custom object and its corresponding relationship with the contact object, ready. The biggest task now is to make these two unrelated custom objects to talk to each other.
Since this is a Many to Many relationship, there are no parent-child relationship between these objects. So it is not like if something changes, the change is reflected back to its parent or child object. The only way to make them speak to each other is through some API calls via webhooks. Let's see how it is done.
We are going to connect our custom object-Blog to Contacts via making a connection to Contact Owner record.
We can trigger a contact automation based on Contact owner field update. Hence we are sending that webhook to contact owner records.
In order to do that, the first thing we need to do is to create a custom field in Contact owner fields.
Go to Admin >> User Management >> User Field Editor >> Add a new field
Let this new field be numeric so that we can store the new blog ids.
Now we need to send webhook to update this field from Blog custom object.
For everything Ontraport API, you first go to LIVE API Tool Ontraport created and look for Users object. As we have to update the record, we select PUT method.
There you will see that we are required to fill out a bunch of mandatory fields. To get these values, you can either go to the contact owner record details and find the values there. Or else, you scroll up to find the Get/ User method and give the ID of the user (usually 1 as it is contact owner) and click Try it out button.
When you get the required values, insert them at its required fields along with a dummy value for the new custom field we've created earlier on Contact owner record.
Once these values are filled out, click "Try it out' button to generate the data.
Please do keep in mind that, this will actually update the Contact owner fields with the value that you are entering. So do check the values you're inserting there.
So when we try it out, we get a similar screen as above. You can see that only "id" and the new custom field we created are sent as data in the body. All other details such as mail name, role id, master id etc are sent in the header section of the webhook.
We have to follow the same procedure when we are creating the webhook in the automation
We are going to send the webhook from the Blog/Podcast custom object to contact. So we have to set up this automation inside Blog custom object.
Pick an appropriate trigger. If you want to send an email when new post is created, that could be a trigger. If you have different process like under review, ready to publish, published etc, you can create a trigger based on these stages.
Once the trigger is set, we need to set up the webhook.
Request URL : https://api.ontraport.com/1/Users
Webhook Method : PUT
Header : App-id, api-key, mail_name, reply_to_email, firstname, lastname, role_id and master_id details.
Data to send : Something similar as shown in the above image. But make sure, you are sending the blog post id details to contact owner update field. (In this case the episode number and ID are the same)
These steps should update the contact owner when the trigger fires. Run a test to see if it works as expected.
Now we have contact owner field getting updates whenever a Blog trigger gets activated. So we will use "Contact owner field gets updated" as the trigger in Contact Automation.
So we will load all the contacts who are blog subscribers to an automation map and keep them on a wait element forever. Then we will add a trigger which will then add them to a webhook to add them as a subscriber under our newly created custom object : Blog.
You can see from above screenshot that when the contact owner field gets updated, it will add the contacts on to the map to a webhook.
Now the question is how to create the webhook that will add contacts as subscriber to the latest blog post. Let's look at that
Note : Trigger should be "Anyone on this map" and "Add here when triggered"
When a Many to Many relationship is created, Ontraport actually creates an intermediate object which connects both objects.
In my case, the intermediate object is called "PodcastListeners/EpisodesSubscribedto"
Since we are adding the subscribers. we can use POST method. You can see it needs only 2 parameters for the POST method and they are the Blog post/podcast id and contact id.
So if we can send these two values via webhook to this intermediate object, it will add the contacts as subscribers.
Now we need to provide these values and need to know where to find these values. Remember that we are creating this automation under contact automation. So from where do we get the Blog post/podcast id?
Hope you remember that we were sending a value to update the contact owner field. The value we sent to contact owner update field was the blog post id. So by referring to this field, we can get the value for blog post id. Contact Id value can be directly available from contact field.
By using merge fields we can send the data as shown in the above screenshot.
When triggered, this webhook will add contacts under each blog posts. Do a test run and see this in action.
Now that we have contacts added to the latest blog posts, we can send them the email with blog updates.
In order to do that, you can add a wait element after the webhook in the Blog Post/Podcast automation and make the people wait for either a certain time or until a certain time arrives and send that email.
Regarding the email, all you have to do is create an email template using the merge fields from Blog Post custom field values.
Here is a very simple example.
Once this is set up, whenever there is a new update, this email will be dynamically generated and send the subscriber the latest updates.
Let me know if you tried it by yourself. If you are finding it difficult to implement, get in touch and we can sort it out together. Send me a message from Ontraport Consultation page.