HTML and JavaScript
Install, configure, verify, and remove the floating agent with one public script.
Install, configure, verify, and remove the floating agent with one public script.
Prepare the site#
Publish the agent's site, open Embed, enable embedding, and add the final host-page origin. Add development and production separately; http://localhost:3000, https://example.com, and https://www.example.com do not match one another.
Install the script#
Paste the loader immediately before the closing </body> tag on every page that should show the launcher. Replace only the public site slug and optional presentation values.
<script
src="https://makeagent.fast/embed.js"
data-agent="YOUR_SITE_SLUG"
data-position="right"
data-label="Ask us"
data-accent="#6d5ce7"
data-locale="en"
async
></script>data-agent is required. The slug is public; no API key belongs in this tag. Omit optional attributes to inherit the site's appearance and automatic theme behavior. See Embed overview for every accepted value.
Choose site-wide or page-specific placement#
For a shared server-side template, place the script in the global layout/footer. For selected pages, include it only in those templates. Load the same slug once per document; duplicate same-slug tags are ignored, but removing duplicates keeps ownership and teardown predictable.
Do not paste the snippet into an HTML sanitizer or rich-text field that strips <script>. Confirm the rendered page source or Elements panel still contains the tag.
Remove or remount in an SPA#
Removing the script after it executes does not remove the launcher it already created. A route-specific client application must remove both the script and the slug-specific root before remounting:
const slug = "YOUR_SITE_SLUG";
document.getElementById("maf-agent")?.remove();
document.getElementById(`maf-embed-root-${slug}`)?.remove();Prefer keeping one site-wide root mounted across client-side navigation so the active conversation is not discarded. If you remove the root, append a fresh embed.js script to create it again.
Verify in the browser#
- Open the deployed page in a private window.
- Confirm
embed.jsreturns200and is not blocked by CSP/consent. - Confirm one
[data-maf-embed="YOUR_SITE_SLUG"]root exists. - Open the launcher and confirm the
/embed/YOUR_SITE_SLUGiframe loads. - Send a question and confirm the thread in Conversations.
- Test mobile width and microphone permission when voice is enabled.
Troubleshooting#
| Symptom | Fix |
|---|---|
Console warns about missing data-agent | Put the attribute on the exact embed.js tag |
| Script exists but launcher does not | Check publish/embed switches, exact origin, CSP, and consent state |
| Works on one hostname only | Add each actual scheme/host/port to the allowlist |
| Style differs from expected | Check data-accent, data-theme, and saved site appearance |
| Voice fails inside iframe | Allow microphone in browser and host Permissions Policy |
Never proxy or copy the loader into an unreviewed local fork; use the hosted script so origin validation and fixes remain current.