Generating embedded web chat
To simplify integration with your website, the CLI includes theorchestrate channels webchat embed command. This command takes the name of an agent and produces a script tag that you can place in the <head></head> section of your page for the currently active environment.
BASH
OUTPUT
Embedded chat security
By default, security is enabled, but not configured for the embedded chat. This means:- The embedded chat will not function until security is properly configured
- You must configure both IBM and client key pairs for the chat to work
- Alternatively, you can explicitly disable security to allow anonymous access
Security Architecture
The embedded chat uses RSA public-key cryptography to secure communication. The configuration involves two key pairs:-
IBM Key Pair
- Generated by: watsonx Orchestrate service.
- Public key: Shared with your application. Your application uses this key to encrypt the
user_payloadsection of the JWT sent to watsonx Orchestrate. - Private key: Stored securely by watsonx Orchestrate.cUsed to decrypt the
user_payloadsection of the JWT.
-
Client Key Pair
- Generated by: You (or a security configuration tool).
- Public key: Shared with watsonx Orchestrate. Used to verify that JWTs originate from your application.
- Private key: Remains with you and must be stored securely. Used to sign JWTs sent to watsonx Orchestrate.
-
JWT Authentication
- When security is enabled, your application must:
- Generate a JWT signed with your private key (Client Key Pair).
- Include the JWT in all requests to the Embedded Chat API. watsonx Orchestrate validates the token using your public key.
- When security is enabled, your application must:
- All requests to the Embedded Chat API must include a valid JWT token
- The token must be signed with your private key
- The watsonx Orchestrate service validates the token using your public key
- This prevents unauthorized access to your watsonx Orchestrate instance
- Requests to the Embedded Chat API do not require authentication
- Anyone with access to your web application where chat is Embedded can access your watsonx Orchestrate instance. In addition, your Watson Orchestrate instance allows anonymous authentication to a limited set of Apis, which is required to get your embed chat to work for anonymous users.
- This option should only be used for specific use cases where anonymous chat access is required.
- Ensure your watsonx Orchestrate instance in this case, does not provide access to sensitive data or access to tools configured with functional credentials that access sensitive data.
Enabling security
1
Prerequisites
- IBM watsonx Orchestrate instance
- API Key with administrative privileges
- Service Instance URL from your watsonx Orchestrate instance
- On macOS and Linux: OpenSSL installed on your system (for key generation)
- Python Installed on your system (for key extraction from APIs)
2
Get the `wxO-embed-chat-security-tool.sh`
Copy the following automated script to configure security:
wxO-embed-chat-security-tool.sh
3
Change the script's permissions
On Unix-based systems (macOS and Linux), change the permissions to run the script:
4
Run the script
Run the script and follow the instructions to enable or disable security:
- The tool generates an IBM key pair via the API
- The tool generates a client key pair using OpenSSL
- Both public keys are configured in the service
- Security is enabled
wxo_security_config directory:
ibm_public_key.pem: IBM’s public key in PEM formatibm_public_key.txt: IBM’s public key in single-line formatclient_private_key.pem: Your private key (keep it secure!)client_public_key.pem: Your public key in PEM formatclient_public_key.txt: Your public key in single-line format
Context variables for embedded web chat
To use context variables in embedded web chat, include them inside the JWT token. You can add context variables to a JWT token using a JavaScript script. The following script shows how to include context variables inside a JWT token:createJWT
JavaScript
Customizing embedded web chat
Configuring header
Header is an optional property in WXOConfiguration that controls whether header actions appear.| Parameter | Type | Description |
|---|---|---|
header.showResetButton | boolean | Displays the Reset Chat button in the header when set to true. Default is true. |
header.showAiDisclaime | boolean | Displays the AI disclaimer icon/button in the header when set to true. Default is true. |
Customizing styles
You can customize embedded web chats to create a unique chat interface that better fits your webpage. To apply custom styles, add astyle component inside the window.wxOConfiguration object in your web chat script. In this component, you can configure the following elements:
| Parameter | Type | Description |
|---|---|---|
headerColor | string | Set a six-digit hex code that defines the chat header color. |
userMessageBackgroundColor | string | Set a six-digit hex code that defines the user message bubble color. |
primaryColor | string | Set a six-digit hex code that defines the interactive elements color. |
style.showBackgroundGradient | boolean | Displays the background gradient when set to true. Default is true. |
style component inside window.wxOConfiguration:
JavaScript
Customizing layout
The watsonx Orchestrate embed supports a flexiblelayout object to control how and where the chat UI appears.
| Parameter | Type | Default | Description | |
|---|---|---|---|---|
rootElementID | string | — | (fullscreen-overlay only) ID of the container node to mount chat into. | |
showLauncher | boolean | true | (fullscreen-overlay only) Show the bubble launcher (true) or render chat immediately (false). | |
layout.form | string | float | Defines the layout form of your web chat. Use fullscreen-overlay to display the web chat in fullscreen mode. No additional parameters are required.Use float to display the web chat as a floating window. Also configure:
custom to define a custom layout. Also configure the customElement parameter with your custom element. | |
layout.width | string | — | (float only) Popup width (e.g. ‘350px’, ‘30rem’). | |
layout.height | string | — | (float only) Popup height (e.g. ‘500px’, ‘40rem’). | |
layout.showOrchestrateHeader | boolean | true | Render the standard header bar (true) or hide it | (false). |
layout.customElement | HTMLElement | — | element reference to render into. |
JavaScript
JavaScript
Enabling thumbs-up and thumbs-down
In the embedded chat, you need to manually enable thumbs-up and thumbs-down feedback usingpre:receive handlers. First, subscribe to the pre:receive event to inject feedback options. Then, handle submitted feedback through the feedback event.
The following script shows how to configure feedback in the embedded chat:
JavaScript
Events reference
Embedded web chat supports a variety of events that allow you to trigger specific actions or customize behavior. The following tables list all supported events, grouped by category.Customization Events
| Event name | Description |
|---|---|
userDefinedResponse | Triggered when a response contains an unrecognized or user_defined response type. |
Message Events
| Event name | Description |
|---|---|
pre:send | Triggered before the web chat sends a message to the assistant. |
send | Triggered after the web chat sends a message to the assistant. |
pre:receive | Triggered before the web chat receives a response from the assistant. |
receive | Triggered after the web chat receives a response from the assistant. |
pre:restartConversation | Triggered before the conversation restarts. Useful for alerting the user that the chat will reset, allowing them to complete any ongoing actions (e.g., finishing a tool call). |
restartConversation | Triggered after the conversation restarts, before a new session begins. Useful for displaying specific UI elements when a new session starts. |
View Events
| Event name | Description |
|---|---|
view:pre:change | Triggered before the view state changes. |
view:change | Triggered after the view state changes. |
pre:threadLoaded | Triggered when a user navigates to a chat thread in full-screen embedded chat. Useful for displaying custom responses or UI elements. |
Security Events
| Event name | Description |
|---|---|
identityTokenExpired | Triggered when security is enabled and the JWT token expires. |
authTokenNeeded | Triggered when the embedded chat requires a refreshed or updated authentication token. |
Miscellaneous Events
| Event name | Description |
|---|---|
chat:ready | Triggered when the web chat is fully loaded and ready to receive user input. Useful for displaying a welcome message or initializing UI components. |
Events example
The following example shows how to configure events in the embedded web chat:JavaScript

