This example demonstrates how you can send an order confirmation SMS via Twilio using Moltin webhooks.
When running this example locally it's recommended you use a service like ngrok to tunnel your dev environment to the outside world.
Once you have the repo running locally, you'll want to add the integration via the Moltin Dashboard. The URL
will be the one provided by ngrok.
Clone the repository:
git clone git@github.com:moltin/integration-examples.git
Install dependencies with Yarn
cd integration-examples/order-confirmation-sms
yarn
In this example we will send our order confirmation via Twilio. You will need an account an account to continue.
Once you've signed up, head over to their Programmable SMS page and Get a number. You'll have to enter your address to comply with local regulations but once done, you'll have a new phone number.
Next you will need to get your Account SID
and Auth Token
. You can get these by clicking on the Show API credentials
dropdown.
You will want to create an .env
inside the directory /order-confirmation-sms
containing all the keys for the below:
TWILIO_ACCOUNT_SID=
TWILIO_AUTH_TOKEN=
TWILIO_FROM_NUMBER=
MOLTIN_CLIENT_ID=
MOLTIN_CLIENT_SECRET=
MOLTIN_WEBHOOK_SECRET=
MOLTIN_WEBHOOK_SECRET
can be anything you want.
Start the development server
yarn dev
The server will typically start on PORT 3000
, if not, make a note for the next step.
Start ngrok
ngrok http 3000
This will expose PORT 3000
to the outside world. Make a note of the http
URL ngrok provides.
You must now tell Moltin the ngrok URL above. Head to the Moltin Dashboard, login and go to Settings > Integrations
and click Create
.
Enter a name and description for your Integration. We recommend you prefix the name with DEVELOPMENT:
.
Next, enter the URL
and Secret Key
that match those inside .env
.
Now finally you'll want to configure when this webhook will be invoked, in this example check the Paid/Captured
box.
That's it! Click Save
Now that our integration is setup and configured, you will need to update the Order after Checkout to include the customers phone number.