All challenges

Challenge 02

Air Quality in Valencia

Reply to any TelegramTelegram is a messaging app that works on phones, computers, and the web. message with fresh air-quality data from any available station.

BeginnerComplexity:Time: 20–30 min

Your task

Create a Telegram botA Telegram bot is an automated Telegram account that can receive messages and send replies. that replies to any message with fresh air-quality data. Fetch the data each time and return the air-quality rating and all available NO₂Nitrogen dioxide (NO₂) is a gas produced mainly by road traffic and other fuel combustion. This value is reported in micrograms per cubic metre (µg/m³)., PM10PM10 means airborne particles that are 10 micrometres wide or smaller. This value is reported in micrograms per cubic metre (µg/m³). and PM2.5PM2.5 means fine airborne particles that are 2.5 micrometres wide or smaller. They can travel deeper into the lungs than PM10 and are reported in µg/m³. measurements from any one station in the same chat. Any station is fine. The message can say anything or contain a photo or sticker; you do not need to read or parse its content.

Your bonus task

Use the VALÈNCIA CENTRE station specifically. Add ✅ when its rating is Buena or Razonablemente Buena, and ⚠️ for any other rating. Keep replying to incoming messages, and also send a fresh update automatically every six hours to your own TelegramTelegram is a messaging app that works on phones, computers, and the web. account using one fixed private chat ID, even when no one messages the bot.

Example use cases

  • A resident wants to check the latest air quality in central Valencia without searching it on Google.
  • An event organizer wants to check local air quality before choosing an outdoor meetup spot.
  • A neighborhood group wants a quick TelegramTelegram is a messaging app that works on phones, computers, and the web. air-quality update it can share with community members.
  • Residents could use the same workflow pattern to request information from Valencia Open DataValencia Open Data is the website where Valencia City Council publishes public information for people and apps to reuse.'s nearly 300 public datasets through a familiar messaging app such as TelegramTelegram is a messaging app that works on phones, computers, and the web. or WhatsApp.

Before you start

  1. 01

    Sign up for n8n Cloud or open an existing n8n workspace, then create a new workflow.

  2. 02

    Install Telegram, then create or sign in to a Telegram account.

  3. 03

    Create a Telegram bot with BotFather, then add its token as an n8n credential.

  4. 04

    The Valencia City Council air-quality endpoint provides real-time data. Keep it ready to use in your HTTP Request node.

  5. 05

    For the bonus, send your bot a private message once and copy message.chat.id from Telegram Trigger. Use that fixed ID as the recipient of scheduled updates. Configure the Schedule Trigger and publish the workflow to enable automatic runs.

What the workflow must do

  1. 01

    Any incoming message triggers a fresh request and a reply to the same chat, without checking its text or requiring a command. Test with two unrelated messages, such as a greeting and a sticker. Each must receive a reply based on newly fetched data.

  2. 02

    The core reply includes the air-quality rating and every available NO₂Nitrogen dioxide (NO₂) is a gas produced mainly by road traffic and other fuel combustion. This value is reported in micrograms per cubic metre (µg/m³)., PM10PM10 means airborne particles that are 10 micrometres wide or smaller. This value is reported in micrograms per cubic metre (µg/m³). and PM2.5PM2.5 means fine airborne particles that are 2.5 micrometres wide or smaller. They can travel deeper into the lungs than PM10 and are reported in µg/m³. value from any one station; a missing measurement may be omitted or shown as unavailable.

  3. 03

    For the bonus, select VALÈNCIA CENTRE by its address rather than its row position and apply the rating emoji to both replies and scheduled updates. For the bonus, publish a six-hour schedule that fetches new data and sends it to one fixed private chat ID. Test the scheduled branch independently of an incoming message.

Solution

See the workflow challenge answer

Reveal the completed workflow only when you are ready to compare it with your own.

Submit as solved

Ready to submit?

Submit when your team has a working workflow to demonstrate.

Solution

Reveal the workflow solution?

This will show the completed workflow for this challenge. Are you sure you want to continue?

Mentor review

Find a mentor and ask them to review.

Show them your working workflow. Once they approve it, collect the balloon for this challenge.