Skip to main content

Embedding Agents

You already have the ability to create agents on top of your lakehouse. With embedding, you can take those same agents and drop them into your own apps, websites, or any third-party tool — with just one line of code.
Embedded agents
The embedded agent connects to the same data sources, tools, and model configuration you set up in Datazone, so your users get the full conversational experience without ever leaving your product.
Embedded agent in drawer mode

Overview

Embedding works through a secure, token-based mechanism:
  1. Your server generates a signed JWT token containing the agent ID and embedding configuration.
  2. The token is used to build a signed script URL.
  3. You drop a single <script> tag into your HTML, and the agent renders inside your application.
The token is signed with your secret key on the server, so credentials are never exposed to the browser.

Widget Types

When embedding, choose how the agent appears in your application:
Embedded agent widget types

Integration Steps

1. Generate the Signed Script URL

Insert this snippet into your server code to generate the signed script URL. The secret key must stay on the server — never expose it in client-side code.
You can use user_id instead of email in the payload for user identification based on your application’s needs.

2. Add the Script to Your Page

Then insert this snippet into your HTML template or single page app:
Replace {scriptUrl} with the signed URL generated on your server.
The container <div> is only needed for the full widget. The bot and drawer widgets render their own floating UI and ignore the container.

Embedding Parameters

The JWT token payload can include the following parameters:

embedding_config Options

Example: Full Server-Side Implementation

Here’s a more complete example using Node.js / Express:

Security Considerations

  • Keep your Datazone secret key secure and never expose it in client-side code.
  • Generate tokens server-side and pass the complete script URL to your frontend.
  • Use the email or user_id field to scope access and track usage per user.
  • Set appropriate content security policies for embedding.

Troubleshooting

If your embedded agent isn’t loading correctly:
  1. Check that your token is signed correctly with the right secret key.
  2. Verify that the agent ID is correct.
  3. For the full widget, ensure the datazone-agent-embed-container div exists on the page.
  4. Look for CORS or CSP issues in your browser’s developer tools.

Next Steps