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 machine learning 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 fresh 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 Machine Learning model

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.

If your head hurts and you're finding the above difficult to understand, we'd love to help you out of course, at which point you can contact us below to get started.

Thomas Hansen

Thomas Hansen I am the CTO of AINIRO.IO AS. 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