# AI Sales Agent — Embed on Any Website

_Website Chat Widget_

Turn a chat widget into an AI sales agent for any website (yours or a site not built in CRMown): a two-line snippet, answers grounded in your AI agent's business knowledge, domain locking, and a daily AI-reply cap.

## Steps
1. Open Web Studio > Chat Widgets > your widget > Embed tab and copy the "AI Sales Agent Snippet" (two lines). Paste it before </body> on any website — it loads from our CDN and renders the same chat bubble.
2. Ground it in your business knowledge: on the Settings tab > AI Sales Agent, pick a "Knowledge source (AI agent)". The widget then answers from that agent's FAQs and business-context memories in addition to the widget's own knowledge base. Manage agents in AI > Agent Setup.
3. Lock it to your domains: enter "Allowed domains" (one hostname per line, e.g. example.com and www.example.com). When set, the chat refuses to run anywhere else, so nobody can paste your snippet on their own site and burn your AI quota. Leave empty to allow any site.
4. Cap daily spend: set "Daily AI reply cap" (default 500). After the cap, the widget politely asks visitors to leave their email instead of generating AI answers; the counter resets each day.
5. Pass visitor details from your site (optional): if your site knows who the visitor is, call CRMownAgent('setContext', { firstName, email, company, custom: {...} }) after the snippet. The agent greets them by name, skips asking for email, and the contact is created automatically.

## Tips
- Context passed via setContext is treated strictly as data — visitors and web pages cannot inject instructions that override the agent's rules.
- Handoff still works exactly like website chat: when a visitor asks for a human, the session posts to your Comm Pro escalation channel and replies flow back live.
- Sessions, transcripts, and captured contacts appear in the same places as website chat: the widget's Sessions tab and your Conversations inbox.

## Example
A SaaS company pastes the two-line snippet on their docs site (built in Webflow, not CRMown). The agent is linked to their "Sales" AI agent, so it quotes accurate plan limits from the FAQ knowledge, books demos for hot leads, and every visitor who shares an email lands in the CRM tagged with the page they chatted from.

## Troubleshooting
- **Chat shows "This widget is not enabled for this domain"** — Allowed domains is set and the embedding page's hostname isn't on the list (www vs bare domain counts as different hostnames). Fix: Settings > AI Sales Agent > Allowed domains — add the exact hostname shown in the browser address bar, including the www. variant if used.
- **Agent answers generically instead of using our business facts** — No AI agent linked as the knowledge source, or the linked agent has no FAQs/memories. Fix: Settings > AI Sales Agent > pick a Knowledge source. Then check AI > Agent Setup > that agent's FAQs — the retrieval matches the visitor's question against FAQ text.
- **Widget replies "leave your email and our team will follow up" to every question** — The daily AI reply cap was reached (bot traffic or a busy day). Fix: Settings > AI Sales Agent > raise the Daily AI reply cap. The counter resets automatically the next day.
