# Set up web message inbox

#### Prerequisites

Make sure you've implemented Pushwoosh Web SDK on your website. To do so, please follow our [guide](/developer/pushwoosh-sdk/web-push-notifications/web-push-sdk-30/).


**Message Inbox for websites** allows you to store web push notifications so users can revisit them later, ensuring important messages are seen.

## How it works

Here's a typical workflow with InboxMessages:

| Step                                                                 | Method                                                                                                                                      |
| -------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
| Page load                                                            |                                                                                                                                             |
| Synchronizing messages with the server                               | <p><code>InboxMessagesModel.updateMessages</code><br/>Executed while the SDK is initialized</p>                                              |
| Deleting outdated messages                                           | <p><code>InboxMessagesModel.updateMessages</code><br/>Executed while the SDK is initialized</p>                                              |
| Receiving the number of unread messages to update a badge            | <p><code>Pushwoosh.pwinbox.unreadMessagesCount</code><br/>Executed manually (after the <code>onUpdateInboxMessages</code>event triggers)</p> |
| Loading messages to be displayed in Inbox                            | <p><code>Pushwoosh.pwinbox.loadMessages</code><br/>Executed manually (after the <code>onUpdateInboxMessages</code>event triggers)</p>        |
| Marking messages got in the viewport as read                         | <p><code>Pushwoosh.pwinbox.readMessagesWithCodes</code><br/>Executed manually</p>                                                            |
| Performing an action assigned to the message opened                  | <p><code>Pushwoosh.pwinbox.performActionForMessageWithCode</code><br/>Executed manually</p>                                                  |
| Deleting messages by click on a delete icon or swipe-right a message | <p><code>Pushwoosh.pwinbox.performActionForMessageWithCode</code><br/>Executed manually</p>                                                  |

## Event listeners

```javascript title="onUpdateInboxMessages"
// Executed after the Inbox is updated automatically while the page is loading. 
Pushwoosh.push(['onUpdateInboxMessages', function(api, pwinbox) {
  pwinbox.loadMessages().then(function(messages) {
    console.log('EVENT: onUpdateInboxMessages', messages);
  });
}]);
```

```javascript title="onPutNewMessageToInboxStore"
// Executed by ServiceWorker after the Inbox Message is received and saved to indexedDB. 
Pushwoosh.push(['onPutNewMessageToInboxStore', function(api, message) {
  console.log('EVENT: onPutNewMessageToInboxStore', message);
}]);
```

## Public module

**WebSDK InboxMessagesPublic module** presents a public interface to implement Web Inbox.

```txt title="Model"
type TInboxMessageTypePlain = 0;
type TInboxMessageTypeRichmedia = 1;
type TInboxMessageTypeURL = 2;
type TInboxMessageTypeDeeplink = 3;
type TInboxMessageType = TInboxMessageTypePlain  // depends on action_params
  | TInboxMessageTypeRichmedia
  | TInboxMessageTypeURL
  | TInboxMessageTypeDeeplink;
 
 
interface IInboxMessagePublic {
  code: string;  // inbox_id
  title: string;  // title
  message: string; // body
  imageUrl: string;  // image
  sendDate: string;  // send_date
  type: TInboxMessageType;  // depends on action_params
  isRead: boolean;  // true if status is "read" or "open"
  link: string; // Deeplink | URL | "/"
  isActionPerformed: boolean;  // true if status is "open"
}
```

## Public methods

Check out public methods' descriptions in the [Web Push SDK 3.0](/developer/pushwoosh-sdk/web-push-notifications/web-push-sdk-30/) guide.