APIs & Integrations

Grigorii
Member

Creating a letter by condition

I am trying to create a notification letter from the datocms website about a new blog entry. I can do it. But I need to create an email only for certain blog categories. Is it possible to create a condition for creating a letter? For example, if the property is "true", create a letter, if not, do not create.

I use this url from api to creating email 

https://api.hubapi.com/marketing-emails/v1/emails

 

0 Upvotes
1 Reply 1
SSukys
Contributor | Elite Partner
Contributor | Elite Partner

Creating a letter by condition

Hello  @Grigorii,

 

Great question!

 

I would make a request to the following endpoint:

 

POST/cms/v3/blogs/posts/batch/read 

 This returns a list of blog articles. You can filter this, for example, so it is only the most recent 5 blog entries that are returned. This returns the follow JSON response:

 

{
"status": "PENDING",
"results": [
{
"id": "string",
"slug": "string",
"contentGroupId": "string",
"campaign": "string",
"categoryId": 0,
"state": "string",
"name": "string",
"mabExperimentId": "string",
"archived": true,
"authorName": "string",
"abTestId": "string",
"createdById": "string",
"updatedById": "string",
"domain": "string",
"abStatus": "master",
"folderId": "string",
"widgetContainers": {
"additionalProp1": {},
"additionalProp2": {},

 

You can take the "categoryId" response and conditionally send an email based on that category. This will ensure you are only triggering the next step to send the email when the category is correct.

 

I hope this helps! If you have any more questions I am happy to work through it with you.

0 Upvotes