Skip to main content

Build a Storefront AI agent

Build an AI chat agent that helps shoppers find products faster and complete purchases through natural conversation. The agent can answer questions about products, shipping policies, and manage shopping carts using the Model Context Protocol (MCP) to connect with Shopify's commerce features.

Use natural language to search for products, get recommendations, ask questions about store policies, and complete checkout—all within a chat window.

Requirements

Node.js v18.20 or higher

Download from nodejs.org and install.

Shopify Partner account

Sign up at shopify.com/partners.

Shopify development store with sample products

Create a dev store for testing - see the Development stores guide. Make sure to add some sample products.

Claude API Key

Generate a key in the Claude Console and store it securely. This template uses Claude, but you can swap in any LLM by updating the code.

Shopify CLI v3.79.0 or higher

Install the latest version of Shopify CLI. You'll need this before starting the tutorial.

Project

Anchor to Clone the repositoryClone the repository

Terminal

git clone https://github.com/Shopify/shop-chat-agent.git
cd shop-chat-agent

Anchor to Install dependenciesInstall dependencies

Terminal

npm install

Anchor to Set up environment variablesSet up environment variables

Rename the .env.example file to .env and make sure it has your Claude API key:

.env

CLAUDE_API_KEY=your_claude_api_key
Note

See the Change the AI provider section if you want to use a different LLM.

Anchor to Install the latest Shopify CLIInstall the latest Shopify CLI

Terminal

npm install -g @shopify/cli@latest

Anchor to Start the development serverStart the development server

Run the following command to start the development server and select your Shopify Partner organization:

Terminal

shopify app dev --use-localhost --reset

Anchor to Select the organization with access to the Dev DashboardSelect the organization with access to the Dev Dashboard

? Which organization is this work for?
> Organization name (Dev Dashboard)

Anchor to Select Yes to create this project as a new appSelect Yes to create this project as a new app

? Create this project as a new app on Shopify?
> (y) Yes, create it as a new app

Anchor to Accept the default app nameAccept the default app name

Hit enter to accept the default name shop-chat-agent. All references in the code use this name.

? App name:
> shop-chat-agent

Anchor to Keep the configuration file name blankKeep the configuration file name blank

? Configuration file name:
āœ” (empty)

Anchor to Overwrite existing configuration fileOverwrite existing configuration file

Select no and overwrite your existing configuration file:

? Configuration file shopify.app.toml already exists. Do you want to choose a different configuration name?
āœ” No, overwrite my existing configuration file

Anchor to Select your development storeSelect your development store

Choose the development store you would like to use:

? Which store would you like to use to view your project?
āœ” your-store

Anchor to Enter your store passwordEnter your store password

You can get your store password from the URL that is in your terminal:

? Incorrect store password (
https://your-store.myshopify.com/admin/online_store/preferences ). Please
try again:
> *****ā–ˆ________
Note

At this stage, you will see Preview URL: https://your-store.myshopify.com/... in your terminal. You can now proceed to the next step. If you get an error, restart from the Shopify CLI installation step.

Anchor to Generate a certificate for localhostGenerate a certificate for localhost

? --use-localhost requires a certificate for `localhost`. Generate it now?
> Yes, use mkcert to generate it

Anchor to Allow automatic URL updatesAllow automatic URL updates

Select yes to automatically update your app's URL:

Have Shopify automatically update your app's URL in order to create a preview experience?
> Yes, automatically update

Follow the Preview URL: https://your-store.myshopify.com/... in your terminal to open your store in your browser.

You will now be in the browser and on your store's Admin portal. Install the app when prompted.

Anchor to Enable the theme extensionEnable the theme extension

On your Admin portal, navigate to Online Store > Themes

  • Click the Customize button
  • Click the App embeds icon in the sidebar
  • Enable the toggle
  • Click Save

Congratulations!

Your AI shopping assistant is now fully functional for product search, cart management, and store policy questions.

You can start testing and customizing your app, or continue to the next section to enhance it with the customer accounts MCP server.

Early access

The Customer accounts MCP server is currently available in early access only. To request access to this feature, contact Shopify support. Our team will review your request and follow up with next steps. Early access features are subject to change.

Anchor to (Optional) Configure customer accounts authentication(Optional) Configure customer accounts authentication

Add order history and account management features to your AI assistant:

You'll need Level 2 protected customer data permissions to use the Customer accounts MCP server. See Shopify's guidelines.

Anchor to Verify Next-Gen Dev Platform accessVerify Next-Gen Dev Platform access

Verify that you have access to the Next-Gen dev platform. This is required for the customer accounts authentication features.

Anchor to Create your app on the Next-Gen Dev PlatformCreate your app on the Next-Gen Dev Platform

Follow the steps on the Next-Gen dev platform page to create a Storefront AI agent app using a partner organization. You can use the code from the reference app repo.

Anchor to Set up your development storeSet up your development store

Create a development store on the Next-Gen Dev Platform. Make sure to add some sample products to test the AI agent functionality.

Anchor to Log in to Shopify PartnersLog in to Shopify Partners

Log in to your Shopify Partners dashboard.

Navigate to Apps and select your app under the Developer Dashboard apps tab.

Click API access requests.

Anchor to Request protected data accessRequest protected data access

Click Request access under the Protected customer data section.

Anchor to Provide a reason for accessing protected dataProvide a reason for accessing protected data

Click select on protected customer data. Provide a clear reason for requesting this data.

Anchor to Provide a reason for accessing specific data fieldsProvide a reason for accessing specific data fields

Click select for each data field: name, email, phone, and address. Provide a clear reason for requesting each field.

Anchor to Update your app's TOML fileUpdate your app's TOML file

shopify.app.toml

# Add customer accounts MCP configurations

[mcp.customer_authentication]
redirect_uris = [
"https://your-app-domain.com/callback"
]

Replace your-app-domain.com with your actual app domain.

Anchor to Deploy your app and restart the serverDeploy your app and restart the server

Terminal

shopify app deploy
shopify app dev --use-localhost
Was this page helpful?