How to send base64 encoded images to rasa-webchat?


Not sure if this is the right place to ask for it but I can’t find any documentation anywhere else. So I use the react component rasa-webchat to interact with my rasa bot. At some point I would like to be able to send and display images on the webchat, I now it’s possible to send an image via URL (according this doc) when calling:

dispatcher.utter_message( text=some_text, image= “https://some_image”)

However I don’t have access to remote stores to keep image and so would prefer to send a base64 encoded string of my image and decode it in the webchat.

My question is then how to do so? Should I put my base64 string as a json_message when calling dispatcher.utter_message()? How to handle the response from the react component side?

Help would be greatly appreciated, best,



Indeed, you’ll have to send a custom field (json_message) containing that base 64 string.

As for converting back to an image, it’s not related to Rasa and I haven’t done this, but check out:

Hi, good to know for the custom field. Converting an base64 to an image in react isn’t that hard indeed, but it’s kind of obscure how the webchat react-component handles the response

1 Like

Ah yes indeed, I went through the code yesterday to try to answer this question and got lost there. Couldn’t even find what I was looking for!

Try to open an issue in their repository if you don’t get an answer here.

Thanks for your time, I’ll keep digging…

1 Like