Skip to main content

Hi all, I work for a local health department in Utah. Every winter, we have bad air quality (also known as inversion season; some days are worse than others).

We’d like to figure out how we can use the data from our state’s air quality agency (this page to be precise—https://air.utah.gov) narrowed to our county (Salt Lake County) to send out a daily Tweet in the morning to inform the public about that day’s air quality. This is the information the Tweets would include, depending on the air quality:

#AirReport: Right now, #SLCo air quality is GOOD. Wood burning is ALLOWED.

#AirReport: Right now, #SLCo air quality is MODERATE. Wood burning is NOT ALLOWED.

#AirReport: Right now, #SLCo air quality is UNHEALTHY FOR SENSITIVE GROUPS. Wood burning is NOT ALLOWED.

To add an extra layer of complexity, we would also like to have these daily Tweets go out in Spanish. Not sure what activity or task could act as the trigger for the Zap, but we know the data from https://air.utah.gov is updated hourly. I’m a Zap newbie so I very much appreciate and welcome all wisdom!

Hi @gmoreno!

This is an excellent idea for a Zap!

I have a couple of questions for you to best answer your question:

  1. Are those the only three statuses that will ever be displayed (and with that exact wording for good, moderate, and unhealthy)?
  2. You mentioned wanting to post once per day, but then referenced the hourly updates. You can definitely set it up to go whenever you want (once per day at a specific time, twice per day, every hour, etc.) It’s up to you!
  3. Would the Spanish version of the Tweet appear separately from the English version? In a different account? Or just both together in one Tweet?
  4. The solution is very likely to require a paid Zapier account. Is that okay?

Hi @gmoreno!

This is an excellent idea for a Zap!

I have a couple of questions for you to best answer your question:

  1. Are those the only three statuses that will ever be displayed (and with that exact wording for good, moderate, and unhealthy)? Yes, those three statuses are the ones we would be sending out depending on the air quality that day, word by word.
  2. You mentioned wanting to post once per day, but then referenced the hourly updates. You can definitely set it up to go whenever you want (once per day at a specific time, twice per day, every hour, etc.) It’s up to you! Gotcha! We’d only post the status one time each day, ideally early in the morning.
  3. Would the Spanish version of the Tweet appear separately from the English version? In a different account? Or just both together in one Tweet? Thinking about this now that you ask, it would probably be better for us to include both languages on each Tweet (just tested the length of characters and thankfully they all fit). We’d also like to include a graphic along with each Tweet. Here is the exact copy in English and Spanish for each air quality status:
     

    #AirReport: Right now, #SLCo air quality is GOOD. Wood burning is ALLOWED.

    #ReporteDelAire: En este momento, la calidad del aire en #SLCo es BUENA. Se permite la quema de leña.

     

    #AirReport: Right now, #SLCo air quality is MODERATE. Wood burning is NOT ALLOWED.

    #ReporteDelAire: En este momento, la calidad del aire en #SLCo es MODERADA. NO SE PERMITE la quema de leña.

     

    #AirReport: Right now, #SLCo air quality is UNHEALTHY FOR SENSITIVE GROUPS. Wood burning is NOT ALLOWED.

    #ReporteDelAire: En este momento, la calidad del aire en #SLCo es INSALUBRE PARA GRUPOS SENSIBLES. NO SE PERMITE la quema de leña.

  4. The solution is very likely to require a paid Zapier account. Is that okay? Totally!

Hey @Todd Harper, thanks for your response! See my answers above!


Hi @gmoreno,

Those are all the answers I was hoping you’d give!

Here’s how I would recommend achieving this (I’ve also created a test version of this to be sure Utah’s RSS feed behaves as I expect it to...so standby for confirmation).

  1. Set up an RSS by Zapier trigger with the event set to New Item in Feed and use feed URL https://air.utah.gov/rssCurFeed.php?id=slc (this is the RSS version of the site you referenced). Leave username and password blank.
  2. Insert a Filter by Zapier step to only continue if the title contains the hour you want to use for determining the day’s air quality, which should be at least two hours before the time you want to post (ie. 04:00).
     

     

  3. Insert a Code by Zapier step and select Run Javascript. On the action setup screen, type “Content” in the left box under input data, and select the description from step 1 for the right box (as in the screenshot below). Then copy and paste in the following code.
     
    const CONTENT = inputData.Content;

    var ozone = CONTENT.split("Ozone: ")C1].split(" ")"0];
    var pm25 = CONTENT.split("PM 2.5: ")O1].split(" ")P0];
    var airQuality = "";
    var message = "";

    if (ozone <= .054 && pm25 <= 12) {
    airQuality = "good";
    message = "#AirReport: Right now, #SLCo air quality is GOOD. Wood burning is ALLOWED.\n\n#ReporteDelAire: En este momento, la calidad del aire en #SLCo es BUENA. Se permite la quema de leña.";
    } else if (ozone >= .071 || pm25 >= 35.5) {
    airQuality = "bad";
    message = "#AirReport: Right now, #SLCo air quality is UNHEALTHY FOR SENSITIVE GROUPS. Wood burning is NOT ALLOWED.\n\n#ReporteDelAire: En este momento, la calidad del aire en #SLCo es INSALUBRE PARA GRUPOS SENSIBLES. NO SE PERMITE la quema de leña.";
    } else {
    airQuality = "moderate";
    message = "#AirReport: Right now, #SLCo air quality is MODERATE. Wood burning is NOT ALLOWED.\n\n#ReporteDelAire: En este momento, la calidad del aire en #SLCo es MODERADA. NO SE PERMITE la quema de leña."
    }

    output = b{message, ozone, pm25, airQuality}];
  4. Optionally insert a Delay by Zapier step to hold off on posting to Twitter until a desired time. In the filter above, I used 4am to determine the day’s air quality. By default, this will actually trigger your Zap at 6am (confusing, I know, but I don’t make the rules, I just make workarounds), but perhaps you don’t actually want to post to Twitter until 6:20am. You can post that here. Or if you’d like to randomize the time slightly to make it feel less robotic, let me know and we can add that to the code step above.
     

     

  5. Finally, insert a Twitter action and set the event to “Create Tweet”. The message should be the message generated by the code step, the image should be the URL link to the image you’d like to include with the post. Do you want the photos to be dynamic in some way? Like if the air quality is good, you display a random image or GIF frohttps://giphy.com/search/wood-fire? Or just a single pre-determined image for each of the three statuses? Or did you want the same graphic with every post?


@gmoreno what an interesting use case! DM’ing you to learn more about how you’re using Zapier ⚡️ Hoping Todd’s workflow suggestion above helps you get this up and running. 

@Todd Harper love this flow & LOVE the idea of adding a weather GIF to the tweets!


Okay, can confirm that the Zap works as described 🙂 BUT, as the RSS feed updated each hour over night, it appears the delay is about 2 hours, 25 minutes, not just 2 hours. I’m one hour ahead of you, and as you can see in the screenshot below, the 4am data ran at 7:25am (so 6:25am MST).

What this means is that if you DON’T use the Delay by Zapier step, you can expect your Tweet to go out about 2 hours, 25 minutes after the time set by your Filter by Zapier step. If you DO use the Delay by Zapier step, you will need to set it for a time at least 2 hours, 26 minutes after the time set by your Filter by Zapier step (ie. if you want to post at, say, 7:12am, you would set the Filter step to “04:00” and the Delay step to “7:12am”).

 


Hey yall,

Thanks for the help on this -- some great help going on here.

With regards to the RSS delays, I can confirm that a Free plan will check every 15 minutes for new data.  There may be a little drift to that (in that we might check a little before or after EXACTLY 15 minutes), but not much.  If there are real delays going on here that are not attributable to some sort of time zone oddities, that would suggest that the RSS feed is not being updated in real time.

Another interesting thing to mention about Delay is you can use human-readable language as input (any field marked with a date/time symbol supports this and other special functionality), so you could input “Two hours” instead of a “real” date/time string as input and we usually parse that correctly! =)  


Hi @gmoreno,

Those are all the answers I was hoping you’d give!

Here’s how I would recommend achieving this (I’ve also created a test version of this to be sure Utah’s RSS feed behaves as I expect it to...so standby for confirmation).

  1. Set up an RSS by Zapier trigger with the event set to New Item in Feed and use feed URL https://air.utah.gov/rssCurFeed.php?id=slc (this is the RSS version of the site you referenced). Leave username and password blank.
  2. Insert a Filter by Zapier step to only continue if the title contains the hour you want to use for determining the day’s air quality, which should be at least two hours before the time you want to post (ie. 04:00).
     

     

  3. Insert a Code by Zapier step and select Run Javascript. On the action setup screen, type “Content” in the left box under input data, and select the description from step 1 for the right box (as in the screenshot below). Then copy and paste in the following code.
     
    const CONTENT = inputData.Content;

    var ozone = CONTENT.split("Ozone: ")C1].split(" ")"0];
    var pm25 = CONTENT.split("PM 2.5: ")O1].split(" ")P0];
    var airQuality = "";
    var message = "";

    if (ozone <= .054 && pm25 <= 12) {
    airQuality = "good";
    message = "#AirReport: Right now, #SLCo air quality is GOOD. Wood burning is ALLOWED.\n\n#ReporteDelAire: En este momento, la calidad del aire en #SLCo es BUENA. Se permite la quema de leña.";
    } else if (ozone >= .071 || pm25 >= 35.5) {
    airQuality = "bad";
    message = "#AirReport: Right now, #SLCo air quality is UNHEALTHY FOR SENSITIVE GROUPS. Wood burning is NOT ALLOWED.\n\n#ReporteDelAire: En este momento, la calidad del aire en #SLCo es INSALUBRE PARA GRUPOS SENSIBLES. NO SE PERMITE la quema de leña.";
    } else {
    airQuality = "moderate";
    message = "#AirReport: Right now, #SLCo air quality is MODERATE. Wood burning is NOT ALLOWED.\n\n#ReporteDelAire: En este momento, la calidad del aire en #SLCo es MODERADA. NO SE PERMITE la quema de leña."
    }

    output = b{message, ozone, pm25, airQuality}];
  4. Optionally insert a Delay by Zapier step to hold off on posting to Twitter until a desired time. In the filter above, I used 4am to determine the day’s air quality. By default, this will actually trigger your Zap at 6am (confusing, I know, but I don’t make the rules, I just make workarounds), but perhaps you don’t actually want to post to Twitter until 6:20am. You can post that here. Or if you’d like to randomize the time slightly to make it feel less robotic, let me know and we can add that to the code step above.
     

     

  5. Finally, insert a Twitter action and set the event to “Create Tweet”. The message should be the message generated by the code step, the image should be the URL link to the image you’d like to include with the post. Do you want the photos to be dynamic in some way? Like if the air quality is good, you display a random image or GIF frohttps://giphy.com/search/wood-fire? Or just a single pre-determined image for each of the three statuses? Or did you want the same graphic with every post?

@Todd Harper, thank you so, so much for these detailed instructions! I think we’re going to opt for not using a Delay (we don’t think the AQI will change too much from the time it’ll pull the data from the RSS, through the 2 hours and 25 minutes delay when the Tweet would go out).

I’m now waiting on my graphic designer to finish up the three graphics for each AQI status. How do you recommend setting the last step with the Twitter action so that based on whatever AQI status is pulled from the RSS feed at the time, it’ll select the right graphic? 


Hey @gmoreno!

In the Code Step Todd wrote for you, you could add in a string like so along with the URLs to the images under the “airQuality” in each section:

image = "https://www.yoururl.com/image.png";

Replace the URL there with a link to the image you want to use -- be sure to use a direct URL to the image file and not a page in which the image is embedded!

Then, modify the output setting like so to pass out that image URL:

output = u{message, ozone, pm25, airQuality, image}];

Thanks again to Todd for such excellent help!

 

EDIT:  Oops, forgot to initialize the variable!  Under the list of “var” up top, also add the string:

var image = "";

 

👋


Hey @gmoreno!

In the Code Step Todd wrote for you, you could add in a string like so along with the URLs to the images under the “airQuality” in each section:

image = "https://www.yoururl.com/image.png";

Replace the URL there with a link to the image you want to use -- be sure to use a direct URL to the image file and not a page in which the image is embedded!

Then, modify the output setting like so to pass out that image URL:

output = u{message, ozone, pm25, airQuality, image}];

Thanks again to Todd for such excellent help!

 

EDIT:  Oops, forgot to initialize the variable!  Under the list of “var” up top, also add the string:

var image = "";

 

👋

Thank you for that info! One thing that I realize I will need to update on the Code by Zapier step is adding another message for a fourth category (that I totally spaced out). We have the following: good, moderate, unhealthy for sensitive groups, and unhealthy. Below are the actual Tweet messages in English and Spanish; I’m wondering how should my code reflect this change? Also, sharing with you the URL for each corresponding graphic, what would my code string look like with these as variables?

https://slco.org/globalassets/1-site-files/health/programs/air/aqi_green.jpg

https://slco.org/globalassets/1-site-files/health/programs/air/aqi_yellow.jpg

https://slco.org/globalassets/1-site-files/health/programs/air/aqi_orange.jpg

https://slco.org/globalassets/1-site-files/health/programs/air/aqi_red.jpg

 

#AirReport: Right now, #SLCo air quality is GOOD. Wood burning is ALLOWED.

-

#ReporteDelAire: En este momento, la calidad del aire en #SLCo es BUENA. Se permite la quema de leña.

 

#AirReport: Right now, #SLCo air quality is MODERATE. Wood burning is NOT ALLOWED.

-

#ReporteDelAire: En este momento, la calidad del aire en #SLCo es MODERADA. NO SE PERMITE la quema de leña.

 

#AirReport: Right now, #SLCo air quality is UNHEALTHY FOR SENSITIVE GROUPS. Wood burning is NOT ALLOWED.

-

#ReporteDelAire: En este momento, la calidad del aire en #SLCo es INSALUBRE PARA GRUPOS SENSIBLES. NO SE PERMITE la quema de leña.

 

 

#AirReport: Right now, #SLCo air quality is UNHEALTHY. Wood burning is NOT ALLOWED.

-

#ReporteDelAire: En este momento, la calidad del aire en #SLCo es INSALUBRE. NO SE PERMITE la quema de leña.