A framework for building Shopify webhook-driven automation jobs that run on Cloudflare Workers.
Create a new ShopWorker instance using npx:
npx create-shopworkerThis will:
- Clone the main ShopWorker repository
- Create a GitHub repository for your account-specific code
- Set up a
local/directory (cloned from your account repo) for your custom jobs - Create
.shopworker.jsonwith your Shopify credentials - Install dependencies
your-project/
├── core/ # ShopWorker framework (reference only)
│ ├── jobs/ # Example jobs (order, product, review, webrequest-example)
│ ├── triggers/ # Available webhook triggers
│ └── graphql/ # Reusable GraphQL queries
├── local/ # Your account-specific code (separate git repo)
│ ├── jobs/ # Your custom jobs go here
│ ├── triggers/ # Custom webhook triggers
│ └── wrangler.toml # Your deployment configuration
└── cli/ # Command-line tools
The local/ directory is a separate git repository for your account-specific customizations, while core/ contains the ShopWorker framework code.
To see the status of all jobs in your project:
node cli.js statusThis shows the status of all jobs in both core/jobs/ and local/jobs/.
Status types:
MANUAL: Job is triggered manually (no webhook needed)ENABLED: Job has an active webhook configuredNOT CONFIGURED: Webhook exists for this topic but isn't linked to this jobDISABLED: No webhooks found for this job's trigger topic
To enable a job by registering a webhook:
node cli.js enable your-job-nameThis will create a webhook in your Shopify store that triggers the job.
To disable a job by removing its webhook:
node cli.js disable your-job-nameTo test a job locally with sample data:
node cli.js test your-job-nameYou can provide custom parameters:
node cli.js test your-job-name --param key=valueCreate your custom jobs in the local/jobs/ directory. Each job requires:
config.json: Specifies which trigger to usejob.js: The job implementation
Example job structure:
// local/jobs/example-job/job.js
/**
* Brief description of what this job does
*/
export async function process({ payload, shopify, step, env }) {
// Use step.do() for all operations
const result = await step.do("operation-name", async () => {
// Your job logic here
return await shopify.graphql(YourGraphQLQuery, variables);
});
console.log("Job completed successfully!");
}See local/CLAUDE.md for detailed job development guidelines.
The core/jobs/ directory contains example jobs for reference:
- order: Order processing examples
- product: Product management examples
- review: Review handling examples
- webrequest-example: Web request handling patterns
Your custom jobs go in local/jobs/ and are specific to your Shopify store's needs.
ShopWorker uses .shopworker.json for Shopify credentials (created by npx create-shopworker):
{
"shopify_domain": "your-store.myshopify.com",
"shopify_token": "shpat_...",
"shopify_api_secret_key": "..."
}Your Cloudflare account ID is configured in local/wrangler.toml.
-
Ensure you have Wrangler CLI installed (should be installed via npm):
npx wrangler login
-
Update
local/wrangler.tomlwith your configuration if needed (this file is version controlled) -
Deploy using the CLI:
node cli.js deploy
The deploy command automatically:
- Copies
local/wrangler.tomlto the root (for wrangler to use) - Deploys your worker to Cloudflare
- Applies any pending database migrations
- Copies
-
Enable your jobs to register webhooks:
node cli.js enable your-job-name
Note: The root wrangler.toml is gitignored and automatically synced from local/wrangler.toml during deployment. Always edit local/wrangler.toml, never the root one.
To update the core ShopWorker framework:
git pull origin masterYour local/ directory is a separate repository, so framework updates won't affect your custom jobs.
- See
CLAUDE.mdfor development guidelines - See
local/CLAUDE.mdfor job creation patterns - Check
core/jobs/for example implementations