A lightweight service for managing document updates in Shopify and syncing them with Marqo's vector search engine.
- Node.js (v14 or higher)
- npm or yarn
- A Shopify store with admin API access
- A Marqo account and API key
- Clone the repository:
git clone https://github.com/marqo-ai/shopify-marqo-connector.git
cd shopify-marqo-connector
- Install dependencies:
npm install
- Configure environment variables:
Create a
.env
file in the root directory with the following variables:
PORT=5000
SHOPIFY_WEBHOOK_SECRET=your_webhook_secret
MARQO_API_KEY=your_marqo_api_key
MARQO_URL=your_marqo_url
MARQO_INDEX_NAME=your_index_name
TEST_MODE=false
MARQO_CONFIG={"tensorFields":["multimodal"],"mappings":{"multimodal":{"type":"multimodal_combination","weights":{"image_url":0.9,"name":0.1}}}}
- Start the development server:
npm start
The server will start on port 5000 by default. You can change this in the .env
file.
To enable real-time product updates, you need to set up three webhooks in your Shopify admin:
-
Go to your Shopify admin panel
-
Navigate to Settings > Notifications > Webhooks
-
Click "Create webhook"
-
Create the following three webhooks:
a. Product Creation
- Event: Product creation
- Format: JSON
- URL:
https://your-domain.com/webhooks/products/create
- Webhook API version: 2024-01
b. Product Update
- Event: Product update
- Format: JSON
- URL:
https://your-domain.com/webhooks/products/update
- Webhook API version: 2024-01
c. Product Deletion
- Event: Product deletion
- Format: JSON
- URL:
https://your-domain.com/webhooks/products/delete
- Webhook API version: 2024-01
-
Set the webhook secret
- For one of the webhooks, copy the webhook secret
- Add it to your
.env
file asSHOPIFY_WEBHOOK_SECRET
- Ensure your server is accessible at the webhook URLs
Note: If you're testing locally, you'll need to use a service like ngrok to expose your local server to the internet.
- Google Cloud Platform account
- Google Cloud CLI installed
- Docker installed locally
- Build the Docker image:
docker build -t gcr.io/[YOUR_PROJECT_ID]/shopify-marqo-connector .
- Push the image to Google Container Registry:
docker push gcr.io/[YOUR_PROJECT_ID]/shopify-marqo-connector
- Deploy to Cloud Run:
gcloud run deploy shopify-marqo-connector \
--image gcr.io/[YOUR_PROJECT_ID]/shopify-marqo-connector \
--platform managed \
--region [YOUR_REGION] \
--allow-unauthenticated \
--set-env-vars="PORT=8080,SHOPIFY_WEBHOOK_SECRET=[YOUR_SECRET],MARQO_API_KEY=[YOUR_KEY],MARQO_URL=[YOUR_URL],MARQO_INDEX_NAME=[YOUR_INDEX],TEST_MODE=false,MARQO_CONFIG={\"tensorFields\":[\"multimodal\"],\"mappings\":{\"multimodal\":{\"type\":\"multimodal_combination\",\"weights\":{\"image_url\":0.9,\"name\":0.1}}}}"
When deploying to Cloud Run, you'll need to set the following environment variables:
PORT
: Set to 8080 (Cloud Run default)SHOPIFY_WEBHOOK_SECRET
: Your Shopify webhook secretMARQO_API_KEY
: Your Marqo API keyMARQO_URL
: Your Marqo instance URLMARQO_INDEX_NAME
: Your Marqo index nameTEST_MODE
: Set to false for productionMARQO_CONFIG
: JSON string containing your Marqo configuration
Once deployed, the service will automatically:
- Listen for Shopify webhook events
- Process product updates
- Sync changes with your Marqo index
To run tests locally:
npm test
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request