> For the complete documentation index, see [llms.txt](https://docs.eesel.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.eesel.ai/integrations/e-commerce/magento/magento-embed-chat-bubble.md). Agents can also search and read this documentation through its [MCP server](https://docs.eesel.ai/~gitbook/mcp).

# Embed the chat bubble in Magento

Embed the eesel AI chatbot on your Magento 2 storefront from Content > Design > Configuration, with the snippet Magento's RequireJS needs.

The eesel [chat bubble](https://docs.eesel.ai/integrations/chat-surfaces/chat-bubble.md) puts your AI agent on every page of your Magento 2 storefront. It answers shoppers from your store and your connected knowledge, and it looks orders and stock up live once [Magento is connected](https://docs.eesel.ai/integrations/e-commerce/magento.md). On Magento the snippet goes into a design setting, so you never edit a theme file.

Magento needs a different snippet from the one on the [Chat Bubble](https://docs.eesel.ai/integrations/chat-surfaces/chat-bubble.md) page. This page has the one that works, and the Magento Admin steps around it.

{% hint style="info" %}
**Using Claude Code, Codex or Cursor?** Ask it to create the chat bubble with the [eesel CLI](https://docs.eesel.ai/apis-and-developer-resources/cli), then paste the trigger id into the snippet below. The CLI makes the bubble; a Magento admin still has to save the snippet in Magento Admin.
{% endhint %}

## Before you begin

* Set up a chat bubble in eesel first. Ask your agent in the dashboard chat for a chat bubble on your store, then open **Integrations > Chat Bubble** and copy the trigger id shown beside the snippet. See [Chat Bubble](https://docs.eesel.ai/integrations/chat-surfaces/chat-bubble.md).
* [Connect Magento](https://docs.eesel.ai/integrations/e-commerce/magento.md), so the bubble can look orders and stock up.
* You need a Magento Admin user who can open **Content > Design > Configuration**.

## Why Magento needs its own snippet

Magento loads RequireJS on every storefront page, and RequireJS sets `define.amd`. While `define.amd` is set, the eesel loader registers itself as an AMD module instead of attaching to the page, so the plain snippet never draws the bubble and nothing reports an error. The snippet below clears `define.amd` while the loader runs and puts it back afterwards, so Magento's own scripts are unaffected.

If you paste the plain snippet and the bubble never appears, this is why.

## Add the snippet in Magento Admin

{% stepper %}
{% step %}

### Open the design configuration

Sign in to Magento Admin. In the left sidebar open **Content**, and under **Design** choose **Configuration**.

The grid lists every website, store and store view. Click **Edit** on the row for the store view you want the bubble on. Edit the Default row to cover the whole store, or one store view to put the bubble on a single language or a single brand's storefront.
{% endstep %}

{% step %}

### Paste the snippet into Miscellaneous HTML

Expand the **HTML Head** or **Footer** section and find **Miscellaneous HTML**. Use **Footer**, so the bubble loads after the page itself and does not hold the store up.

Paste the snippet below, and replace `YOUR_TRIGGER_ID` with the trigger id from your eesel Chat Bubble page.

```html
<script>
(function(){
  var TRIGGER = 'YOUR_TRIGGER_ID';
  window.__EESEL_WIDGET_V2_CONFIG__ = { EESEL_TRIGGER_ID: TRIGGER };

  var amd = window.define && window.define.amd;
  if (amd) { window.define.amd = undefined; }
  function restore(){ if (amd && window.define) { window.define.amd = amd; } }

  var script = document.createElement('script');
  script.src = 'https://cdn.eesel.ai/loader.js';
  script.async = true;
  script.onload = function(){
    var t0 = Date.now();
    var poll = setInterval(function(){
      if (window.EeselWidgetWithTrigger || Date.now() - t0 > 10000) {
        clearInterval(poll);
        restore();
      }
    }, 50);
  };
  script.onerror = restore;
  document.head.appendChild(script);
})();
</script>
```

If you are editing a store view rather than Default, clear the **Use Website** or **Use Default** tick beside the field first, or Magento keeps the inherited value.
{% endstep %}

{% step %}

### Save and refresh the cache

Click **Save Configuration**. Magento usually shows a cache notice at the top of the page. Follow it to **System > Tools > Cache Management**, tick **Page Cache** and **Configuration**, and refresh them. Until the page cache is refreshed, a cached storefront page still serves without the bubble.
{% endstep %}

{% step %}

### Check it worked

Open your storefront and reload it. The bubble sits in the bottom corner, and a fresh chat opens with your welcome message and your starter questions. Ask it something only your store knows, such as whether a product is in stock, to confirm the Magento connection is behind it.

To remove the bubble, clear the **Miscellaneous HTML** field, save, and refresh the cache again.
{% endstep %}
{% endstepper %}

## Troubleshooting

<details>

<summary>The bubble does not appear on the storefront?</summary>

Check you used the snippet on this page and not the plain one from the [Chat Bubble](https://docs.eesel.ai/integrations/chat-surfaces/chat-bubble.md) page. Then refresh **Page Cache** in **System > Tools > Cache Management**, since a cached page still serves the old footer. If you edited a store view, check the **Use Website** tick is cleared, or Magento ignores what you pasted. For a strict Content Security Policy, allow `https://cdn.eesel.ai` for scripts and connections.

</details>

<details>

<summary>The bubble appears, but the rest of the page is broken?</summary>

Something else on the page is holding `define.amd` when the snippet restores it. Take the snippet out, save, refresh the cache, and tell us what the browser console says. The snippet restores `define.amd` on load, on error, and after ten seconds either way, so it should never leave it cleared.

</details>

<details>

<summary>A chat bubble setting change is not showing?</summary>

Saved chat bubble settings reach a live bubble in about 30 seconds. You never need to paste the snippet again.

</details>

## FAQ

<details>

<summary>Do I need to edit my Magento theme to add the chat bubble?</summary>

No. **Miscellaneous HTML** adds the snippet to every storefront page in the scope you picked, without touching a theme file, and it survives a theme change.

</details>

<details>

<summary>Can I put the bubble on one store view only?</summary>

Yes. Edit that store view's row in **Content > Design > Configuration** instead of Default, and clear the **Use Website** tick beside **Miscellaneous HTML**.

</details>

<details>

<summary>Can the chat bubble look up a shopper's Magento order?</summary>

Yes, once Magento is connected. Your agent looks the order up live by its increment id or the shopper's email. See [Magento](https://docs.eesel.ai/integrations/e-commerce/magento.md) for the full action list.

</details>

## Related pages

* [Magento](https://docs.eesel.ai/integrations/e-commerce/magento.md) for what your agent does with the store, and the full action list
* [Set up Magento](https://docs.eesel.ai/integrations/e-commerce/magento/magento-setup.md) for the Magento Admin integration screens
* [Chat Bubble](https://docs.eesel.ai/integrations/chat-surfaces/chat-bubble.md) for every bubble setting
* [Actions and Approvals](https://docs.eesel.ai/instructions-and-memory/actions-and-approvals.md) for choosing what your agent may do


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.eesel.ai/integrations/e-commerce/magento/magento-embed-chat-bubble.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
