(Solved) [CORE/SDK] Sending Pictures from Custom Action (utter_response, utter_attachment not working)

rasa-core
(Tom Graßmann) #1

Hello Community!

Using Rasa-Web-Chat-Widget I’m working on a Bot, that has to select a video from a database, based on the criteria given by the user. This already works fine, but instead of just sending the video link back to the user, I’d like to send the video thumbnail too.

What I already tried:

  • defining a utter_video with an image, where the “image:” part contains a Slot, which will be set by a custom action

utter_video: - text: "{VideoName}" image: "{VideoThumb}"

This doesn’t seem to work, even if I define the VideoThumb Slot as “text” and provide an initial value - the Slotname won’t get replaced with its value

  • sending a response as JSON via utter_response

image_only_message = {"image": "https://i.imgur.com/nGF1K8f.jpg"} dispatcher.utter_response(image_only_message)

This doesn’t seem to work because of the rasa_core and rasa_core_sdk dispatcher differences. When researching this problem, I found other people with the same problem, pointing out, that utter_attachement should provide a working alternative

  • sending a response via utter_attachement

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

The message received by the user now doesnt contain the image, just following text

Attachment: {'image': 'https://i.imgur.com/nGF1K8f.jpg'}

I’m using the latest rasa_core version from Github with Python 3.6.5 on a Windows 10 Machine

Is there a way to make this work?

(Tom Graßmann) #2

Thread can be closed.

Found a solution after reading through the rasa core sdk source code. dispatcher.utter_template("utter_video", tracker, False, image = "https://i.imgur.com/nGF1K8f.jpg")

Does exactly what I needed. Maybe a hint in the documentation of this function would be useful for other people since I discovered some threads with a problem similiar to mine when first googling for the solution.

2 Likes
(Napse Feknu) #3

First of all sorry for commenting on a solved thread. But this even helped me to solve a similar issue/bug. Just here to say a thank you. :smiley:

Regards, Napsa Feknu PLEX . https://tutuappx.com/ . https://vidmate.onl/

1 Like