All pages

Docs / Get started

Quickstart

A working chat takes two steps and a couple of minutes. Steps 3 and 4 are optional: they let the assistant know who is signed in and act in your app.

1. Make an app from your website

Create an account and enter your website. Dezzi does the rest at once:

2. Paste one line

<script src="https://<your Dezzi address>/widget.js" data-app="pk_…" defer></script>

Your inbox shows this line with your address and app key filled in. Put it before </body> and the chat is live. For React, or your own screens, see the widget.

Server secrets

Steps 3 and 4 need a secret, made on the Install page and shown once:

3. Tell Dezzi who is signed in (optional)

Your server signs a short token for the signed-in person (HS256, with the user token secret). sub is your id for them and exp at most a day ahead:

import { createHmac } from 'node:crypto';

const b64 = (v) => Buffer.from(typeof v === 'string' ? v : JSON.stringify(v)).toString('base64url');

export function dezziToken(user) {
  const head = b64({ alg: 'HS256', typ: 'JWT' });
  const body = b64({ sub: String(user.id), email: user.email, name: user.name, exp: Math.floor(Date.now() / 1000) + 600 });
  const sig = createHmac('sha256', process.env.DEZZI_USER_TOKEN_SECRET).update(head + '.' + body).digest('base64url');
  return head + '.' + body + '.' + sig;
}

Serve it from a route only signed-in people reach, and hand it to the widget:

Dezzi.identify(async () => (await fetch('/dezzi-token')).text());

Without a token the chat works for visitors only if you let it (Settings), and then it never uses your actions.

4. Give it one action (optional)

An action is an endpoint of your app. Dezzi calls it with POST, a signed body, and the person from the token your server signed, never from the model. Start with a read-only one:

app.post('/dezzi/actions', express.raw({ type: 'application/json' }), async (req, res) => {
  if (!fromDezzi(req.body.toString(), req.get('x-support-signature') ?? '')) return res.status(401).end();
  const call = JSON.parse(req.body);
  if (call.action === 'get_orders') {
    const orders = await db.orders.findMany({ where: { userId: call.user.id }, take: 5 });
    return res.json({ orders: orders.map((o) => ({ id: o.id, status: o.status, total: o.total })) });
  }
  res.status(404).json({ ok: false, reason: 'Unknown action' });
});

Add it on the Actions page as a read action. fromDezzi and the whole envelope are in Actions. Refunds and other changes are propose actions: your app checks them, you approve them in the inbox, and only then do they run.

Then