deep-chat
deep-chat copied to clipboard
How can I stop an active conversation using code?
How can I actively stop the conversation using code? Which function can achieve this?
Could you elaborate on what you mean by "stop the conversation"? Thankyou.
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
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:
Let me know if this helps. Thanks!