To add Inbox to your website, implement the Dengage Web SDK in your frontend. This guide covers creating a message provider, fetching messages, and reporting user engagement.
For an overview, see the Inbox User Guide.
The Web SDK wraps the Inbox public API in ready-made methods: it fetches the current user's messages and reports engagement events, attaching the account, device, and contact identifiers for you. Requires Web SDK v2.4.0+. You build the Inbox UI; the provider handles the transport.
1. Create the provider
InboxMessageProvider is a prototype function: create it once with new, then use its methods. Both creation styles are equivalent:
JAVASCRIPT
// with the dengage function
var dengageInboxMessageProvider = new dengage('InboxMessageProvider');
// with the DengageHelper object
var dengageInboxMessageProvider = new DengageHelper.InboxMessageProvider();2. Fetch messages
getMessages(limit) returns the current user's messages. It runs asynchronously — use .then or async/await. limit is optional.
JAVASCRIPT
dengageInboxMessageProvider.getMessages().then(inboxMessages => {
/* render messages here */
});
/* --- OR --- */
const inboxMessages = await dengageInboxMessageProvider.getMessages();
30-second cache. The first call fetches messages from the backend and caches them for 30 seconds. Any call within that window is served from the cache. CallinggetMessagesimmediately after an event will not reflect that event.
3. Report events
Four methods map one-to-one to the standard events. Call each at the moment described — nothing is sent automatically.
| Method | Event | When to call |
|---|---|---|
onImpression(messageId) | IM | The message becomes visible in your list |
onOpen(messageId) | OP | Two-stage displays only — the message's full details become visible (marks it read) |
onClick(messageId, buttonId) | CL | The message is clicked — pass the tapped button's buttonId (marks it read) |
onDelete(messageId) | DT | Your UI offers deletion and the user deletes the message |
JAVASCRIPT
dengageInboxMessageProvider.onImpression(messageId);
dengageInboxMessageProvider.onOpen(messageId);
dengageInboxMessageProvider.onClick(messageId, buttonId);
dengageInboxMessageProvider.onDelete(messageId);The SDK attaches the identifiers (acc, did, and ckey when the user is identified) automatically. Anonymous visitors are fully supported.
Never use a "send event → refetch" flow:getMessagesserves a 30-second cache and server-side processing is asynchronous. Update your local list the moment the user acts.