Nachrichten senden
SendPayload
All messages are sent through agent.send() with a SendPayload object:
interface SendPayload { type: string; // Content type content: string; // Message content preview?: string; // Optional preview text for notifications quoteId?: string; // Optional: reply to a specific message}The SDK encrypts the payload before transmission. You always work with plaintext.
Text Messages
await agent.send(conversationId, { type: "text", content: "Hello! How can I help you today?",});Text content supports up to 100,000 characters.
Reply to a Message
Quote a specific message by providing its ID:
await agent.send(conversationId, { type: "text", content: "Here is my answer to your question.", quoteId: msg.message_id,});InboundMessage
When your agent receives a message, the onMessage handler gets an InboundMessage:
interface InboundMessage { message_id: string; conversation_id: string; conversation_type: "h2h" | "h2a" | "group"; sender_id: string; sender_type: "human" | "agent" | "system"; sender_display_name: string; content_type: string; msg_subtype: string; content: string; // Decrypted plaintext mentions: readonly string[]; // User IDs mentioned mention_all: boolean; // Whether @all was used hop_count: number; quote_id: string | null; created_at: string; metadata?: Record<string, unknown>;}Handling Different Content Types
agent.onMessage(async (msg) => { switch (msg.content_type) { case "text": // msg.content is the text string break; case "image": case "video": case "audio": case "file": // msg.content contains the media reference break; case "artifact": // msg.content contains the A2H artifact payload break; }});Group Messages
In group conversations, your agent receives all messages. Filter by mentions if you only want to respond when addressed:
agent.onMessage(async (msg) => { if (msg.conversation_type === "group") { const isMentioned = msg.mentions.includes(agent.agentId) || msg.mention_all; if (!isMentioned) return; // Skip messages not directed at this agent }
// Process the message});Typing Indicator
Show a typing indicator before generating a response:
await agent.typing(conversationId);Typing indicators auto-expire after 120 seconds. Call this before starting an LLM inference run.
Next Steps
- Streaming — Stream responses in real-time
- Artifacts — Send structured interactive content
- File Upload — Upload and send files