Telegram bot message chain

Hello!

I have a question when creating a bot for Telegram:

I want to write a chain of messages to a user and get replies to those messages from him.

For example, a chain of actions for creating a photo collage of pets:

1. The bot asks the user to send a "photo of a dog"
2. User sends "photo of dog"
3.  Save the image to a file.
(?)

4. Now the bot asks for a "photo of the cat"
5. User sends "photo of cat".
6.  We save the image to a file.
(?)

7. Bot asks for "photo of turtle".
8. User sends "photo of turtle"
9.  Save image to file.
(?)

10. Make a collage on the server 
11. Send the user the finished collage

I’m having trouble getting to step number 4.
I was trying to increment the variable through the “Set” node.

I could solve this with a message chain.

But here I only have a “Telegram message trigger” and I can’t “expect the user to take a picture of the dog”. Instead, I process his message “from scratch.”

How do I make the program understand that the user has already sent a “photo of a dog” and request a “photo of a cat” and then a “photo of a turtle”

Please help me with the logic.

I read the documentation and the tutorial on how to create a telegram bot, but I didn’t find anything like that. I would be grateful for advice on what to read more

Hey @1114!

Welcome to the community :sparkling_heart:

@mcnaveen has built some Telegram bots with n8n. Maybe he can share some ideas :slight_smile:

1 Like

I got what I wanted to do. Let me explain using the same example

....
1.The bot asks the user to send a "photo of a dog".
2. Set the variable through Set - "dog"
3. Open the Spreadsheet file node (write the variable from the previous step)
4.  Write binary file

(start message trigger)

5. User sends "photo of dog". 3.
7. Reading the binary file
8. Opens Spreadsheet file - here variable "dog"
6.  Save the image to a file named "dog".
7. Now the bot asks for a "photo of the cat"
8. Set the variable through Set - "cat".
9. Open the Spreadsheet file node (write the variable from the previous step).
10.  Write binary file

I wanted to find out how to use a “global variable,” but in the end, writing to a table worked fine for me
I hope someone will find my experience useful

1 Like

Thanks @1114 for sharing this :sparkling_heart:

Hey @harshil1712 Sorry bro. I was inactive for a while.

Glad @1114 found a way to fix it. :tada:

1 Like