Displaying Video in the Rasa Webchat

Hi all,

If you want to display the video in the Rasa Webchat, just follow the below steps and you can get the below output:

Note: if you are sending youtube link, You must ensure the URL contains embed rather watch as the /embed endpoint allows outside requests, whereas the /watch endpoint does not. stackoverflow reference.

sending video attachment from domain.yml

  utter_greet:
  - text: "Hey! How are you?"
    attachment: { "type":"video", "payload":{ "src": "https://youtube.com/embed/9C1Km6xfdMA" } }

sending video attachment from actions.py:

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]]:
        msg={ "type":"video", "payload":{ "title":"Link name", "src": "https://youtube.com/9C1Km6xfdMA" } }
        dispatcher.utter_message(text="Hello World!",attachment=msg)

        return []

Reference: Sending video message

I hope this helps :slight_smile:

Thanks .

5 Likes

@JiteshGaikwad bro when I send attachment from domain file it wasn’t show me anything and when I send attachment from actions file it showing error like this:

Error: "Expected type 'Optional[str]', got 'Dict[str, Union[str, Dict[str, str]]]' instead "

How to solve this issue also I cannot see the video displaying on the chatbot.

how are you sending the message from domain.yml file?

I just added this to my domain file:

utter_video:

It causing no error but I didn’t show any video but when I use the code in action file:

class Video(Action):

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

def run(self, dispatcher: CollectingDispatcher,
        tracker: Tracker,
        domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
    msg={ "type":"video", "payload":{ "title":"Link name", "src": "https://security.dimabusiness.com/img/icon/Dima_video.mp4" } }
    dispatcher.utter_message(text="Hello World!",attachment=msg)

    return []

I’m getting error: Error: "Expected type ‘Optional[str]’, got ‘Dict[str, Union[str, Dict[str, str]]]’ instead "

have you customized the video size?

Hi, I was trying to add this video feature but i am facing issue.

After i add the domain.yml code and run what i have observed is, it changes the format as follows

utter_video:

– attachment:

  payload:

    src: https://youtube.com/embed/9C1Km6xfdMA

  type: video

text: Hey! How are you?

And when I interact with the bot i get a blank page. And no error in the CLI

Hi ! I’m trying to do the same . Can you tell me how to customize the video size?

i think no option, may be a PR to rasa webchat project

1 Like

Hello @JiteshGaikwad,

How to autoplay these videos. i tried

link?autoplay=1

But video showed but not autoplayed. my issue is i want to connect it with a phone bot where pre recorded recordings should autoplay. Chrome and Firefox stops from autoplay but its not working in phone bot either.

I guess this works for Youtube videos, can you test with the below url, if it autoplays

https://www.youtube.com/embed/9C1Km6xfdMA?autoplay=1

Hello @JiteshGaikwad,

No it didnt worked. Although locally saved video files are autoplaying but when i m just trying to figure out a way to autoplay via a link or saved locally over GCP.

On my windows system i used this to make utterance worked for autoplay :

  utter_recording:
  - custom:
    attachment:
      type: video
      payload:
        src: fullpath/filename.mp4
      autoplay: true

It worked perfectly fine. But when i tried doing the same on GCP like this :

  utter_recording:
  - custom:
    attachment:
      type: video
      payload:
        src: /etc/rasa/files/video.mp4
      autoplay: true

I get this error in webchat widget :

Any luck finding solution either autoplay videos via link or local files on GCP will be very helpful.

hi @athenasaurav,

How did you play the video from your local ? I am getting error that Not allowed to load from local resource when trying to play the video from my local whereas youtube videos are getting played… Could you please help ?

Hi @vaidehi16 Which OS your are using.

First of all thanks for replying @athenasaurav… I am using windows 10

Then post your domain file here. It should work

domain.yml (18.5 KB)

This is the error i am getting in console…Not allowed to load from local resource… I even tried disabling chrome’s web security using flags etc… but still the same error…

image

the utterance should be like this :

  utter_response_sold_it:
  - custom:
    attachment:
      type: video
      payload:
        src: C:/Users/athen/Datascience/rasa/USA Brian/mood_bot/recordings/response_sold_it.mp3
      autoplay: true

It should be / not this \.

It’s the same error…

image

Did that change… still the same error…

Hi @vaidehi16, I m not sure but can you please try some link like this:

src : D:/Bot_Integration/code-analysis-full.mp4

No White spaces in the link. Make sure to change the folder name accordingly also.

yeah… tried that…still no luck :frowning: