How to show images in Rasa Chat from custom action

Hi,

Can anyone help me showing images in Rasa X chat from custom actions? I tried to use the following but nothing worked:

dispatcher.utter_message(text="https://i.imgur.com/nGF1K8f.jpg") dispatcher.utter_attachment({image="https://i.imgur.com/nGF1K8f.jpg"}) dispatcher.utter_attachment("https://i.imgur.com/nGF1K8f.jpg")

1 Like

hey @kshitiz12345, try sending the image using below line:

dispatcher.utter_message(image=“https://i.imgur.com/nGF1K8f.jpg”)

2 Likes

Hi @JiteshGaikwad

I tried your approach but still no luck. In Rasa x, I am not able to see the image. This is how I am using the code:

 for article in resp["articles"]:
                dispatcher.utter_message(image="https://miro.medium.com/max/4500/1*6azAYcduaPk8alIjkB53rg.jpeg")
                dispatcher.utter_message(text=article["description"]) 

Any other clue?

which version of rasa are you using?

rasa==1.7.0

rasa-sdk==1.7.0

rasa-x==0.25.1

hey @kshitiz12345, I checked the above code and it didn’t worked for me too in Rasa X but it’s able to show me the image reponse when I test it in the postman and it’s rendering the image If I send it from domain.yml file:

rasa version that I am using:

rasa                              1.7.3              
rasa-sdk                          1.7.0              
rasa-x                            0.25.2   

@erohmensing, is there any problem for rendering images in Rasa X if we send the image from custom actions since it works if we send the images registered in domain.yml?

actions.py contents:

class ActionHelloWorld(Action):

    def name(self) -> Text:
        return "action_hello_world"

    def run(self, dispatcher: CollectingDispatcher,
            tracker: Tracker,
            domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:

       

        dispatcher.utter_message(text="Hello World!")
        dispatcher.utter_message(image="https://i.imgur.com/nGF1K8f.jpg")

        return []

@Tanja Will it be possible for you to help me here?

@JiteshGaikwad I’m not sure. It might be that the response format is coming strangely from the rasachat connector. Can you post the ouput you’re seeing in Rasa X?

Hey @erohmensing, I have attached the output here.

Did you solve this issue ?

Also , What if I have an image on in a seperate folder, inside data. How will I retutn that image? I’m using ngrok, to host via localhost and using telegram.

My try was :

> dispatcher.utter_message(image="/p38.png")

raise BadRequest(message)

telegram.error.BadRequest: Url host is empty 2020-04-18 14:05:32 ERROR rasa.core.channels.telegram - Exception when trying to handle message.Url host is empty

I’m getting the below error.

Any help would be much appretiated.

Anyone solved this.
I try this:
dispatcher.utter_message(image = "https://i.imgur.com/nGF1K8f.jpg") but nothing display on Rasa X. This is my version:
rasa 1.10.10
rasa-sdk 1.10.2
rasa-x 0.31.4

Please anyone can solve this issue…? I appreciated your help, My version: rasa==1.10.2 rasa-sdk==1.10.1 rasa-x==0.32.2

Any update on this? How to share images in RASA-X along with the text.

Found this thread searching for a solution for that issue and even if it is probably outdated by now I found a fix for this issue. Apparently you cannot respond with only an image. You have to respond with text and image in the same dispatch namely

dispatcher.utter_message(
   text="Look at that baby tiger !", 
   image = "https://i.imgur.com/nGF1K8f.jpg"
)

and not send 2 seperated dispatches like above

dispatcher.utter_message(text="Hello World!")
dispatcher.utter_message(image="https://i.imgur.com/nGF1K8f.jpg")

Hope this helps someone like me stumbling across this post :grinning_face_with_smiling_eyes:.

1 Like

Did you find solution of this problem…i also have same issue