How to Add Asyntai AI Chatbot to Drupal

Step-by-step guide for Drupal websites

Get Embed Code

Step 1: Get Your Embed Code

First, go to your Asyntai Dashboard and scroll down to the "Embed Code" section. Copy your unique embed code which will look like this:

<script async src="https://asyntai.com/static/js/chat-widget.js" data-asyntai-id="YOUR_WIDGET_ID"></script>

Note: The code above is just an example. You must copy your own unique embed code from your Dashboard as it contains your personal widget ID.

Step 2: Using Header and Footer Scripts Module (Recommended)

The easiest way to add the chatbot is using the "Header and Footer Scripts" module:

  1. Log in to your Drupal admin panel
  2. Go to Extend and click "Install new module"
  3. Search for "Header and Footer Scripts" or download it from Drupal.org
  4. Install and enable the module
  5. Go to Configuration → Development → Header and Footer Scripts
  6. Click on the "Footer" tab
  7. Paste your Asyntai embed code in the footer scripts text area
  8. Click "Save configuration"

Tip: Adding the code to the footer section ensures it loads after the page content, which is recommended for chat widgets.

Alternative: Edit Theme Template

You can add the code directly to your theme's template file:

  1. Navigate to your theme folder: themes/your_theme/
  2. Open the html.html.twig file (or create one if it doesn't exist)
  3. Find the closing </body> tag
  4. Paste your Asyntai embed code just before the </body> tag
  5. Save the file
  6. Clear Drupal's cache: Configuration → Performance → Clear all caches

Important: Changes to theme files may be overwritten when updating your theme. Consider using a child theme or the Header and Footer Scripts module for a more permanent solution.

Alternative: Using Libraries (For Developers)

For developers who prefer using Drupal's asset library system:

  1. Create or edit your theme's *.libraries.yml file
  2. Add a new library entry:
    asyntai-chatbot:
    js:
    https://asyntai.com/static/js/chat-widget.js: { type: external, attributes: { async: true, data-asyntai-id: YOUR_WIDGET_ID } }
  3. Attach the library in your theme's *.info.yml file:
    libraries:
    - your_theme/asyntai-chatbot
  4. Clear Drupal's cache

Step 3: Verify Installation

After saving your changes and clearing the cache, visit your website in a new browser tab or incognito window. You should see the chat widget button in the bottom right corner. Click it to make sure it opens and works correctly.

Not seeing the widget? Make sure to clear Drupal's cache by going to Configuration → Performance → Clear all caches. Also try clearing your browser cache or viewing in an incognito window.