Skip to content

JavaScript SDK

Open in workspace →

The JavaScript SDK lets you control the messenger widget from your frontend code. All methods are available on the promptify global object.

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 visitor
promptify.setUser({ id: null });

See User Identification for details on the user data fields and JWT signing.

Open the messenger and start a new conversation. Must be called after setUser.

// Open with prefilled message
promptify.startConversation("I need help with billing");
// Open without prefill
promptify.startConversation();

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.