SDK APIs
SDK APIs
The SDK exposes a small set of methods on an agent instance. Call them once the SDK is ready:
foldspace("when", "ready", () => { const agent = foldspace.agent({ /* setup */ }); // call any SDK API below});The APIs
Section titled “The APIs”- Messaging — send chat messages as if the user typed them.
- Conversation — read and control the current conversation.
- Agent Event — subscribe to agent lifecycle and interaction events.
- Visibility — open, close, and show or hide the agent.
- Fuzzy search — fuzzy-match user phrasing to a record in a local list.
- Application events — send your own product events with
foldspace.track(). - Test mode — run the agent in test mode without polluting real analytics.
Top-level methods
Section titled “Top-level methods”A few methods live on the foldspace global rather than on an agent instance, so they run without resolving an agent first.
agentIds()
Section titled “agentIds()”Returns the id of every agent the SDK has mounted on the page.
foldspace.agentIds();// → ['overlay-support-agent', 'embedded-support-agent']Each id is the mount mode plus the Agent API Name, so the ids are not the values you pass to foldspace.agent(). Use this when a call on a resolved agent leaves the one on screen unchanged: see Check which agent you’re targeting.
foldspace.identify() is covered in User context, and foldspace.track() in Application events.
Where to start
Section titled “Where to start”New to the SDK? Set up the agent first, then Messaging is the simplest call to try. To react to what the agent does, use Agent Event.