deep-chat icon indicating copy to clipboard operation
deep-chat copied to clipboard

How can I stop an active conversation using code?

Open fanxing-6 opened this issue 1 year ago • 3 comments

How can I actively stop the conversation using code? Which function can achieve this?

fanxing-6 avatar Aug 07 '24 15:08 fanxing-6

Could you elaborate on what you mean by "stop the conversation"? Thankyou.

OvidijusParsiunas avatar Aug 07 '24 16:08 OvidijusParsiunas

image The meaning is that I want to achieve the effect of clicking the stop button using code. How can I implement this? Is there a method for it? Thank you

fanxing-6 avatar Aug 07 '24 16:08 fanxing-6

Currently there is no programmatic way to toggle the Submit button, however if you want to, you can simply do this by finding the submit button element via a querySelector and toggling it via JavaScript that way. Example:

// Get the Deep Chat element reference, there are many ways to do it but one is by getting it via an id
const chatElementRef = document.getElementById('chat-element');
const submit = chatElementRef.shadowRoot.querySelector('#input > div:nth-child(5) > div');
submit.click(); // then simply toggle the click

The html for attaching an id can be done as:

<deep-chat id="chat-element"></deep-chat>

To get the selector, inspect the elements using your browser and copy the selector by right clicking it, the following is an example in Chrome:

image

Let me know if this helps. Thanks!

OvidijusParsiunas avatar Aug 07 '24 19:08 OvidijusParsiunas