Control the chat programmatically using refs and method calls.
import { useRef } from 'react';
import { EmbeddedChat, type SuperInternChatInstance } from 'superintern-web-sdk';
export default function MyComponent() {
const chatRef = useRef<SuperInternChatInstance>(null);
const sendMessage = () => {
chatRef.current?.submitMessage('Hello!');
};
const clearChat = () => {
chatRef.current?.clearChat();
};
return (
<div>
<button onClick={sendMessage}>Send Message</button>
<button onClick={clearChat}>Clear Chat</button>
<div style={{ height: '600px' }}>
<EmbeddedChat
ref={chatRef}
baseSettings={{ apiKey: "YOUR_API_KEY" }}
/>
</div>
</div>
);
}