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
{
"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" }
}
}urlstringrequired- The page to load. Reference your app's settings with
{{{settings.<category>.<name>}}}to give each org its own URL. Widgets can only read their own app's settings. iconURLrequired- An SVG or PNG, at least 128×128 px, shown in the navigation rail.
namestring- Tells an app's widgets apart, and keys their translations. The window's title bar shows your
<app>.widgets.<name>.titletranslation, and is blank without one. titlestring- Not shown in Kustomer. Set the title bar's text with the translation above.
widthnumber | string- Pixels as a number, or any CSS length such as
"24vw"or"calc(30vmin + 50px)". Defaults to 300 px. A string the browser can't parse leaves the frame at 300 × 150 px. heightnumber | string- Same as
width. Defaults to 600 px, plus Kustomer's 36 px title bar. iframePermissionsstring- Browser features to delegate to the iframe, in Permissions Policy syntax:
"microphone *; camera *; autoplay *;". Kustomer passes onmicrophone,camera,autoplayandcompute-pressureand drops anything else. Without this field the frame getsclipboard-read; clipboard-write; microphone *. Setting it replaces that default, so your page loses clipboard access. backgroundLoadboolean- Load the widget when Kustomer starts, before the agent opens it. Without it, your page loads the first time the agent opens the widget. Softphones need it to ring while closed.
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.
Talk to Kustomer from the widget
A widget page loads the same Cards SDK as an embedded KView:
<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)orKustomer.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:
{
"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[]click-to-dialsends your widget thenumber-dialedevent,status-syncsendsrouting-status-change, andtyping-indicatorssendskustomer-typing-status-changed.meta.externalQueuestring- The queue your platform routes calls through. Admins pick it under External Queues in a voice team's routing profile, so that team's calls stay with your app instead of being routed to other teams. It's also your key in each status's
externalStatusMap. settingsPageConfigobject- A settings page you host, where admins map Kustomer statuses to yours.
Voice and presence events
Softphone widgets can subscribe to telephony and routing events:
Only a loaded page hears these events. Without backgroundLoad, they're lost until the agent has opened the widget once.
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:
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
consoleoutput 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 aframe-ancestorspolicy that includes your customers' Kustomer domains).