Integrations
Webhooks allow your commerce platform (Shopify, Square, etc.) to push real-time updates to the LLM Gateway, ensuring that the AI always has the latest intelligence.
While the gateway proxies most requests live, webhooks are essential for:
sessionId when a user completes a checkout on your web storefront.If you are using the Better Data Cloud, you can configure webhooks via the dashboard. If you are self-hosting, you can use our built-in webhook handlers.
1import { createWebhookHandler } from '@commercegateway/commerce-gateway/webhooks';2 3const handler = createWebhookHandler({4 secret: process.env.WEBHOOK_SECRET,5 onInventoryChange: async ({ productId, available }) => {6 "cmt">// Update your cache or notify active sessions7 },8 onOrderComplete: async ({ sessionId, orderId }) => {9 "cmt">// Finalize the conversational session10 }11});12 13"cmt">// Use with a Hono or Express server14app.post('/api/webhooks', async (c) => {15 return await handler.handle(c.req);16});| Event | Platform | Description |
|-------|----------|-------------|
| inventory.updated | Shopify, Square | Change in stock levels. |
| order.created | Shopify, Square | A new order was placed. |
| product.updated | Shopify, Square | Change in price, description, or images. |
| checkout.completed | Better Data Cloud | A conversational checkout was successful. |
Every webhook request must be signed. The gateway automatically verifies:
WEBHOOK_SECRET likely doesn't match the one provided by your commerce platform.200 OK within 2 seconds. Move heavy processing to a background queue.