How to add an AI chatbot to Shopify Hydrogen

On Shopify Hydrogen, a chat widget is installed through app/root.tsx, inside the document body. Applies on your next Oxygen deploy. None beyond your Shopify plan.

Where it goes

app/root.tsx, inside the document body

Availability: None beyond your Shopify plan.

Adding the chatbot to Shopify Hydrogen

  1. 1

    Open app/root.tsx.

  2. 2

    Add the script element inside <body>, after the <Scripts /> component.

  3. 3

    Rebuild and deploy to Oxygen.

  4. 4

    Applies on your next Oxygen deploy.

The snippet you paste

<script src="https://rubyrep.com/rubyrep.js" data-rubyrep="rr_your_public_key" defer></script>

Your own key replaces rr_your_public_key — you get it after training RubyRep on your site.

Worth knowing on Shopify Hydrogen

  • Hydrogen sets a Content Security Policy by default — add the widget's origin to script-src and connect-src or it will be blocked.

  • Theme-level Shopify instructions do not apply to Hydrogen; this is a React app, not a Liquid theme.

Shopify Hydrogen questions

Where does the code go on Shopify Hydrogen?
app/root.tsx, inside the document body. Applies on your next Oxygen deploy.
Do I need a paid Shopify Hydrogen plan?
None beyond your Shopify plan.
Will a Shopify Hydrogen update remove it?
Hydrogen sets a Content Security Policy by default — add the widget's origin to script-src and connect-src or it will be blocked.
Does it slow Shopify Hydrogen down?
No measurable effect. The snippet is deferred, so it loads after your page has rendered, and the chat interface itself is only fetched when a visitor opens it.

Related

Get your snippet.

Enter your Shopify Hydrogen site and RubyRep reads it, builds your representative, and hands you the exact line to paste.

https://

Takes about a minute. No credit card.

Using something else? See all platforms.