Hi! First thanks for this component :)
I'm trying to use the submitUserMessage
method once the deepChat Component has been rendered using the onComponentRender
.
I'm using React, and basically I'm trying to do something like this:
import { DeepChat } from 'deep-chat-react';
import React, { createRef } from 'react';
import { DeepChat as DeepChatCore } from 'deep-chat';
export const ModelWithAI = () => {
let conversationId: string | null = null;
const deepChatRef = createRef<DeepChatCore>();
return (
<DeepChat
className="deep-chat-container"
ref={deepChatRef}
onComponentRender={() => {
console.log('DeepChat component rendered', deepChatRef.current);
deepChatRef.current?.submitUserMessage({ text: 'hello' });
}}
request={{
url: 'ws://localhost:8008/chat/ws',
method: 'POST',
headers: { TODO: 'AUTH' },
websocket: true,
additionalBodyProps: { conversation_id: conversationId },
}}
/>
);
};
The chat is working great when I send the messages through the input or after a while using a button with the same submitUserMessage
, but I wish I can send an specific message once the component is ready to activate the bot I have in the "other side" with a message. Maybe I'm doing something wrong, help here would be much appreciated!
Thanks in advance!
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too