Skip to content

Developer overview

View as Markdown

AgentMySite adds an AI support assistant to your website. It answers from the content you add, and it can take actions on your site through tools you define. Site owners can install it without writing code. This section is for developers who want to embed it in an app, connect it to their own backend, or review how it works.

CapabilityStatusWhere to start
Embed the widget with one script tag, on any site or single-page app Available JavaScript API
Label conversations with your signed-in user’s ID, name, and email Available Script attributes
Let the assistant call your code: look up orders, change settings, and more Available AgentActions
Show the chat full screen in a mobile app WebView (Flutter) Available Mobile apps
Manage sites, content, and conversations through a server-side REST API, and receive webhooks Coming soon REST API

The JavaScript API doesn’t yet include methods to open or close the chat or to listen for widget events. See What the API doesn’t include yet.

  • The loader (https://widget.agentmysite.com/loader/widget.js) is a small script that runs on your page. It draws the launcher, gets a short-lived chat session for the visitor, and opens the chat.
  • The chat runs in a sandboxed iframe served from widget.agentmysite.com. It can’t read your page, and your page can’t read it.
  • window.AgentMySite is the global object the loader adds to your page. You use it to register the handler that runs your AgentActions.
  • The API (api.agentmysite.com) authenticates the widget, checks that your page’s domain is allowed, finds relevant passages in your content, and streams the assistant’s answer.

Appearance and behavior (colors, assistant name, auto-open, light or dark mode) and the assistant’s welcome message and suggestion chips are set in the admin panel and delivered to the widget when the page loads, so you don’t redeploy your site to change them.

To show the assistant in a native app, load the widget’s mobile page, https://widget.agentmysite.com/mobile.html, in a WebView. The mobile page opens the chat full screen right away, without a launcher. Your app passes its settings in a window.AgentMySiteConfig object, set before the page script runs:

FieldDescription
siteKeyRequired. Your site key.
apiBase, iframeOriginThe API and widget hosts (https://api.agentmysite.com, https://widget.agentmysite.com).
visitorIdA stable ID your app keeps for the user, so conversations survive app restarts.
conversationIdThe conversation to resume, or null to start a new one.
customerId, customerName, customerEmail, shopDomainOptional labels, as on the web.

The page talks to your app through a JavaScript channel named AgentMySiteHost (for webview_flutter) or a handler with the same name (for flutter_inappwebview). It sends JSON events: ready, conversationChanged, toolCall, requestClose, navigate, and error. Your app answers tool calls with window.agentmysite.toolResult(toolUseId, result, isError) and can close the chat with window.agentmysite.close(). In a WebView, tool calls time out after 20 seconds.

These states come from the service, not from your code, but they help when you test your integration:

  • The widget doesn’t appear. The site key is missing or wrong, or the page’s domain isn’t on the site’s allowed list.
  • “This assistant is unavailable right now.” The site has used all its credits for the current billing period. The assistant answers again when credits renew or the plan changes.
  • “You already have a request with our team.” The visitor already has an open support ticket, so the widget doesn’t create another one.
  • An error after many messages. The visitor or the site reached a rate limit.