The SquawkVoice Chat Widget lets you place an AI chat assistant directly on any webpage. Visitors can type questions and get instant, intelligent responses — powered by the agent you built in the Studio.
This guide walks you through embedding the widget, customizing how it looks, and optionally passing customer details (like a name or account ID) so the agent can personalize every conversation.
Before You Start
Make sure you have:
- An agent built and saved in Studio → Build → AI Agents
- The assistant ID and public key for that agent (found in its Embed settings panel)
- Access to your website’s HTML source code
The widget is a small piece of HTML you paste into your website. It loads as a floating chat button, usually in the bottom-right corner of the page.
Get Your Embed Code
- Open your agent in Studio → Build → AI Agents.
- Click the Embed tab (or Widget Settings).
- Choose a Widget Version — use
latest unless you need to pin a specific release.
- Choose your starting theme:
light or dark.
- Copy the generated embed snippet.
Paste It Into Your Page
Open your website’s HTML and paste the snippet just before the closing </body> tag:
<squawkvoice-widget
assistant-id="your-assistant-uuid"
public-key="squawk_pk_your_public_key"
theme="light"
></squawkvoice-widget>
<script
src="https://app.squawkvoice.ai/widget/loader/squawk-chat-widget@latest.js"
defer
type="text/javascript"
></script>
That’s it — save your file, reload your site, and the chat button should appear.
The defer attribute on the script tag means it loads after the rest of your page, so it won’t slow down your site’s initial load time.
You can change how the widget looks directly from the Studio — no code changes needed.
| Setting | What It Controls |
|---|
| Theme | light or dark starting mode |
| Position | Corner of the screen: bottom-right, bottom-left, top-right, top-left |
| Display Title | The name shown at the top of the chat window (defaults to your agent’s name) |
| Logo | Your brand logo shown in the widget header |
| Colors | Custom primary color, text colors, and background for light and dark modes |
| AI Disclaimer | Optional fine-print text shown below the chat input |
Changes to these settings take effect automatically — you don’t need to update the embed code.
Step 3 — Pass Customer Data Into the Chat (Optional)
This is one of the most powerful features of the widget. You can tell the agent who the customer is before they type a single word — things like their name, email address, subscription plan, or account ID.
Think of it like giving your agent a briefing sheet before starting a conversation.
How It Works (Plain English)
- You define which pieces of customer information you want to share — these are called chat variables.
- You map each piece of information to a named slot in the agent (e.g.,
"customerName" → the agent’s interaction.CHAT.customer_name variable).
- When your page loads, your JavaScript puts the actual customer values into a global object called
window.SquawkVoiceChatVariables.
- The widget reads those values, strips them from the browser window (so other scripts can’t snoop on them), and sends them securely to the agent’s session.
- The agent can immediately use those values — in its greeting, its guidelines, or any API calls it makes on the customer’s behalf.
Chat variables require widget version 1.1.0 or later. If you’re on latest, you’re already covered.
Part A — Create the Variables in the Studio
Before the widget can pass any data, the agent needs to know where to store it.
- Open your agent and go to Pre-Call (or the Variables / Guidelines section).
- Create new variables of type INTERACTION.
- Name each variable using the prefix
interaction.CHAT. followed by a descriptive name.
Example variable names:
| Variable Name | What It Stores |
|---|
interaction.CHAT.customer_name | The customer’s display name |
interaction.CHAT.email | Their email address |
interaction.CHAT.account_id | Their account or user ID |
interaction.CHAT.plan | Their subscription tier |
This step connects your JavaScript keys (what you’ll type in your website’s code) to the agent variables you just created.
- In your agent settings, go to Widget Settings → Chat Variables.
- Click Add Mapping and fill in:
- Key — the name you’ll use in your JavaScript (e.g.,
customerName)
- Variable — the agent variable to receive the value (e.g.,
interaction.CHAT.customer_name)
- Default Value (optional) — a fallback if the page doesn’t provide a value (e.g.,
Guest)
Use the Default Value field for things like a customer name — set it to Guest so the agent always has something to work with, even for anonymous visitors.
Key naming rules:
- Must start with a letter (not a number or symbol)
- Can only contain letters (
a–z, A–Z), numbers (0–9), and underscores (_)
- Maximum 64 characters
Valid examples: customerName, account_id, planTier2
Invalid examples: 123customer, my-key, customer.name
Part C — Inject the Values on Your Web Page
On your website, define the window.SquawkVoiceChatVariables object in a separate <script> block that appears before the widget loader script. Use the exact key names you set up in Part B.
<script>
window.SquawkVoiceChatVariables = {
"customerName": "Sarah Johnson",
"email": "sarah@example.com",
"accountId": "acc_98765",
"plan": "Pro"
};
</script>
<squawkvoice-widget
assistant-id="your-assistant-uuid"
public-key="squawk_pk_your_public_key"
theme="light"
></squawkvoice-widget>
<script
src="https://app.squawkvoice.ai/widget/loader/squawk-chat-widget@latest.js"
defer
type="text/javascript"
></script>
In a real application, you’d replace the hardcoded values with dynamic ones from your server or session:
<script>
window.SquawkVoiceChatVariables = {
"customerName": "{{ current_user.display_name }}",
"email": "{{ current_user.email }}",
"accountId": "{{ current_user.id }}"
};
</script>
The window.SquawkVoiceChatVariables script block must come before the <script src=".../squawk-chat-widget.js"> tag. If the loader runs first, it won’t find your variables.
What Happens Behind the Scenes
You don’t need to understand this to use the widget, but it helps to know the widget is designed with security in mind.
- The loader reads your variables — When the widget loader script runs, it immediately reads whatever is in
window.SquawkVoiceChatVariables.
- It deletes the global object — The loader then removes
window.SquawkVoiceChatVariables from the browser window, so other scripts on the page can no longer access that customer data.
- Values are sanitized — Keys and values are validated: invalid types (objects, arrays, functions) are dropped; values are capped at 500 characters.
- A secure session is started — The widget establishes an authenticated session with the SquawkVoice backend using a challenge-response handshake. Your variables are sent as part of this secure session setup.
- The backend validates mappings — The backend only accepts keys that are explicitly configured in your Widget Settings. Any extra keys sent from the page are silently ignored.
- Variables become available to the agent — Once the session is established, your agent can reference these values in its greeting, guidelines, or during-call actions.
Limits & Constraints
| Constraint | Limit |
|---|
| Maximum chat variable mappings per agent | 20 |
| Maximum value length | 500 characters (longer values are truncated) |
| Key naming | Must start with a letter; letters, numbers, and underscores only |
| Maximum key length | 64 characters |
| Variable name format | Must use the interaction.CHAT. prefix in the Studio |
Troubleshooting
The chat button doesn’t appear.
- Check that both the
<squawkvoice-widget> tag and the <script src="..."> tag are present in your HTML.
- Make sure the
assistant-id and public-key attributes are filled in with your actual values (not placeholder text).
- Check your browser’s developer console (F12) for any JavaScript errors.
My customer variables aren’t reaching the agent.
- Confirm the
window.SquawkVoiceChatVariables script block is placed before the widget loader script in your HTML.
- Check that your key names match exactly what you configured in Widget Settings — they are case-sensitive.
- Make sure your keys follow the naming rules (start with a letter, no hyphens or dots).
- Verify you’re using widget version 1.1.0 or later — check the
src URL or set it to @latest.
The agent doesn’t use the variable values I passed.
- Confirm you’ve created matching
interaction.CHAT.* variables in your agent’s variable editor.
- Confirm each mapping in Widget Settings has both a Key and a Variable selected.
- Check that the variable is referenced correctly in your agent’s guidelines (e.g.,
{{interaction.CHAT.customer_name}}).
I’m seeing “Guest” instead of the customer name.
- Your default value is working as intended — it means the page didn’t pass a value for that key. Check that
window.SquawkVoiceChatVariables is being set with the correct data before the widget loads.