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 automate this goal, I created an n8n workflow that sends a poem translated into Romanian in my Telegram chat every day. In this tutorial, I’ll show you how to set it up in four steps.
The no-code 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.
This workflow consists of four nodes:
- Cron node: triggers the workflow every day at 10:00. You can change the time and interval based on your use case.
- HTTP Request node: makes an HTTP request to the Poemist API that returns random poems.
- LingvaNex node: translates the returned poems into Romanian. You can choose from over 100 languages.
- Telegram node: posts the translated poems in the chat.
Now let’s see how to set up each node.
1. Schedule the workflow
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.
2. Get poems from Poemist
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.
3. Translate poems with LingvaNex
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).
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.
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.
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.
Now execute the whole workflow and check your Telegram for an incoming message:
Finally, save and activate the workflow, so that it runs every day at the scheduled time.
What’s next?
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.
This post was originally published on the the n8n blog.