Inbox

The inbox component

For many applications, this will be the only component you need to integrate to get started. It should be noted too that the component is fully responsive. If embedded in a narrow width sidebar for instance, it will collapse down to show a smaller mobile-style view.

Installation

The simplest version of the inbox component can be embedded like this:

1<iframe
2 src="https://embed.surge.app/conversations?user_id={SURGE_USER_ID}&token={ACCOUNT_TOKEN}"
3></iframe>

Both {SURGE_USER_ID} and {ACCOUNT_TOKEN} are required parameters. You can find them in the Surge dashboard. We will also be providing more robust auth options in the near future.

Events emitted

The Inbox component emits events that you can listen to in your application. Here are the events that you can listen to:

Conversation selected

When the user selects a conversation, this event is emitted with the details of the conversation:

1{
2 "source": "surge-inbox",
3 "type": "conversation-selected",
4 "conversation": {
5 "id": "cnv_01jadpja6sen796q4wxygg5q78",
6 "contact": {
7 "id": "ctc_01jadpk0asfq599vt3pwn3he6x",
8 "first_name": "Dominic",
9 "last_name": "Toretto",
10 "phone_number": "+18015551234"
11 }
12 }
13}

Conversation deselected

When the user selects a conversation or begins a new one, this event is emitted with the details of the conversation that was previously selected:

1{
2 "source": "surge-inbox",
3 "type": "conversation-deselected",
4 "conversation": {
5 "id": "cnv_01jadpja6sen796q4wxygg5q78",
6 "contact": {
7 "id": "ctc_01jadpk0asfq599vt3pwn3he6x",
8 "first_name": "Dominic",
9 "last_name": "Toretto",
10 "phone_number": "+18015551234"
11 }
12 }
13}

Filter changed

When the user selects an inbox filter, this event is emitted with the new selection.

1{
2 "source": "surge-inbox",
3 "type": "filter-changed",
4 "filter": "unread"
5}

The filter will be one of inbox, unread, all, archived, or opt_outs.

Events accepted

The Inbox component also accepts events to provide basic controls for your application. Here are the events you can send:

Update composer

Update the content in the user’s composer.

1{
2 "target": "surge-inbox",
3 "type": "update-composer",
4 "method": "replace",
5 "text": "this should be the only text"
6}

The method can be one of replace or append:

  • replace scraps any existing content and leaves just the included text
  • append adds the included text at the end of the existing text content