Coder Social home page Coder Social logo

Video/Image Not Showing about rasa-webchat HOT 9 CLOSED

botfront avatar botfront commented on July 17, 2024 3
Video/Image Not Showing

from rasa-webchat.

Comments (9)

znat avatar znat commented on July 17, 2024 1

With Rasa Core it must follow the template schema.
So for an image:

{
  text: ...,
  image: ...
}

See: https://rasa.com/docs/core/domains/#images-and-buttons

from rasa-webchat.

arni5na avatar arni5na commented on July 17, 2024

Update: I used dispatcher.utter_attachment(message) with message = {
"type":"video",
"payload":{
"title":"Link name",
"src": "https://youtu.be/f3EbDbm8XqY"
}
}

But it still shows as text in the chat window:
screen shot 2018-12-16 at 4 28 58 pm

from rasa-webchat.

arni5na avatar arni5na commented on July 17, 2024

I was able to send an image by adding it in the templates of the domain file, but I can't send through the custom actions. I changed the value of the message variable in my actions file into this:
message = {
"attachment":{
"type":"image",
"payload":{
"text":"Test",
"image": "img.jpg"
}
}
}

Then I used the dispatcher to send it, but it still doesn't show the image. I'm not sure if I'm in the right track here. Is it possible to send image/video through the custom actions or it can only be done through the domain file?

from rasa-webchat.

bing-zhub avatar bing-zhub commented on July 17, 2024

I have encountered the same problem with you, attachment should be part of response. The reality is that it is part of text. I don't know if you have solved this problem.

from rasa-webchat.

arni5na avatar arni5na commented on July 17, 2024

Sorry, I got busy... Anyway, it seems that we need the Rasa core output channel of the webchat to send the video. I checked the rasa-addons link where we supposed can get it but I didn't find it there...

from rasa-webchat.

hrqiang avatar hrqiang commented on July 17, 2024

the socketio.py doesn't seem like it supports video tag, so there is a mismatch.
The other way is send thru custom message.

from rasa-webchat.

arni5na avatar arni5na commented on July 17, 2024

It's still not working using custom message. This is the video JSON data I sent to the UI:

message = {
                "attachment":{
                    "type":"video",
                    "title":"Link name",
                     "src": "https://www.youtube.com/watch?v=f3EbDbm8XqY"
                }
            }

I did a debug on the UI and it's acknowledging that it received the data as video but it just doesn't show it. Is there a video JSON format that I should follow?

from rasa-webchat.

arni5na avatar arni5na commented on July 17, 2024

Got it finally resolved. These are the steps I did:

In CollectingDispatcher class, I added this function:

    def utter_response(self, message: Dict[Text, Any]) -> None:
        """Send a message to the client."""
        
        self.messages.append(message)

In SocketIOOutput class of the socketio module, I added the following:

    def send_response(self, recipient_id: Text, message: Dict[Text, Any]):
        self._send_message(self.sid, message)

In the Dispatcher class of the dispatcher module, I made the following changes:

    def utter_response(self, message: Dict[Text, Any]) -> None:
        """Send a message to the client."""

        bot_message = BotMessage(text=message.get("text"),
                                 data={"elements": message.get("elements"),
                                       "buttons": message.get("buttons"),
                                       "attachment": message.get("video")})

        self.latest_bot_messages.append(bot_message)
        self.output_channel.send_response(self.sender_id, message)

from rasa-webchat.

arni5na avatar arni5na commented on July 17, 2024

Sorry, above fix caused some issue when dispatching messages other than video attachment. I made changes to the send_custom_message function in socketio instead:

def send_custom_message(self, recipient_id: Text, elements: List[Dict[Text, Any]]) -> None: """Sends elements to the output.""" #print(">>>elements:", elements) message = '' try: if not any('attachment' in d for d in elements): message = {"attachment": { "type": "template", "payload": { "template_type": "generic", "elements": elements[0] }}} else: message = elements[0] self._send_message(self.sid, message) except Exception as e: print("Error sending custom message:", e)

from rasa-webchat.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.