Skip to main content

Embed Your Agent on Your Website

Add your RightAsk AI agent as a live chat widget on any website by pasting two lines of code before your closing `</body>` tag.

K
Written by Khrystyna Maryniuk

Overview

Embedding your agent places a chat widget directly on your website so visitors can start conversations without leaving your page. The widget connects to your agent in real time, uses the configuration you set in RightAsk, and appears on every page where the snippet is installed.

Embedding is available on all plans, including Free. No upgrade is required.

Before You Start

  • You need at least one agent. If you have not set one up yet, complete Setting Up Your Agent With the Quick Start Wizard first.

  • You need access to your website’s HTML source so you can paste a code snippet before the closing </body> tag.

  • If your site uses a CMS (such as WordPress, Webflow, or Squarespace), check that platform’s documentation for how to add custom HTML to the footer area.

Finding Your Embed Code

  1. Select Agents in the left sidebar, under External Agents.

  2. Select the agent you want to embed.

  3. Select the Configuration tab.

  4. In the panel header, select the embed control. The Embed Your Agent dialog opens, described as “Add your agent to any website with a single code snippet”, and your code loads automatically.

Each agent has its own embed code, so check the agent name beside the tabs before copying.

The dialog shows your snippet alongside a short installation guide: copy it, open your HTML file, paste before </body>, and save.

Adding the Embed Code to Your Website

Your embed code consists of two <script> tags that must both be present. The first sets your agent’s token and API endpoint; the second loads the widget script.

<!-- RightAsk Chatbot Widget -->
<script>
  window.RightAskConfig = {
    embedToken: "YOUR_TOKEN",
    apiBaseUrl: "https://api.rightask.ai"
  };
</script>
<script src="https://widget.rightask.ai/widget.js" defer></script>

YOUR_TOKEN is replaced automatically with your agent’s actual embed token when you open the Embed dialog in RightAsk.

To install the snippet:

  1. In the Embed dialog, select Copy Code. The button label changes to “Copied!” to confirm the copy succeeded.

  2. Open your website’s HTML file in your editor or CMS.

  3. Locate the closing </body> tag near the bottom of the file.

  4. Paste both script tags immediately before </body>.

  5. Save and publish your changes.

Repeat steps 2–5 for any additional pages where you want the widget to appear. If your site uses a shared footer template, pasting the snippet once in the template is enough to cover every page.

What Happens Next

After you publish, reload your website in a browser. The chat widget should appear, in whichever corner you set as its Widget position in the agent’s configuration. Visitors can open it and start a conversation immediately.

Changes you make to your agent’s configuration in RightAsk (personality, messages, colors) take effect without updating the embed code.

Troubleshooting

The widget does not appear after pasting the code. Confirm that both script tags are present and that they are placed before </body>, not inside <head> or after </body>. Also check your browser’s developer console (F12) for JavaScript errors that may indicate a network or syntax issue.

The widget shows an embed token error. Your embed token is tied to a specific agent. If you deleted and recreated the agent, open the new agent from Agents, go to its Configuration tab, and copy the fresh code to replace the old snippet.

The widget loads but conversations are not reaching RightAsk. Verify that apiBaseUrl in the first script tag is exactly https://api.rightask.ai with no trailing slash. If your network or browser extension blocks requests to that domain, the widget will load but cannot send messages.

The widget appears on some pages but not others. The embed code is only active on pages where it is pasted. If your site does not use a shared footer template, add the snippet to each page individually.

The widget does not appear on one particular domain. If you set Allowed Domains during setup, the widget only loads on the domains you listed. Check that list on the final step of the setup wizard, and note that including or excluding www matters.

Did this answer your question?