Creating a Chat Agent

Configure a chat agent and prepare it for deployment on your website.

Creating a Chat Agent

This guide covers the main steps for setting up a new chat agent for your website.

Basic Settings

Instructions

Use the instructions field to define how the chat agent should behave. A strong prompt usually covers:

Writing Effective Instructions

Appearance

Customize the widget experience to better match your site:

Tools

Enable the tools the agent should be allowed to use:

Booking meetings in a chat. Turn on the calendar tools in the agent's tool list and the agent offers free times from a connected Google or Microsoft 365 calendar and books the one the visitor picks, as voice and SMS agents do. It uses the calendar of the person who created the agent. The agent asks for the visitor's email before booking, so the invite reaches them. Without one the meeting is still booked and linked to the visitor, and the Calendar page says no email is on the invite. The meeting shows on the contact's record and on the Calendar page, with a link back to the chat it was booked in.

Anyone can open a chat, so a visitor reaches only their own meetings:

Mail and file tools in a chat. Google Workspace and Microsoft 365 mail, drive and document tools run in a chat when you turn them on. Anyone who opens the chat can then ask the agent to read, send or change things in that account. The tool list says this under each one, so turn them on only when that is what you want.

Embedding the Widget

After saving, use the embed code snippet to place the widget on your website:

  1. Open the chat agent detail page
  2. Copy the embed code
  3. Paste it into your website's HTML, typically just before the closing </body> tag
  4. The widget will appear as a chat bubble in the corner of your site

The widget can be embedded on many kinds of websites, including static sites, WordPress, Shopify, and React applications.

Content Security Policy (CSP)

If your website uses a Content-Security-Policy header, you'll need to allow the widget's domain. Add these two directives:

Directive Value
script-src https://chat.karmaflow.ai
frame-src https://chat.karmaflow.ai

Example:

Content-Security-Policy: script-src 'self' https://chat.karmaflow.ai; frame-src https://chat.karmaflow.ai;

No additional connect-src, img-src, or style-src entries are needed — the chat UI runs inside an iframe with its own security policy. If your site does not set a CSP header, no action is needed.

Allowed origins

The widget answers only on the websites you list. In the agent editor, open the Embed tab and fill in Allowed Origins under Embed & Notifications: a comma-separated list of origins, such as https://example.com, https://www.example.com. An origin is the scheme and host (plus the port, if it is not the default), with no path. If the list is empty, the widget works on no website. Changes reach the live widget when you click Save & Push Live.

Testing on localhost (Development agents)

While you build a site, the widget often runs on http://localhost on a port that changes, or on preview addresses you cannot list in advance. A chat agent marked as Development can switch off its embed security instead:

  1. Open the agent editor. On the Setup tab, under Basic Configuration, set Environment to Development and save.
  2. Open the Embed tab. A section named Development: Embed Security appears below Embed & Notifications.
  3. Turn on Turn off embed security — load from any URL, including localhost.
  4. Click Save & Push Live. The widget now loads on any page, including http://localhost, without checking Allowed Origins and without its Content-Security-Policy.

While it is off, the editor's header shows an Any origin (dev) badge, the agent's view page reads Embed Security: Off, and its row on the Agents page reads Any origin (dev).

Things to know:

Testing

You can test the widget directly from the chat agent detail page before embedding it on your site.