JavaScript/jQuery Chat - Render Images

To render an image in a Chat, set the message type to "image" and specify the src field with the image URL. In the following example, AI sends a message with the "imageResponse" type, which is then converted into an image in Chat.

NOTE
Chat displays either images or text in a single message. Specify messageTemplate to display custom messages.
index.js
  • const chat = $("#chatContainer").dxChat("instance");
  • const handleAIResponse() {
  • if (aiResponse.type === "imageResponse") {
  • chat.renderMessage({
  • type: "image",
  • src: aiResponse.imageUrl,
  • author: "bot"
  • });
  • }
  • }