OvidijusParsiunas / deep-chat

Fully customizable AI chatbot component for your website
https://deepchat.dev
MIT License
1.57k stars 256 forks source link

prevent submitUserMessage from showing up in deep-chat #289

Open FranzHell opened 1 month ago

FranzHell commented 1 month ago

I want to submit a User Message in order to trigger a first response from the chatmodel, I am currently using:

chatElementRef.value.submitUserMessage({
          text: 'the user has entered the session, please greet him with a welcome message',
        });

Is there any way that I can prevent this initial UserMessage to show up in deep-chat, but only display the first response that comes back?

OvidijusParsiunas commented 1 month ago

Hi @FranzHell. The quickest way to not show the initial user message would be to trigger the clearMessages method after you trigger the [submitUserMessage]() method. Example:

chatElementRef.value.submitUserMessage({
  text: 'the user has entered the session, please greet him with a welcome message',
});
setTimeout(() => {
  chatElementRef.value.clearMessages();
});

An alternative to this would be to trigger the initial call outside of the Deep Chat component and add the AI's response via the addMessage method.

Let me know if this helps. Thanks!