DEV Community

Cover image for Celebrating World Poetry Day with a daily poem in Telegram πŸ“œ
Lorena for n8n

Posted on

Celebrating World Poetry Day with a daily poem in Telegram πŸ“œ

March 21st is World Poetry Day, a day dedicated to one of the most treasured ways of expression around the world and linguistic diversity. I have always loved reading poetry with creative rhymes and melodic rhythm, and lately I have come to appreciate free verse poetry as well. In any case, I would like to make time to read more poetry and discover new international poets. To achieve this goal, I created an n8n workflow that sends a poem translated into Romanian in my Telegram chat every day. In this article, I'll show you how to set it up.

Workflow

If this is your first n8n workflow, have a look at our quickstart guide first to learn how to install n8n. Once you have your n8n Editor UI open, there are two ways to follow this tutorial: either copy the workflow from here into your Editor UI and deactivate the nodes, so that you can execute and test each node separately, or add the nodes one at a time.

n8n Editor UI showing the workflow

This workflow consists of four nodes:

  1. Cron node: triggers the workflow every day at 10:00. You can change the time and interval based on your use case.
  2. HTTP Request node: makes an HTTP request to the Poemist API that returns random poems.
  3. LingvaNex node: translates the returned poems into Romanian. You can choose from over 100 languages.
  4. Telegram node: posts the translated poems in the chat.

Now let's see how to set up each node.

1. Set the time

First, you need to set the time and interval at which you want to receive poems in the chat. For this, set up the Cron node, where you can choose from seven modes and set the exact hour and minute*.* For this example, the workflow will be triggered every day at 10:00.

n8n Editor UI showing the setting for the Cron node

2. Get the poems

Now, you need to get the poems. For this, set up the HTTP Request node to get data from Poemist. Paste the Poemist URL and execute the node to test that it's working.

n8n Editor UI showing the setting for the HTTP Request node

3. Translate the poems

The Poemist API includes poems in different languages, which on one hand is great for linguistic diversity, but on the other hand it can be challenging if you don't know the language.

To make sure you can read all poems, translate them into a language of your choice using the LingvaNex node. For this, you need to sign up on LingvaNex to get credentials. You can find detailed instructions here. Copy your credentials in LingvaNex API, then set Translate to Romanian (or any other language you prefer).

n8n Editor UI showing the setting for the LingvaNex node

In the Text field, select:

  • The title: Current Node > Input data > JSON > 0 > title
  • The author: Current Node > Input data > JSON > 0 > poet > name
  • The poem: Current Node > Input data > JSON > 0 > content

Now execute the node to test that it's working.

n8n Editor UI showing the expression setting for the LingvaNex node

4. Send poems to Telegram

Finally, you need to send the requested poems to your Telegram chat. In your Telegram account, start a chat with Botfather and follow the instructions to create a bot and get credentials. Then, go to the Telegram node and add the credentials to Telegram API.

Next, you need to fill in the Chat ID of the newly created bot. There are two ways to get your Telegram Chat ID: with the Telegram Trigger node or with a Telegram bot. You can find instructions for both methods here.

n8n Editor UI showing the setting for the Telegram node

After completing the Chat ID, you need to set up the text you want to send to the chat. Open the Text field and select the poem translation from Current node > Input Data > JSON > result. You can add more text or emojis to prettify the message.

n8n Editor UI showing the text field setting for the Telegram node

Now execute the whole workflow and check your Telegram for an incoming message:

Message of a poem in a Telegram chat

Finally, save and activate the workflow, so that it runs every day at the scheduled time.

Next steps

That was it! Now you know how to get international poems, translate them, and send them to a Telegram chat to get your daily dose of poetry. If you run into issues while following this tutorial, you can message me on Twitter or ask for help in our community forum. Feel free to tweak and extend this workflow as you please and share your ideas with us on Twitter 🧑

This post originally appeared on the n8n.io blog.

Top comments (2)

Collapse
 
spiritupbro profile image
spiritupbro

wow cool didn't platform like this exist cool stuff

Collapse
 
lorena profile image
Lorena

Glad you find it interesting!