Telegram send media group

Hi, I am trying to send more than 1 image in telegram in custom actions.

            photogrp = "",  ""
            mediatest = {
                "media": {photogrp}

I am trying to use json_message to send these group photos. I know that’s something wrong with the json I defined. Anyone have experience on this, please let me know. Thanks.

Welcome to the forum! :slight_smile:

Try to send multiple messages instead:

 photogrp = ["",  ""]

for photo in photogrp:
    mediatest = {
        "media": photo

    dispatcher.utter_message(json_message = mediatest)
1 Like

Thanks Chris, :+1: This is a workaround method, but it will be annoying for user if sending a group of photos, example 10. Now at least I got the json_message responding. Still trying to figure out how to pass the list in.

Why though? You won’t have to add anything to the code (except the links obviously).

What do you mean? Don’t hesitate to ask for help :slight_smile:

Let me tell you some background of what this bot doing, this is a bot working as a middle man, to link up seller and buyer. From seller side seller will let the bot know what kind of used stuff he/she wanted to sell (example iPhone 11), and uploaded the bot some photos (max 10), the bot has a database to store the info and a storage to store the photos. (Seller part is completed)

From the buyer will ask the bot about the product he/she is looking for (example iPhone 11), bot will search at the database and return the product info and photos.

photogrp = []
photos = [pic1, pic2, pic3, pic4, pic5, pic6, pic7, pic8, pic9, pic10]
for photo in photos:
bot.send_media_group(chat_id=chat_id, media=photogrp)

Above code is working with Python telegram module (non-Rasa)

1 Like

Ah I see, interesting use-case.

But what’s the problem? I still don’t understand what you meant by this:

Does sending a group of photo appears differently that individual photos in Telegram? Doesn’t Telegram merge successive photos into a group like WhatsApp does?

If 10 photos, It will prompt users 10 times, and multiply by numbers of product matched. I want it to be minimize prompt

1 Like

Ah, that’s annoying indeed.

This is more related to Telegram than to Rasa, though. I don’t have knowledge about Telegram but what happens if you pass the list to the “media” key (as you were initially doing but with correct format)?

photogrp = ["",  ""]

dispatcher.utter_message(json_message = {
    "media": photogrp

No luck, It passing in the JSON, but the 2 photos not send out by the bot. I am going to modify my local PC “” ( Between line 137 - 141

1 Like