Skip to content
Talk to an engineer

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.

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 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;
}
ParameterTypeDescription
textstringThe message content to send.
options.newChatbooleanStart a fresh conversation.
options.autoSendbooleantrue 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 prefill
foldspace.agent("myproduct-agentic-agent")
.message("Configure brand settings for me");
// Prefill the input and let the user send it
foldspace.agent("myproduct-agentic-agent")
.message("Configure brand settings for me", { autoSend: false });

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();