Skip to main content

Embed a Knowledge

The Embed feature puts a Knowledge on any web page as a self-contained widget. Visitors browse its records, open the one they need, and ask its assistant questions on your site, without signing in.

What is the embed widget?

The embed widget is a public window onto one Knowledge. You decide what it shows (which views, in what order, whether visitors can search, filter or open a record, whether a chat is available) and Rational AI gives you a single <script> tag to paste into your site. The widget loads in an isolated frame and talks to your Knowledge through one embed key, so no Control Room sign-in is ever required of your visitors. Visitors can't edit your records, even in grids. They can add new ones through the contact form, which writes to the collection you choose, and what their chat costs counts against the Monthly budget.

Prerequisites​

Before you start, make sure you have:

  • Update rights on the Knowledge: Update on the Knowledge row of your role. Without it the Embed tab opens read-only. See Manage roles and users.
  • A Knowledge to publish: with the records or resources you want visitors to see, and the views you want to show them.
  • A place for the tag: access to the HTML of the page where the widget should appear, or a WordPress site with the Rational AI Observatory plugin.

Open the Embed settings​

Open the Knowledge, go to its settings, and select the Embed tab. The tab is a single page of sections, top to bottom:

SectionWhat you set there
GeneralWhether the widget shows all its views or one view alone, the assistant's system prompt, and the embed code.
Published viewsWhich views visitors can switch between, and in what order.
AppearanceLight or dark colors and the accent color.
ActionsFilters, view switcher, search and record details.
ChatWhether there is a chat, its options, and the limits on what visitors can spend.
StatisticsA collection that receives one record of activity per day.
Visitor contactsA collection that receives the details visitors leave, and the form they fill in.

Changes are applied with Save in the settings footer.

The Embed settings tab with the system prompt, the embed code and the toggles

The Embed settings tab, starting from the General section.

Choose between the widget and a single view​

The Embedded view dropdown in General decides the shape of the widget.

  • Widget with its views (the default): a header with the Knowledge's name, a toolbar, and every view you publish under Published views.
  • One of your views: that view alone, full page, "without the header and the view picker". Use it when the page should show one custom view, such as a map or a calculator, and nothing else. When a single view is published, the widget fits its height to the view's content.

Grid, dashboard and graph views can't be published alone; they are offered only inside the widget.

Set the system prompt​

The system prompt shapes how the widget's chat answers. Use it to give the assistant its role and its rules.

  1. In the General section, write a Custom system prompt, for example telling the assistant to answer only from this Knowledge's content.
  2. Select Save in the settings footer.

Publish and order the views​

The Published views section lists the Knowledge's views that can go on a public page, each with a drag handle and a switch.

  1. Switch on the views visitors should be able to see.
  2. Drag the rows into the order you want. The first view switched on is marked Opens first: it is the one the widget shows when it loads.
  3. Select Save.
Grids are published only when you switch them on

Until you change the list, every custom view and dashboard is published, but no grid view is: a grid shows your records, so it goes public only when you switch it on by name. A published grid is read-only, with the columns, groups and filters saved in the view; visitors can search, filter and sort it, never edit it. Calendar and graph views are never offered.

Switching off every view also switches off Views under Actions, and switching one on turns it back on. The built-in Grid (labeled Attributes in the widget) and Graph views appear in the widget's picker after your published views when they are enabled for the Knowledge itself, on its Views tab.

Set the appearance​

Under Appearance:

  • Colours: Match the visitor's device (the default), Light or Dark.
  • Accent colour: the color of "Buttons, links, the open record and the chat button." Choose Rational (the default), Blue, Indigo, Red, Orange or Graphite to sit well with your site.

Choose what visitors can do​

The Actions toggles decide which controls appear in the widget's toolbar and panels.

ToggleWhat it enables
FiltersFilter resources by category, tags and relations.
ViewsA view switcher, so visitors can move between the published views.
SearchA search bar over the resources.
Resource detailsA side panel with a record's details, annotations and chunks. It is also what makes record links work.

When Resource details is on, opening a record in the widget writes #r= followed by the record's ID into the address of your page, and closing it removes it. A visitor who wants to send someone straight to that record copies the page address from the browser: whoever opens it lands on your page with the same record already open.

Set up the chat​

The Chat section controls the conversation and what it may cost you.

OptionWhat it does
Chat"Show the assistant on the page." On by default. Switch it off for a widget that only shows content, such as a public register or a whistleblowing page. The other chat options keep their values while it is off.
Suggested questionsStarter prompts shown when the chat opens.
Source visibilityShows which sources were used to generate each response.
CopyA copy button on each message.
FeedbackLets visitors rate and report the AI's responses.
Messages per visitor per dayHow many questions one visitor can ask in 24 hours. The default is 20; leave it empty for no limit.
Monthly budgetOnce the chat has cost this much in a calendar month (UTC), it pauses until the next one. Empty, the default, means no cap.
The budget is counted in the currency your costs are reported in

The field has no currency symbol: the amount is compared with the model costs Rational AI records for this widget's conversations, in the same currency Governance reports them in. Because the check uses recorded costs, answers that were already being generated when the budget ran out still complete, so the month can end slightly above the figure you set.

When a visitor reaches their daily limit the chat input is locked with "You have reached today's message limit. Come back tomorrow to ask more."; when the budget runs out it reads "The chat is paused for this month. You can keep browsing the content." Everything else in the widget keeps working, and if you collect visitor contacts the form opens beneath the notice.

Collect visitor contacts​

The widget can invite visitors to leave their details, and save each one as a record in a collection you choose (for example the contacts collection of a CRM Knowledge).

  1. Under Visitor contacts, choose a collection in Save contacts to. Any collection of any Knowledge in your workspace can receive them.
  2. Enter the Privacy notice URL. It is linked from the consent box and is required.
  3. Optionally set a Form title and Form text.
  4. Arrange the Form fields. The form starts with Name, Email and Organization; drag them to reorder, rename the label visitors read, switch Required on or off, remove a field, or add another from Add field from the collection (text, date, number and choice attributes). An attribute the collection doesn't have yet is marked "will be created" and is added when you save.
  5. Select Save.

In the widget, a bell button in the chat header opens the form. The visitor ticks the consent box and selects Subscribe.

Keep the email field to recognize returning visitors

A visitor who submits again with the same email updates their existing record instead of creating a new one; your own values on that record are kept, and the new answers are added as a note. Without an email field, every submission is a new record. Each visitor can submit at most five times an hour. The form lives in the chat panel, so it is unavailable while Chat is off.

Keep daily statistics​

To see how the widget is used, choose a collection in Save statistics to under Statistics. Every night Rational AI writes one record there for the previous day, named after the Knowledge and the date, with:

  • Opens: times the widget was opened.
  • Records opened, and the five opened most.
  • Searches, and the five most frequent.
  • Conversations started and Messages sent in the chat.
  • Contacts: visitors who left their details.

Days with no activity get no record. The statistics are totals only: nothing in them identifies a visitor. Because they are ordinary records, you can chart them in a grid or a Rational BI dashboard.

Add the widget to your site​

  1. In General, if there is no code yet, select Generate embed code. This saves the settings and creates the widget's embed key.
  2. Choose where the widget goes with the HTML or WordPress pill.
  3. Select Copy embed code and paste it into your page.

For HTML, the code is a single tag:

<script src="https://control-room.example.com/embed.js" data-embed="ek-…" data-lang="en" async></script>

The widget appears exactly where the tag stands. data-lang sets the widget's language and starts as your own Control Room language; change it to match the page.

For WordPress, the code is a shortcode for the Rational AI Observatory plugin:

[rational_observatory embed="ek-…" origin="https://control-room.example.com"]

The page then also holds the records of the first published grid view as plain text, so search engines can read them; the widget replaces that text once it loads. The language follows the page.

See the widget​

On the page, the widget shows the Knowledge's name, the toolbar you configured (view picker, search, filters), the published views, a chat button in the corner if the chat is on, and an Open full view link that opens the widget in a tab of its own.

The embedded Knowledge widget on a page, showing the resource table, toolbar and chat launcher

The embedded widget: the Knowledge's records, the configured toolbar, and the chat button.

Rotate the embed key​

The embed key is what ties a published tag to your Knowledge. If a tag is ever shared where it shouldn't be, rotate the key to cut it off.

  1. In General, select the Rotate key button beside the embed code.
  2. Confirm in the Rotate embed key dialog.
  3. Copy the new code and replace it everywhere the widget is embedded.
Rotating breaks every published tag at once

Every page that still uses the previous key immediately shows "This widget isn't available". Only rotate when you're ready to replace the code wherever it's published.

Next steps​