Unable to see image in rasa-x

I am unable to see the image in rasa-x server. Please check the details here:

Here is the screenshot of the issue: image

@nik202 Have tried on local, installed required libraries. Same error.

@ChrisRahme I seek your help too.

@Sajjadmanal what code you are using to display an image in rasa x ? can you check in the action server log that you are able to get the image link?

@Sajjadmanal please try one trick, mention any URL image link in the dispatcher.utter_message first and tell me are you able to see that image in rasa x?

For example:

dispatcher.utter_message(text="Hiii 😉", image="https://www.datocms-assets.com/30881/1635851498-newmobileherographic.png?auto=format&auto=format&w=1440")

@nik202 Here is my actions.py file:

class ActionForecastRisk(Action):

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

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

        import seaborn as sns
        import matplotlib.pyplot as plt

        l = [41, 44, 46, 46, 47, 47, 48, 48, 49, 51, 52, 53, 53, 53, 53, 55, 55, 55,
            55, 56, 56, 56, 56, 56, 56, 57, 57, 57, 57, 57, 57, 57, 57, 58, 58, 58,
            58, 59, 59, 59, 59, 59, 59, 59, 59, 60, 60, 60, 60, 60, 60, 60, 60, 61,
            61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 62, 62, 62, 62, 62, 62, 62, 62,
            62, 63, 63, 63, 63, 63, 63, 63, 63, 63, 64, 64, 64, 64, 64, 64, 64, 65,
            65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 66, 66, 66, 66, 66, 66,
            67, 67, 67, 67, 67, 67, 67, 67, 68, 68, 68, 68, 68, 69, 69, 69, 70, 70,
            70, 70, 71, 71, 71, 71, 71, 72, 72, 72, 72, 73, 73, 73, 73, 73, 73, 73,
            74, 74, 74, 74, 74, 75, 75, 75, 76, 77, 77, 78, 78, 79, 79, 79, 79, 80,
            80, 80, 80, 81, 81, 81, 81, 83, 84, 84, 85, 86, 86, 86, 86, 87, 87, 87,
            87, 87, 88, 90, 90, 90, 90, 90, 90, 91, 91, 91, 91, 91, 91, 91, 91, 92,
            92, 93, 93, 93, 94, 95, 95, 96, 98, 98, 99, 100, 102, 104, 105, 107, 108,
            109, 110, 110, 113, 113, 115, 116, 118, 119, 121]

        plt = sns.distplot(l, kde=True, rug=False)
        fig = plt.get_figure()
        fig.savefig("./actions/neww.png")


        msg = "hiiiii"
        dispatcher.utter_message(text=msg, image = "./actions/neww.png")
        return []

Action server logs when I call this:

After this, I have tried your example. It is showing image fine: image

@Sajjadmanal I know :slight_smile: So the gotcha is this, you need to store the file in somewhere, where you able to fetch the http link, suggestion you can use google drive or FTP etc, as it will not picked the image you are trying to show while just simply creating the graph etc ? I hope you got my point?

More serious concern is that, if you are using docker container then this will be a nightmare’s, as the generated file will be stored in container.

1 Like

@nik202 I chose this method just to show the plots/graphs. Is there any other better way to plot graphs inside chat? Also, I was planning to delete the image once it is shown to user, i.e, after utter, I would have deleted the image. Confused why it is not able to show image which is there in local path.

@Sajjadmanal I have no idea on that, I have given you suggestion and solution simultaneously. I never encounter with such type of use case or project.

Tip: You just need http or https link for the generate chat, that how it work, think the process again as you are using docker and docker runs on containers and how you push the chat to elsewhere and get the link.

Good Luck! I hope this much help will solve you issue.

1 Like

Thanks for your suggestion.

@Sajjadmanal No worries, do discuss if you need any help or suggestion.