Widgets

Add an iframe agents can open from the Kustomer navigation rail on any page, with per-org URLs, sizing, browser permissions and background loading.

A widget is a page you host that agents open from the navigation rail, whatever they're looking at. Use one for tools agents need alongside every conversation: a softphone, an order lookup, a knowledge tool, a portal into another system. Unlike a KView, a widget isn't tied to a record. It stays open as the agent moves around, and receives context updates through the Cards SDK.

Agents open widgets from the Widgets button in the navigation rail, which lists the icon of every widget installed in the org. Hovering an icon shows the app's title. A widget opens as a floating window with buttons to refresh your page and close the window. Agents can drag the window but not resize it, and Kustomer remembers where each agent left it.

Define a widget

widgets (excerpt)
{
  "app": "acme_orders",
  "settings": {
    "default": {
      "storeDomain": { "type": "string", "defaultValue": "", "required": true }
    }
  },
  "widgets": [
    {
      "name": "order-lookup",
      "url": "https://kustomer.acme.example/widget?store={{{settings.default.storeDomain}}}",
      "icon": "https://kustomer.acme.example/widget-icon.png",
      "width": "24vw",
      "height": "60vh",
      "iframePermissions": "microphone *; autoplay *;",
      "backgroundLoad": false
    }
  ],
  "i18n": {
    "en_us": { "acme_orders.widgets.order-lookup.title": "Acme lookup" }
  }
}
Widget
urlstringrequired
iconURLrequired
namestring
titlestring
widthnumber | string
heightnumber | string
iframePermissionsstring
backgroundLoadboolean

Closing the widget only hides the window. Your page keeps running, with its state intact, until the agent clicks refresh or reloads Kustomer.

Try a widget

Change a field to see the widget at its real size on a laptop, desktop or ultra-wide screen, the frame Kustomer renders, and the events your page receives as the agent opens it, moves between pages and takes calls. Copy the app definition when it looks right.

InteractiveWidget builder
Screen
frame 0 × 0 px
<iframe src="https://kustomer.acme.example/widget?store=shop.acme.example" allow="clipboard-read; clipboard-write; microphone *">(Kustomer’s default)
Widget
This org’s settings
Voice
  1. Open the widget, change the agent’s page or status, or click to dial. The Cards SDK events your page gets show up here, newest first.
The agent desktop is drawn at the real size of each browser window, then scaled to fit, so the widget keeps its true proportions. Kustomer opens a widget centered, halfway down the screen, and pulls it up to fit. After that it opens wherever the agent last dragged it. Clicks are simulated, and nothing is loaded from your URL.

Talk to Kustomer from the widget

A widget page loads the same Cards SDK as an embedded KView:

widget.html
<script src="https://cdn.kustomerapp.com/card-js/latest/kustomer-card.min.js"></script>
<script>
  Kustomer.initialize((context) => {
    showFor(context)
  })

  // Fires when the context changes, including when the agent opens or closes the widget.
  Kustomer.on('context', (context) => {
    if (context.widget && !context.widget.isOpen && hasUnsavedWork()) {
      Kustomer.open() // reopen so the agent can finish
      return
    }
    showFor(context)
  })
</script>

Every widget context has isWidget: true, the path of the page the agent is on, and widget, your installed app with isOpen, so your page can react when the agent opens or closes it. On a customer's timeline the context also carries the page's records with the matching type, as for a card: customer, or conversation while one is open. Everywhere else, type is "widget". From there you can:

  • Read and write Kustomer data with Kustomer.request (as the agent).
  • Call your own API with credentials kept server-side through commands.
  • Send the agent to a customer with Kustomer.openCustomer(id) or Kustomer.openCustomerEvent(customerId, eventId).
  • Open the widget with Kustomer.open(), for example on an incoming call.

Voice apps

A softphone or contact-center integration is a widget plus a few keys in the app definition:

Voice app definition (excerpt)
{
  "app": "acme_voice",
  "dataSubscriptions": ["click-to-dial", "status-sync"],
  "meta": { "externalQueue": "acme_voice" },
  "settingsPageConfig": { "title": "Acme Voice", "url": "https://voice.acme.example/kustomer/settings" },
  "widgets": [
    {
      "url": "https://voice.acme.example/kustomer/phone",
      "iframePermissions": "microphone *; autoplay *;",
      "backgroundLoad": true
    }
  ]
}
dataSubscriptionsstring[]
meta.externalQueuestring
settingsPageConfigobject

Voice and presence events

Softphone widgets can subscribe to telephony and routing events:

EventFires whenPayload
number-dialedAn agent clicks a phone number in Kustomer to dial itThe number, as a string: "+14155550134"
routing-status-changeThe agent's routing status changes, such as available to busy{ app, externalQueue, kustomerStatusId, externalStatusId, statusType }, where externalStatusId is the status's externalStatusMap entry for your queue

Only a loaded page hears these events. Without backgroundLoad, they're lost until the agent has opened the widget once.

JavaScript
Kustomer.on('number-dialed', (payload) => softphone.dial(payload))

To change the agent's status in Kustomer from your platform, call Kustomer.requestUpdateUserStatus.

Map agent statuses

Your settings page stores the mapping on each Kustomer routing status. Load the org's statuses with GET /v1/routing/statuses, then save each match with PUT /v1/routing/statuses/{id} and an externalStatusMap entry keyed by your meta.externalQueue. When your widget calls requestUpdateUserStatus with an appStatusCode, Kustomer sets the status that maps it. The map is shared with other voice apps, so keep their entries:

JavaScript
const request = (params) =>
  new Promise((resolve, reject) => Kustomer.request(params, (err, data) => (err ? reject(err) : resolve(data))))

function mapStatus(status, acmeStatusId) {
  return request({
    method: 'PUT',
    url: `/v1/routing/statuses/${status.id}`,
    body: { externalStatusMap: { ...status.attributes.externalStatusMap, acme_voice: acmeStatusId } },
  })
}

Background loading

backgroundLoad: true loads your page for every agent in the org as soon as Kustomer opens. Keep that cheap:

  • Load under 1 MB of assets before the agent interacts.
  • Keep console output to a minimum.
  • Don't open the widget automatically unless something needs the agent, like an incoming call. Several auto-opening widgets competing for attention frustrate agents.

Design checklist

  • Works at the smallest width you set, and at 2× that.
  • Scrolls inside an element of its own (overflow: auto). Kustomer turns off scrolling on the frame, so a page taller than the widget is cut off.
  • Uses the theme's CSS variables so it's readable in dark mode.
  • Handles masked fields in context data.
  • Shows a useful state when settings are missing, instead of a blank frame.
  • Served over HTTPS and allows framing by Kustomer (no X-Frame-Options: DENY, and a frame-ancestors policy that includes your customers' Kustomer domains).