deep-chat
deep-chat copied to clipboard
Advice needed for submitUserMessage
Hi DeepChatTeam!
I'm struggling to get submitUserMessage to work. Basically it doesn't seem to do anything at all and I'm not sure why.
So I made a very simple example to show what I'm doing:
import {DeepChat as DeepChatCore} from 'deep-chat';
import {DeepChat} from 'deep-chat-react';
import {useEffect, useRef, useState} from "react";
import './style.css';
export const App = () => {
const [buttonmsg, setButtonmsg] = useState("")
const deepChatRef: React.RefObject<DeepChatCore> = useRef(null);
useEffect(() => {
if (deepChatRef && buttonmsg != "") {
deepChatRef.current.submitUserMessage({text: buttonmsg})
}
}, [buttonmsg])
return (
<div className="App">
<h1>Deep Chat</h1>
<DeepChat
ref={deepChatRef}
demo={true}
style={{ borderRadius: '10px' }}
textInput={{ placeholder: { text: 'Welcome to the demo!' } }}
/>
<button onClick={() => setButtonmsg("Hi this is a message submitted by a button!")}>Click me!</button>
</div>
);
};
In my real world code the message even seems to be sent to the back-end but the response is not shown at all. In my simple example it is not visible as well.
Maybe I'm doing something horribly wrong so I would be glad if you could give me an advice!
Thanks!