How to Connect your AI Chatbot to Shopify

How to Connect your AI Chatbot to Shopify

We've had the ability to connect your AI Chatbot to Shopify for a long time. However, we've never really documented these parts. Since we want our platform to be a DIY thing, where users can do at least the basics themselves, we figured the time is ripe for creating a writeup about the process.

The Shopify plugin

The first thing you'll have to do is to install our Shopify plugin. If you're inside your cloudlet, you can find it in the plugins menu item under manage. Below is a screenshot.

Installing the Shopify plugin

Click "Install" and wait until the process is finished. This will download and install the Shopify plugin, allowing you to create a scheduled task that synchronizes your Shopify products with your AI chatbot's training snippets.

Scheduling synchronization

The point about the Shopify integration is that you want it to execute as a scheduled task. This ensures that your cloudlet always have access to recent product information about your Shopify products.

A scheduled task in Magic is a Hyperlambda task that periodically executes some sort of job. The Shopify import task will retrieve all products from your Shopify API account, and create one training snippets for each product. Don't worry if you don't understand Hyperlambda, you can just copy and paste the code further down in this article into a task.

Creating a scheduled task that synchronizes your Shopify account with your AI chatbot

Code for your scheduled task

log.info:Ingesting data from Shopify
signal:shopify.products.ingest
   secret:shpat_YOUR_SHOPIFY_API_KEY_HERE
   shop:YOUR-STORE-NAME-HERE
   type:YOUR-MACHINE-LEARNING-TYPE-HERE
   base_url:"https://YOUR-WEBSITE-HERE.COM"
log.info:Done ingesting data from Shopify

You'll need to modify all the parameters in the above invocation to [shopify.products.ingest] to match your own values. Aria created a YouTube video a month ago illustrating how to do this.

The most difficult part is probably creating your Shopify API key, but Aria covers that extensively in the above video. When you're done with setting things up, you can test the task by clicking the "Execute" button, wait some few minutes, and verify that you're getting products imported into your machine learning type.

Obviously the machine learning type already needs to exist at this point.

When you're done with this, all that's left is to create a schedule for your task. We recommend importing at night. All dates are in UTC format, so if you schedule your task to execute 01:00, this implies UTC time. To synchronize at 01:00 UTC time you'll need to provide **.**.01.00.00 as a repetition pattern. Below is a screenshot showing you how to do this. Click schedule and chose "Custom repetition" and paste in **.**.01.00.00 as your value.

Scheduling your Shopify import task

Notice, during import your chatbot will not be able to recommend products. This is why we recommend that you import during the night, since it minimizes the risk of having users asking your chatbot a question it won't be able to answer. The import typically goes fast though. We've got clients with 2,000+ products that are able to import everything from their Shopify API account in 10 minutes.

However, since the chatbot won't be able to recommend products during import, we kind of recommend you schedule the task to execute during the night.

Notice, the API key you create in your Shopify account needs to have at the very least the following rights.

  • Read access to products
  • Read access to product_listings

We recommend not adding additional rights, since this minifies your attack surface. The above should be the only parts you need to add if all you want to accomplish is importing Shopify products into your AI chatbot. If you want to have additional Shopify integrations, such as order tracking, you may need to add additional rights to the API key.

Have a Custom AI Solution

At AINIRO we specialise in delivering custom AI solutions and AI chatbots with AI agent features. If you want to talk to us about how we can help you implement your next custom AI solution, you can reach out to us below.

Thomas Hansen

Thomas Hansen I am the CEO and Founder of AINIRO.IO, Ltd. I am a software developer with more than 25 years of experience. I write about Machine Learning, AI, and how to help organizations adopt said technologies. You can follow me on LinkedIn if you want to read more of what I write.

Published 10. Feb 2024

Uploading Files to your AI Chatbot

Sometimes you'll have training data for your AI chatbot in the PDF files, XML files, JSON files or YAML files. This article walks you through how to import such files.

Read More

Celebrating 10 Million Downloads

A couple of days ago we rounded 10 million downloads of our platform from Microsoft's NuGet repository.

Read More

Increasing the Quality of Your GPT Instructions

This article explains how you can increase the quality of your GPT instructions, just by making a small change in formatting.

Read More