https://github.com/bolajiayodeji/cl-twilio-webhooks-demo
A minimal demo for sending an SMS notification to customers when an SKU that had finished is back in stock using Commerce Layer Webhooks and Twilio SMS.
https://github.com/bolajiayodeji/cl-twilio-webhooks-demo
commercelayer twilio twilio-sms-api webhooks
Last synced: 6 months ago
JSON representation
A minimal demo for sending an SMS notification to customers when an SKU that had finished is back in stock using Commerce Layer Webhooks and Twilio SMS.
- Host: GitHub
- URL: https://github.com/bolajiayodeji/cl-twilio-webhooks-demo
- Owner: BolajiAyodeji
- Created: 2022-05-31T21:53:09.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-12-06T04:54:37.000Z (10 months ago)
- Last Synced: 2025-02-02T19:06:17.904Z (8 months ago)
- Topics: commercelayer, twilio, twilio-sms-api, webhooks
- Language: JavaScript
- Homepage:
- Size: 3.15 MB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# cl-twilio-webhooks-demo
A minimal demo for sending an SMS notification to customers when an SKU that had finished is back in stock using Commerce Layer Webhooks and Twilio SMS. To get started, kindly read the comprehensive tutorial on [Commerce Layer's blog](https://commercelayer.io/blog/a-comprehensive-guide-to-commerce-layer-webhooks).
---
Add your credentials in `.env`:
```bash
TWILIO_ACCOUNT_SID=""
TWILIO_AUTH_TOKEN=""
TWILIO_PHONE_NUMBER=""
CL_SHARED_SECRET=""
```Start the local server:
```bash
node server.js
```Start a ngrok HTTP tunnel listening for HTTP/HTTPS traffic on port 9000:
```bash
ngrok http 9000
```Create a new `in_stock_subscriptions.notify` webhook using the CLI:
```bash
cl webhooks:create \
-n "Back In Stock Notifications" \
-t "in_stock_subscriptions.notify" \
-u "https://39cb-8-21-8-251.eu.ngrok.io/callback" \
-i "sku"
```Create a new stock subscription associated with some custom metadata (telephone number and customer name) and required relationships (market ID, customer’s ID, and SKU ID).
```bash
cl resources:create in_stock_subscriptions -m \
customer_telephone="+12345678910" \
customer_name="Bolaji Ayodeji" -r \
market="VgKNLhKGBj" \
customer="OwyehaRvJX" \
sku="ZrxeSKVNRB
```