Messaging API

Learn how to send messages programmatically to your Foldspace agent to trigger conversations, actions, and UI flows directly from your application

You can send messages to it as if the user typed them, enabling seamless product flows that blend conversation, actions, and UI components.

Every call must reference your Agent API Name, which you’ll find in **Agent Studio **→ Setup.

Example Initialization

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?");
});

message(text: string): this

Programmatically send a chat message as if the user typed it into the agent.

foldspace.agent("myproduct-agentic-agent")
  .message("Configure brand settings for me");

Send Dynamic Message

const userName = "John";
agent("myproduct-agentic-agent")
  .message(`Hi ${userName}, let’s review your pipeline today`)
  .open();