Sendgrid won't send because Airtable is empty

I have a flow that checks an Airtable Table and then sends the list of records to an email recipient using Sendgrid. The issue is, if the Airtable has no records for that day the flow throws an error because it has no columns to merge and therefore an email isn’t sent. What would be the best way to send an email essentially saying “no news for today” if the Airtable is empty?

Hmm I wonder if you could use the If/Else step to accomplish this. If a value in a particular column is blank, you can replace it with a value like “No news for today” and that would send in replacement of the usual records.

It doesn’t allow for a completely different Sendgrid email template, but it might address the problem?

Thanks Sachi! I’ll give that a try, could work potentially!

Tough one @sachi, I tried, but the issue I’m seeing is that without any data in the Airtable when it imports there aren’t any rows for the If/Else to reference (ie. If “Id” is “Blank”) – I tried creating a row, but can’t figure out how to connect it back to the main flow that leads to SendGrid.

Hey Tessa - this one is a little annoying to work around. You need to upload a CSV that just has a single row of data - the headers that your Airtable would normally bring in. Pull in that, and then send it into a Stack tables step. Send the Airtable data into that Stack tables step as well, as the 2nd arrow. When Airtable data comes in, it will work as normal, and when it does not come, these headers will be used. Make sure every header you need in your flow is present. From there, you can use a Remove rows step to keep all rows that are not blank in the ID column and process them as normal. In a separate path, use a Remove rows step to keep all rows that are blank in the ID column - this will also always be 0 rows, but you will have column headers. From there, use an Insert rows step to add a row of data to use to indicate that no news is available and use another export for that branch.

1 Like

Thanks Brian! The only issue I’m seeing is that both paths will always execute—whereas if there is data to send, I don’t always want an email to come through with no news for the day.

Ah good point. In that case, I think you will need to add some logic to only add that row if there really is no data. Perhaps branch off the part of the flow where you are sending news, and count the rows, and if it comes back as 0, then add the row to the other branch of the flow, and if there are rows, then keep that other branch at no rows.

If the export has 0 rows it should not actually export (either of them)