How can I create an Airtable to Wordpress integration with conditional validation to update existing posts?
Guys,
I need to create an integration with Airtable and Wordpress so that I can get the data entered in Airtable and create the post in Wordpress.
The idea would basically be:
1) Get data from Airtable 2) Check if the post exists in Wordpress 3) Conditional validation 3.1) If so, Zapier will just update the information in the existing post. 3.2) If not, Zapier will create a new post
I managed to create a flow that captures the data in Airtable and creates the post, however, if you update any information in the content of the posts already created, Zapier creates a new post instead of updating the existing one.
To try to resolve this issue, in the flow I used:
1) Airtable connection 2) I used the Find Post option to search, which generates a result, but there is no possibility of actually validating whether it exists or not. 3) I tried using "Only continue if...", it even makes sense, but I can't create a negative conditional if it happens.
The objective would be to create in the same flow the process of creating and updating the post if it succeeds or not. Is it possible to do this in the same stream? If so, can you shed some light?
Currently, what's on my mind is creating a flow to create a post and another flow to update.
Page 1 / 1
Hi @wmosquini
Good question.
Try this…
Add another field to Airtable to save the WordPress Post ID when the post is originally created.
Then add logic using Airtable View Filters to know whether to create or update based on whether a Post IDs exists.
Hello, @Troy Tessalone
Thanks a lot for the help.
How would I do this exactly? I think the Zapier sync is one-sided, i.e. it will only do Airtable > Wordpress and will not capture the post ID at this point. To get this ID, I will have to create a second flow, but from Wordpress > Airtable and synchronize the IDs.
I believe that the second flow is carried out by searching the title in Wordpress and then capturing the ID.
I hope this wasn't confusing. lol
@wmosquini
Try testing the WordPress Create Post step and provide a screenshot of the returned data payload.
Hello, @Troy Tessalone
I managed to create the flow where when inserting a new record in Airtable, the flow starts, creates the post, then I search for the record by title and save the ID in the ID column:
Airtable:
However, now comes the tricky part, how to configure the flow to identify whether the Post ID column has any information to differentiate whether to create or update a post in Wordpress?
From what I've observed in tests, the only way to create an action is if the conditional result is true, if it's false, the flow just interrupts.
Taking this into account, is it possible or not to configure the creation and update of the post in the same flow or should I create a specific one for each action?
If possible, can you give me an idea of how to assemble it?
@wmosquini
You can use Airtable Table Views.
Views can have Filters. (e.g. Post ID exists)
Views can be used to trigger Zaps.
Hey @Troy Tessalone ,
Excuse my stupidity, but I don't understand what you mean by Airtable Table Views.
In Zapir, the first trigger is "New or Updated Record in Airtable", in the next trigger, I believe it is "Find Record in Airtable", correct?
If so, in the "Search by Field" field, I select the post ID column in my Airtable, but the question is, how to differentiate whether or not there is a value inserted in the Airtable?
The only option that crosses my mind is the "Search Value" field, but is it possible to validate if the field has a value or not?
@wmosquini
You don’t need step 3.
Instead do this.
In the Table, add a Formula field with this formula: RECORD_ID()
That will show the internal Record ID.
That will then be part of the Zap trigger data payload.
So you can map that ID to Step 4 for the record to Update.
Both Zap triggers can use Views with Filters to show only the relevant records. (w/ or w/o WP Post ID)
1 Zap for Airtable Records w/ WP Post ID
1 Zap for Airtable Records w/o WP Post ID
Hey @Troy Tessalone ,
I understand your idea, however, before executing the "create the post" action I need to validate if the post has already been created in Wordpress.
In my Airtable there is a column that will store the post ID when it is created by Zapier, but this only happens at the end of the entire flow.
When adding a new row in the Airtable, the column (ID) will be blank (empty) by default, being filled in after the post is created, so the creation flow needs to be like this:
1st A new line is added in the Airtable and the "New record in Airtable" trigger is fired. 2nd Use the "find record in" action to search in the ID column of the new line if it has any information. 3rd If the search in step 2 does not find an ID (content), it means that the post is new (or has not yet been created in Wordpress) and the process must continue, that is, create the post. If an ID (content) is found, it means that the post has already been created, so the process must stop immediately.
For the "find record of Airtable" action, there is no option that allows you to continue only if the content of the ID column (Airtable) is just empty.
This is important because I'm going to create another separate flow to synchronize the information of the posts already created in Wordpress > Airtable. As they already exist, I will capture the ID of the posts, so the ID column will already have information. But, as new information is being added to the Airtable (line), the "New record in Airtable" event will be triggered and it is at this point that the validation of the ID column comes into action to prevent the post from being created again, generating duplication.
Any idea?
hey @Troy Tessalone ,
I think I found a solution:
1: Fires when it has a new record (line) 2: Search in the new record if the contents of the ID column 3: With the "only continue if" action, I configured it to continue only if there is no content. 4: Upload media to Wordpress 5: Create the new post 6: Saves the post ID to Airtable.
Taking the test, even separate, worked for me.
Doubt: Is it possible to synchronize the slug (URI) of the post with the "Create post in Wordpress" action?
@wmosquini
You don’t need step 2.
In step 1, you can select a View to limit the records.
In Airtable you can set filters on the View. (e.g. w/ or w/o the Post ID)
You would then have 2 Zaps:
Zap for records w/o Post ID
Used to create new Posts
Zap for records w/ Post ID
Used to update existing Posts
Hey @Troy Tessalone ,
Thank you so much for all the support and help!
I was able to successfully create the entire flow that allows me to create or update posts in Wordpress.
My next step is to create the flow on Webflow, but I'll create another post here on the forum to specifically address that.