how to display images in chat bot using custom Component .Any example?
See original GitHub issueHi I am new to react. I want to display an Image in chat bot using custom component. Please providing any example. For example i am trying below code using an api(json Data). If response is text type display that message using addResponse method. Similarly buttons also. But if response is Image type then how to display using customcomponent.Please help me
`export default class App extends Component { state = { todoss: [] }
componentDidMount() { addResponseMessage(‘Welcome to this awesome chat!’); }
handleNewUserMessage = (newMessage) => {
fetch('http://localhost:5005/webhooks/rest/webhook', {
method: 'POST',
headers : new Headers(),
body:JSON.stringify({"sender": "Rasa", "message": newMessage}),
}).then((res) => res.json())
.then((data) => {
var first = data[0];
var mm= first.text;
var i;
console.log(mm)
toggleMsgLoader();
setTimeout(() => {
toggleMsgLoader();
if (data.length < 1) {
addResponseMessage("I could not get....");
} else {
//if we get response from Rasa
for ( i = 0; i < data.length; i++) {
//check if there is text message
if (data[i].hasOwnProperty("text")) {
addResponseMessage(data[i].text );
}
if (data[i].hasOwnProperty("buttons")) {
setQuickButtons([ { label: data[i].buttons[0].title, value: 'Yes' }, { label:
data[i].buttons[1].title, value: 'No' } ]);
}
if (data[i].hasOwnProperty("image")) {
this.setState({todos: data[i].image})
}
}
}
}, 2000);
})
}
handleQuickButtonClicked = (e) => {
addResponseMessage('Selected ' + e);
setQuickButtons([]);
}
render() {
return (
<div>
<Widget
title="Rasa Sample Bot"
subtitle="Asistente virtual"
senderPlaceHolder="Type here ..."
handleNewUserMessage={this.handleNewUserMessage}
handleQuickButtonClicked={this.handleQuickButtonClicked}
badge={1}
customComponent={(customData) => (<div><img src={todoss.image} /></div>) }
/>
<h2> hi</h2>
</div>
</div>
);
}
} `
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:6
Top Results From Across the Web
Specify Chat Images | Embedded Service for Web Developer ...
Specify a URL to set the avatar image that appears when the customer is chatting with a bot. We recommend an image size...
Read more >Web Chat customization in the Bot Framework SDK - Bot Service
The Web Chat control provides rich customization options: you can change colors, sizes, placement of elements, add custom elements, and interact ...
Read more >Developing custom messages for react-chatbot-kit - YouTube
... we implement custom messages in the react- chatbot -kit package, allowing users to define a message type and map custom components to...
Read more >Chat Lightning Web Component Pack – User Guide
Therefore, it is best to use the carousel component in a Question block if using a chatbot, to save the selected tile response...
Read more >Web Chat samples - Microsoft Open Source
These samples are connected to MockBot, a bot for testing various features of Web Chat. The source code of MockBot can be found...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Here’s how you would add an image at the beginning of the chat.
In your code you probably want add it after the check for an image.
how we can send images voice messages and videos through react-chat-widget