How to add an AI chatbot to Drupal

On Drupal, a chat widget is installed through The theme's html.html.twig, or the Asset Injector module. Requires a cache rebuild before the change appears. Self-hosted, so no plan gate.

Where it goes

The theme's html.html.twig, or the Asset Injector module

Availability: Self-hosted, so no plan gate.

Adding the chatbot to Drupal

  1. 1

    Install the Asset Injector module for a UI-driven approach, or edit your theme directly.

  2. 2

    With Asset Injector, add a new JS injector and paste the snippet's contents.

  3. 3

    To edit the theme, open templates/html.html.twig and paste before the closing </body>.

  4. 4

    Clear caches from Configuration → Performance.

  5. 5

    Requires a cache rebuild before the change appears.

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 Drupal

  • Drupal aggressively caches rendered markup; drush cr or a cache rebuild is required.

  • Editing a contrib theme directly is overwritten on update — use a subtheme.

Drupal questions

Where does the code go on Drupal?
The theme's html.html.twig, or the Asset Injector module. Requires a cache rebuild before the change appears.
Do I need a paid Drupal plan?
Self-hosted, so no plan gate.
Will a Drupal update remove it?
Drupal aggressively caches rendered markup; drush cr or a cache rebuild is required.
Does it slow Drupal 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 Drupal 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.