Customer context
Identify your signed-in users in the chat and show what your system knows about each customer beside the conversation.
Your team answers better when it sees who is writing. Mobiari shows the customer beside every conversation in the inbox, and the AI drafting replies reads the same. Two integrations bring your own system in:
- Signed identity: your site tells the chat widget who is signed in, and what you want the team to see (plan, account, version).
- Context URL: Mobiari asks your server about the customer when the team opens a conversation, and shows the fields and links you return.
Both use the workspace's integration secret: in the admin, Conversas → Configurações → Equipe → Integração com o seu sistema → Criar segredo. It is shown once; keep it on your server, never in the browser.
Signed identity
Sign a short-lived JWT (HS256) with the integration secret on your server, and hand it to the widget:
<script>
window.MobiariChatSettings = {
identity: () => fetch('/api/mobiari-identity').then((r) => r.text()),
}
</script>
<script src="https://api.mobiari.com/widget.js" data-key="ch_..." async></script>| Claim | |
|---|---|
aud | The chat channel's key (ch_..., the widget's data-key). |
sub | Your id for the person. |
email | Their e-mail. |
name | Optional. |
context | Optional object: anything the team should see ({"plan": "Pro", "projects": 3}). Shown as fields beside the conversation. |
exp | At most 10 minutes ahead: the widget asks for a fresh token when a chat starts. |
import jwt from 'jsonwebtoken'
app.get('/api/mobiari-identity', requireLogin, (req, res) => {
const token = jwt.sign(
{
aud: 'ch_...',
sub: req.user.id,
email: req.user.email,
name: req.user.name,
context: { plan: req.user.plan, projects: req.user.projectCount },
},
process.env.MOBIARI_INTEGRATION_SECRET,
{ algorithm: 'HS256', expiresIn: '10m' },
)
res.type('text/plain').send(token)
})A chat opened with a valid token is marked verified, and its contact's name
and e-mail are the ones you signed. An invalid or expired token is refused
(401 bad_identity).
Context URL
Set an https address in Integração com o seu sistema → URL de contexto.
When someone on the team opens a conversation, Mobiari POSTs to it:
{
"event": "conversation.context",
"store_id": "…",
"conversation_id": "…",
"channel": "web",
"customer": {
"external_id": "your id, from the signed identity",
"email": "ana@example.com",
"phone": "+5511987654321",
"name": "Ana",
"customer_id": "Mobiari's customer id"
}
}with two headers:
X-Mobiari-Timestamp: Unix seconds.X-Mobiari-Signature:sha256=and the hex HMAC-SHA256 oftimestamp + "." + bodywith the integration secret.
Check both before answering (and refuse old timestamps):
import crypto from 'node:crypto'
function fromMobiari(req, rawBody) {
const ts = req.headers['x-mobiari-timestamp']
const expected = 'sha256=' + crypto
.createHmac('sha256', process.env.MOBIARI_INTEGRATION_SECRET)
.update(`${ts}.${rawBody}`)
.digest('hex')
const given = req.headers['x-mobiari-signature'] ?? ''
return Math.abs(Date.now() / 1000 - Number(ts)) < 300 &&
given.length === expected.length &&
crypto.timingSafeEqual(Buffer.from(given), Buffer.from(expected))
}Answer 200 with JSON, within 5 seconds:
{
"title": "Develari account",
"fields": [
{ "label": "Plan", "value": "Pro" },
{ "label": "Projects", "value": "3" },
{ "label": "Last deploy", "value": "failed 2h ago", "url": "https://app.develari.com/deploys/981" }
],
"links": [
{ "label": "Open in admin", "url": "https://admin.develari.com/accounts/42" }
]
}Up to 20 fields and 10 links; values up to 300 characters; links must be https. The answer is kept for 10 minutes (the team can refresh it). When your server does not answer, the last good answer stays on screen with the error.
Ticket fields
Besides what your system knows, each workspace can have its own ticket fields (project, version, contract): Conversas → Configurações → Equipe → Campos do chamado. The team fills them in beside the ticket. Reading and writing ticket fields is not part of the public API yet.