Hi everyone,
I’m trying to build a workflow, but I’m facing a problem that I can’t seem to solve.
In short, the flow should work like this: multiple photos are sent in a single message on Telegram, and these photos are sent ALL TOGETHER to an artificial intelligence model for analysis.
The problem is that when multiple photos are sent in a single message, Telegram treats them as different triggers, and I can’t find a way to send them all together to the Ai.
Hey @Silvia_Ambrosio !
Here is an example with Redis, but you can even use Data Tables or any storage , to store the media_group_id and files_id for later use, since Telegram Trigger gets hits with every image.
What will do this?
Each photo trigger stores its image in Redis using the shared media_group_id
Only the LAST photo’s workflow execution continues after the wait period
It retrieves ALL photos from Redis (including the ones from earlier triggers)
All photos are sent together to OpenAI for analysis
Redis key is cleaned up after processing
So :
Check Media Group - Verifies if the message has a media_group_id (multiple photos)
Download Photo - Downloads each photo from Telegram API using the file_id
Store Photo in Redis - Stores each photo in a Redis list using media_group_id as the key
Wait for All Photos - Waits 5 seconds for all photos in the group to arrive and be stored
Get All Photos from Redis - Retrieves all photos from the Redis list
Prepare Images for AI - Formats all photos as base64 images for OpenAI vision API
Cleanup Redis - Deletes the Redis key after processing to free up memory
How to Setup?
Set up Redis credentials in all Redis nodes (Store, Get, Cleanup)
Adjust the wait time (currently 5 seconds) if needed based on how quickly photos arrive
Customize the AI analysis prompt in the “Analyze Images” node…
Hope you got the idea , Cheers!
Hi there, thank you for the suggestion.
So, I tried it using Data Tables, but I’m not able to pass the photos to the AI - it does not “take” them and gives me answers that make no sense, not based on the photos.
What am I doing wrong?