orki_webchat 0.1.0
orki_webchat: ^0.1.0 copied to clipboard
Official Flutter SDK for the Orki webchat — a WebView widget hosting the Orki chat UI, plus a headless OrkiChatClient for custom chat UIs. Supports authenticated identity via tenant-signed JWTs (setUs [...]
orki_webchat #
Official Flutter SDK for the Orki webchat. Two layers — use either:
OrkiWebchatWidget— drop-in WebView hosting the full Orki chat UI (bubbles, media, forms, typing, everything), with a native bridge for authenticated identity.OrkiChatClient— headless client (REST + SignalR) when you want your own chat UI on Orki's backend.
Widget quick start #
final controller = OrkiWebchatController();
OrkiWebchatWidget(
baseUrl: 'https://app.orki.ai',
tenantId: 'YOUR_TENANT_ID',
integrationId: 'YOUR_WEB_INTEGRATION_ID',
language: 'en',
userJwt: orkiUserJwt, // optional: tenant-signed identity JWT
controller: controller,
onEvent: (event) {
if (event.type == 'auth-required') {
// Fetch a fresh JWT from YOUR backend, then: controller.updateToken(freshJwt)
}
},
)
controller.setUser(jwt) / updateToken(jwt) / logout() / setPushToken(token) (capture
seam — push delivery ships later).
Headless quick start (custom UI) #
Requires the integration's auth mode to be jwt or both — the identity JWT replaces the
anonymous bot check, which has no headless channel.
final client = OrkiChatClient(
baseUrl: 'https://app.orki.ai',
tenantId: 'YOUR_TENANT_ID',
integrationId: 'YOUR_WEB_INTEGRATION_ID',
);
final session = await client.connect(identityToken: orkiUserJwt);
final history = await client.loadMessages();
client.messages.listen((m) => print('${m.senderName}: ${m.text}'));
await client.sendMessage('Hello!');
Minting the identity JWT (server-side ONLY) #
Sign {sub, iat, exp (≤24h), tenantId, integrationId} with HS256 using the integration's
signing secret (Dashboard → Integrations → Web → Authentication). Optional name/email
claims pre-fill the customer profile. The secret must never ship in the app binary.
WebView prerequisites #
JavaScript and DOM storage stay enabled (the widget layer sets both). Anonymous mode runs its bot check (Cloudflare Turnstile) inside the WebView — no extra setup needed.