Skip to main content

Build a chatbot for your website

What you'll build: a chatbot for acruxcore.com. AcruxCore reads the site's pages from its sitemap into a knowledge base. An agent searches those pages and answers a visitor's question, such as "Can I run AcruxCore on my own servers?", with a link to the page it used. A chat widget then puts the agent on the site. Replace the sitemap with your own to build the same chatbot for your site.

GitHub

Before you start​

You need an AcruxCore account, an API key, and two models registered under Gateway → Models: a chat model and an embedding model. This page uses an OpenAI credential with the public names gpt-4o-mini and text-embedding-3-small. Route calls through the gateway shows how to add a credential and register a model.

Nothing to install. Step 1 copies the prompt from system-prompt.txt.

Each step shows two routes in one set of tabs. Dashboard is the click path, and curl calls the same endpoints from code.

1. Write the system prompt​

The prompt keeps the agent to what the site says, and asks it to link the page it used:

system-prompt.txt
You answer questions from visitors to the AcruxCore website, acruxcore.com.

Search the website before you answer, and answer only from the passages the search returns.
If the passages do not answer the question, say that you do not know, and point the visitor
to https://acruxcore.com/contact.

Keep each answer short: two to four sentences, or a short list.

When a passage you use has a url, end your answer with a Markdown link to that page.

Open Prompts and click New prompt. Name it website-chatbot and click Create prompt. Paste system-prompt.txt into the System message, then click Commit new version.

2. Read the website into a knowledge base​

A documents knowledge base holds the site's pages. Its sitemap tells the crawler which pages to read, and each page becomes one document with its URL.

Open Knowledge and click New knowledge base:

  • Kind: Documents
  • Name: Website chatbot pages. The model calls the base's search tool search_website_chatbot_pages, after this name.
  • Description: The pages of acruxcore.com: what AcruxCore does, its features, pricing, security, self-hosting and how to contact the team. The model reads this text to decide when to search.
  • Embedding model: text-embedding-3-small

Click Create, and open the base. In the Website section, set:

  • Sitemap URL: https://acruxcore.com/sitemap.xml
  • Page limit: 50
  • Refresh: Weekly

Click Save and crawl. The pages appear under Documents as they are read.

The Website section of the Website chatbot pages knowledge base: the sitemap https://acruxcore.com/sitemap.xml, a page limit of 50, a weekly refresh, the line 19 pages listed: 18 added, 1 needs text, and below it the documents list with each page's title and URL

The crawl reads 19 pages. One of them has less than 50 words of main text, so it is marked Needs text. Leave it for now. Add a website to a knowledge base shows how to send that page's text through the API.

The weekly refresh re-reads only the pages whose <lastmod> date in the sitemap changed. A page with no <lastmod> is never refreshed on its own; click Re-crawl whole site to update it.

3. Create the agent​

Open Agents and click New agent:

  • Name: Website chatbot
  • Prompt: website-chatbot. Alias then shows production (v1).
  • Model: gpt-4o-mini

Under Knowledge, click Attach knowledge base, pick Website chatbot pages, and set Results to return to 5. Click Create agent. The Tools panel lists search_website_chatbot_pages.

4. Ask the agent​

On the agent's page, click Chat and ask:

How do I report a security problem?

Steps shows the search the model made and the pages it got back, each with its URL. The answer links the support address and ends with a link to the security page.

The chat page of the Website chatbot agent: the question How do I report a security problem?, a search_website_chatbot_pages step, and the answer that links support@acruxcore.com and ends with a link to the security page

5. Put the agent on your website​

The widget is a chat button that runs the agent for your site's visitors. It runs only on the domains you list, and two limits bound what it can spend: messages per visitor per hour, and a daily spend cap.

On the agent's page, click the Embed on website tab:

  • Select Show this agent as a chat widget on my website.
  • Allowed domains: your site, such as example.com. Add localhost to try the widget on your own computer.
  • Title: Ask AcruxCore. Greeting: Hi! Ask me anything about AcruxCore.
  • Messages per visitor per hour: 20. Daily spend cap (USD): 2.

Click Save, then Copy code.

Paste the tag before </body> on each page that should show the chat:

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

A visitor clicks the button in the bottom-right corner and asks a question. The answer shows its links, and a thumbs-up and a thumbs-down button to rate it.

A web page with the Ask AcruxCore chat panel open: the greeting, the question Can I run AcruxCore on my own servers?, the agent's answer that the whole stack can be self-hosted, ending with a link to the self-hosting page, and the thumbs-up and thumbs-down buttons under it

On the agent's Chat page, conversations that visitors started are labelled Website. Embed an agent on your website covers the widget's settings, visitor ratings and costs in detail.

Run it​

The scripts run steps 1 to 5 for you. Run the setup once, then ask as often as you like:

cd scripts/tutorials/build-a-chatbot-for-your-website
bash bash/setup_website_chatbot.sh
bash bash/ask_website_chatbot.sh
Crawled 19 pages: 18 added, 1 need their text, 0 failed
Agent Website chatbot (749cc96e-f5fb-484f-9673-8a624aa148da)
Paste before </body>:
<script src="https://acruxcore.com/widget.js" data-agent="emb_knAf5TUttnw9yCEpAfTcEgVt" async></script>
Q: Can I run AcruxCore on my own servers?
model calls search_website_chatbot_pages({"query":"self-hosting AcruxCore"})
A: Yes, you can run AcruxCore on your own servers. It is open-source under the Apache License 2.0, which means there is no license fee associated with self-hosting; you only need to cover your server costs. For more details on self-hosting, you can check the specific instructions [here](https://docs.acruxcore.com/docs/getting-started/self-host-with-docker).
status=succeeded cost=$0.00049364 trace=47fcbc2e-adb0-4912-ba38-c2fa7287f968

Q: Do I pay a markup on model tokens?
model calls search_website_chatbot_pages({"query":"model tokens markup AcruxCore"})
A: No, you do not pay a markup on model tokens when using AcruxCore. You connect your own provider credentials and pay the provider’s rates directly, as the gateway records the cost of each call without adding any additional fees. For more information, you can visit the FAQ page [here](https://acruxcore.com/faq).
status=succeeded cost=$0.00084464 trace=79098130-36a1-49ec-97f4-1bd90a146dba

Q: How do I report a security problem?
model calls search_website_chatbot_pages({"query":"report security problem AcruxCore"})
A: To report a security problem with AcruxCore, you should email [[email protected]](mailto:[email protected]) with steps to reproduce the issue and any relevant details. Security reports are prioritized, so you can expect them to handle your report with urgency. For more information on their security practices, you can visit their [security page](https://acruxcore.com/security).
status=succeeded cost=$0.00113309 trace=73a8670a-f727-4d6d-a679-19bf53c09b46

The setup reads the model names from CHAT_MODEL and EMBED_MODEL, which default to gpt-4o-mini and text-embedding-3-small. Set SITEMAP_URL to your own sitemap and SITE_DOMAINS to your own domains, separated by spaces. To start again, run the teardown script, which deletes the agent, the prompt and the knowledge base with its pages.

What's next​