Skip to main content

Embed an agent on your website

What you'll do: put the Help desk agent on a shop's help page as a chat button. A visitor clicks it, asks "can I return a tent I used once?", and gets the agent's answer. The agent searches the same policies and orders as it does in the dashboard. Your site needs one <script> tag and no code of its own.

The agent is the one from Build a help-desk agent from documents and a spreadsheet. Any agent that answers on its Chat page works the same way.

1. Turn on the widget​

Open Agents → Help desk and click the Embed on website tab.

  • Show this agent as a chat widget on my website: turns the widget on. Clear it to stop the widget everywhere at once.
  • Allowed domains: the sites the widget may run on, one per line. example.com allows that host only, and *.example.com allows its subdomains, such as shop.example.com. A pasted address such as https://example.com/help is saved as example.com. To try the widget on your own computer, add localhost.
  • Title, Colour and Greeting: what the chat shows. An empty title uses the agent's name.
  • Messages per visitor per hour: how many messages one IP address may send. The default is 20.
  • Daily spend cap (USD): when the widget's model calls reach this amount in a day, it stops answering until 00:00 UTC. The default is 5. Only an owner or admin can change it.

Click Save. The panel on the right shows the code for your site and what the widget has spent today. Only an owner or admin can make the first save, because that save creates the widget's key. After that, an editor can change every setting except the daily cap.

The Embed on website tab of the Help desk agent: the widget turned on, the allowed domains localhost and *.example.com, the title Gear shop help, a teal colour, a greeting, 20 messages per visitor per hour and a 2 USD daily cap, and on the right the script tag, today's spend and the preview button

Preview the widget here loads the real widget on the dashboard page. The dashboard is always allowed, so you can try the chat before you list any of your own domains. Preview messages run the agent and count toward the cap.

2. Add the code to your site​

Click Copy code and paste the tag before </body> on each page that should show the chat:

<script src="https://acruxcore.com/widget.js" data-agent="emb_5fr80X21uAZhh71jHuMV9eFM" async></script>

data-agent is the widget's public id. It is not a secret: anyone can read it in your page's source, and the allowed domains, the per-visitor limit and the daily cap decide what it can be used for. A self-hosted AcruxCore serves the same file from its own domain, and the code on the tab shows that address.

If your site sends a Content-Security-Policy header, add the AcruxCore address to script-src and connect-src, or the browser blocks the widget.

3. Chat as a visitor​

Open a page with the tag and click the chat button in the bottom-right corner.

A shop's help page with the chat panel open: the title Gear shop help, the greeting, the question Can I return a tent I already used on one trip?, and the agent's answer that a used tent can be returned within 30 days if it is clean, dry and undamaged, for an 80% refund, with thumbs-up and thumbs-down buttons under it

The widget keeps the conversation in the visitor's browser, so it is still there after a reload or on another page of the same site. The pencil button in the header starts a new conversation. On a phone the chat fills the screen.

Under each answer are a thumbs-up and a thumbs-down button. A click saves the rating at once and opens a box for an optional comment, and Send feedback adds the comment to that rating. A visitor who clicks the other thumb later changes the rating.

The chat panel with the answer about returning a used tent, its thumbs-up button pressed, and below it the comment box with the text Clear answer, and it gave the refund amount. and a Send feedback button

The widget draws nothing on a site that is not in the allowed domains, and the browser console shows one warning that says so.

4. Read the conversations​

On the agent's Chat page, conversations that visitors started are labelled Website. Open one to see each answer with its steps, and click View trace to read the run step by step, as for any other run.

The agent's Chat page with two conversations labelled Website and one from the dashboard; the open website conversation shows the visitor's two questions, a search step and a SQL step, and the answers with View trace links

A visitor's rating and comment are saved on the answer's trace as End user feedback. They show in the trace's Feedback panel and on Observability → Feedback, which also averages the ratings by prompt version, so you can see which version of the agent's prompt visitors rate lower.

The Feedback page with a summary row for the help-desk prompt version 1, three ratings with two thumbs down, and below it three End user ratings: a thumbs down with the comment I also wanted to know which carrier you use., a thumbs up with the comment Clear answer, and it gave the refund amount., and a thumbs down with no comment

The widget's model calls run under a virtual key named Website widget: Help desk, so Gateway → Usage can show its spend apart from the rest of the team's. The daily cap is a budget on that key, and it is listed under Gateway → Budgets.

What limits the cost​

The widget runs your agent on your provider account, and its address is public. Three settings bound what a visitor, or anyone who copies the code, can spend:

  • Allowed domains: the API answers a browser only when the page is on one of them, so another website cannot show your widget. A script that calls the API directly is not a browser and can claim any domain, which is why the next two limits exist.
  • Messages per visitor per hour: counted per IP address. Messages over the limit are refused before the agent runs.
  • Daily spend cap: once the day's spend reaches it, the widget answers no new messages. The spend includes the agent's searches as well as its chat calls. The visitor sees "This assistant has reached its limit for today."

To stop the widget at once, clear the switch and save. Revoking the widget's key under Gateway → Virtual keys, or deleting its budget under Gateway → Budgets, also stops it, and the next save on the tab puts back whichever is missing.

A visitor never sees the agent's tool calls, the passages it found, SQL rows, costs or traces. The widget receives the visitor's own messages, the agent's answers and the visitor's own ratings, nothing else. A rating does not count toward the messages-per-hour limit, and each answer keeps one rating, so a new rating replaces the old one.

Next steps​