Prerequisites
- Your client ID. Find it under Behavior → Channels → Chat → Installation, in the Quick start snippet.
- Every variable you pass is declared in Context Variables.
The chat page
The WebView loads this HTML. It setswindow.twConfig and loads the full-page
chat script:
string
required
Your Typewise chat client ID.
object
Context about the signed-in user, such as
user_email. These values are
unverified.string
A JWT from your backend, for values that must pass the Trusted only check.
See Identity
verification.
clientId and
variables. Serialize the configuration as JSON instead of pasting values into
the script, so a quote or </script> in a value can’t break the page or inject
code. Load it with https://platform.typewise.app/ as the base URL, so the
script and its resources resolve correctly.
Load it in a WebView
- iOS (Swift)
- Android (Kotlin)
1
Add a WKWebView
Present a full-screen
WKWebView from a view controller or SwiftUI
view, constrained to the safe area or the full screen.2
Build the HTML
3
Load the HTML with the Typewise base URL
WKWebView runs JavaScript by default. If you pass a custom
WKWebViewConfiguration, don’t disable it.Domain allowlist
While your chat’s Domain allowlist is empty, the chat loads from any origin, including a WebView. If you’ve added domains, the WebView must load from an allowed origin. Loading the HTML with the base URLhttps://platform.typewise.app/ covers this. If you
use a different base URL, add that origin under Behavior → Channels → Chat →
Installation, or contact support to allow your app.
Troubleshooting
The WebView stays blank
The WebView stays blank
Check that JavaScript is enabled (and DOM storage on Android), and that the
base URL is
https://platform.typewise.app/. If your app applies a Content
Security Policy, allow the domains in Configure
CSP.The chat fails with a domain or origin error
The chat fails with a domain or origin error
The WebView’s origin isn’t in your Domain allowlist. See Domain
allowlist.
Related
- Identity verification: pass the user’s identity as verified values
- Chat configuration: appearance, guidance, and installation