JavaScript SDK
The JavaScript SDK lets you control the messenger widget from your frontend code. All methods are available on the promptify global object.
Methods
Section titled “Methods”setUser
Section titled “setUser”Identify the current user or set them as anonymous.
// Identified user (without verification)promptify.setUser({ id: "user-123", email: "jane@example.com", name: "Jane Doe", avatarUrl: "https://example.com/avatar.jpg", attrs: { plan: "pro", signedUp: 1700000000, }, organizations: [{ id: "org-456", name: "Acme Corp" }],});
// Identified user (with signed JWT)promptify.setUser({ jwt: "eyJ..." });
// Anonymous visitorpromptify.setUser({ id: null });See User Identification for details on the user data fields and JWT signing.
startConversation
Section titled “startConversation”Open the messenger and start a new conversation. Must be called after setUser.
// Open with prefilled messagepromptify.startConversation("I need help with billing");
// Open without prefillpromptify.startConversation();setTheme
Section titled “setTheme”Switch to a named theme configured in the dashboard.
promptify.setTheme("dark");Themes are created and configured in Settings > Messenger > Themes. The setTheme method switches between them by name at runtime. You can also set a theme declaratively using the data-theme attribute on the container element.