Set Up the AI Agent on Specific Pages

Set Up the AI Agent on Specific Pages

Introduction

The AI Agent can be displayed only on the pages where you want customers to interact with it, allowing you to provide targeted assistance while keeping your storefront uncluttered. By configuring page-specific visibility, you can control exactly where the AI Agent appears, such as product pages, collection pages, or other selected pages. In this article, you'll learn how to configure the AI Agent to appear only on specific pages of your store.


Here are the steps to setup Ai Agent on specific pages:

Notes
Note: Ensure that you have already created the AI Agent bot. To learn how to create it, click here.
Step 1: Go to AI Agent >> My bots and click on the code icon.



Step 2: Click on the Copy code button.



Step 3: Go to Shopify admin >> Online store >> click on the 3 dots to open the menu >> Click on Edit code.



Step 4: Search for theme.liquid and click on Theme.liquid from the results.



Step 5: Copy the code below and paste it just above the closing </head> tag in your theme file.



Notes
Note:
  1. You need to replace 'your page LINK like /pages/aiagent' with your page link.
  2. Paste the AI Agent script for the bot that you want to display on the specific page below the text -  {% comment %} Paste the code below {% endcomment %}
  3. Paste the AI Agent script for the bot that you want to display on all pages below the else code text which is - {% comment %} Paste the else code below {% endcomment %}

  1. {% if request.path == 'your page LINK like /pages/aiagent' %}
     {% comment %} Paste the code below {% endcomment %}
      {% else %}
      {% comment %} Paste the else code below {% endcomment %}
    {% endif %}



Step 6: Click on the Save button.



The AI Agent will now be displayed on your storefront only on the pages that match the conditions you have configured.









Notes
Note: Similarly, if you have 3 bots, you can show the bots on a specific page by using an elsif condition.

{% if request.path == 'your page LINK like /pages/aiagent' %}
 {% comment %} Paste the code below {% endcomment %}
{% elsif request.path == 'your page LINK like /pages/aiagent2' %}
 {% comment %} Paste the code below {% endcomment %}
{% else %}
  {% comment %} Paste the else code below {% endcomment %}
{% endif %}



    • Related Articles

    • Display the AI Agent on your storefront

      Introduction After creating and publishing your AI Agent, you can display it on your storefront to provide customers with instant, AI-powered assistance. This article explains how to enable the AI Agent widget on your Shopify store and verify that it ...
    • Enable and Create an AI Agent

      Introduction AI Agents enable you to provide instant, AI-powered support to your customers by answering their questions based on your store's knowledge base. In this article, you'll learn how to enable the AI Agents module, create a new AI Agent, and ...
    • Mark an AI Agent as Inactive

      Introduction If you no longer want your AI Agent to assist customers, you can mark it as Inactive. This will disable the AI Agent and prevent it from responding to customer queries until it is reactivated. This article explains how to mark an AI ...
    • View AI Agent Conversations

      Introduction The AI Agent Conversations section allows you to review all customer interactions handled by your AI Agent. You can view conversation details, monitor the AI Agent's responses, and analyze customer queries to evaluate performance and ...
    • Purchase Credits for Your AI Agent

      Introduction AI Agent credits are required to power your AI Agent and enable it to respond to customer queries. When your available credits run low, you can purchase additional credits to ensure uninterrupted AI-powered conversations and support. In ...