Overview
Returns a function to send messages to the conversation on behalf of the user. The message appears as a user message and triggers the AI to respond.
Import
import { useSendMessage } from 'sunpeak';
Signature
function useSendMessage(): (params: SendMessageParams) => Promise<void>
SendMessageParams
Array of message content parts.
MessageContent
Returns
sendMessage
(params: SendMessageParams) => Promise<void>
Function to send a message to the conversation.
Usage
import { useSendMessage } from 'sunpeak';
function MyResource() {
const sendMessage = useSendMessage();
const handleFollowUp = async () => {
await sendMessage({
role: 'user',
content: [{ type: 'text', text: 'Show me more details' }],
});
};
return <button onClick={handleFollowUp}>Ask for Details</button>;
}