SDK APIs
Messaging
Send messages to your agent as if the user typed them, blending conversation, actions, and UI components into your product flows.
Every call references your Agent API Name, found in Agent Studio → Setup.
Initialize the agent
Section titled “Initialize the agent”Call agent methods once the SDK is ready.
foldspace("when", "ready", () => { const agent = foldspace.agent({ /* …common setup… */ }); // Now you can call any of the methods below: agent.message("What actions can you do?");});Send a message
Section titled “Send a message”Send a chat message as if the user typed it into the agent. Returns the agent instance for chaining.
message(text: string, options?: boolean | MessageOptions): this;
interface MessageOptions { newChat?: boolean; autoSend?: boolean;}| Parameter | Type | Description |
|---|---|---|
text | string | The message content to send. |
options.newChat | boolean | Start a fresh conversation. |
options.autoSend | boolean | true sends the message immediately. false prefills it in the input and lets the end user send it. Omit it and the agent decides, based on placement and available height. |
Passing a bare boolean as options is the legacy form of newChat.
// Let the agent decide whether to send or prefillfoldspace.agent("myproduct-agentic-agent") .message("Configure brand settings for me");
// Prefill the input and let the user send itfoldspace.agent("myproduct-agentic-agent") .message("Configure brand settings for me", { autoSend: false });Interpolate runtime values
Section titled “Interpolate runtime values”Because text is a plain string, you can interpolate runtime values and chain other methods such as .open().
const userName = "John";agent("myproduct-agentic-agent") .message(`Hi ${userName}, let's review your pipeline today`) .open();Related
Section titled “Related”- Conversation API: list, search, pin, and manage conversations.
- Agent Event API: listen to agent, UI, and conversation events.