Skip to content

This Particular example demonstrates how you can sync order status updates from Moltin into Zendesk Sunshine via Webhook API.

License

Notifications You must be signed in to change notification settings

uniquelyparticular/sync-moltin-to-zendesk

Repository files navigation

@particular./sync-moltin-to-zendesk

npm version semantic-release code style: prettier CircleCI dependency status: david

Add a Zendesk Sunshine Event when an order is created or modified in Moltin

Asynchronous microservice that is triggered by moltin webhooks to create a Sunshine Event inside of Zendesk.

⚠️ Zendesk Sunshine Event API is only available via Early Access BETA registration.

Built with Micro! 🤩

🛠 Setup

Both a Zendesk and moltin account are needed for this to function.

Create a .env at the project root with the following credentials:

MOLTIN_CLIENT_ID=
MOLTIN_CLIENT_SECRET=
MOLTIN_WEBHOOK_SECRET=
ZENDESK_SUBDOMAIN=
ZENDESK_INTEGRATION_EMAIL=
ZENDESK_INTEGRATION_SECRET=

Find your MOLTIN_CLIENT_ID and MOLTIN_CLIENT_SECRET inside of your moltin Dashboard's API keys.

MOLTIN_WEBHOOK_SECRET can be anything you want.

ZENDESK_SUBDOMAIN is the first part of the URL for your Zendesk account (ie. https://{ZENDESK_SUBDOMAIN}.zendesk.com/).

While logged in to your Zendesk instance create a new User to run the Webhooks under by going to Settings > People > Add User > Role: Staff; this email address will be used as your ZENDESK_INTEGRATION_EMAIL above.

Find your ZENDESK_INTEGRATION_SECRET within your Zendesk instance by going to Settings > API > enable Token Access > add Active API Tokens [+] > API Token.

📦 Package

Run the following command to build the app

yarn install

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 (change ngrok port below from 3000 if yarn dev deployed locally on different port above)

ngrok http 3000

Make a note of the https ngrok URL provided.

⛽️ Usage

Next head over to the moltin Webhook Settings area, add a new integration (Settings > Integrations and click Create).

Enter any name and description for your Integration. Moltin recommends you prefix the name with DEVELOPMENT: for any testing.

Next, enter the ngrok URL from above and MOLTIN_WEBHOOK_SECRET that you saved inside .env.

URL and Secret Key

Now finally you'll want to configure what Moltin Observables will cause this webhook to be invoked. In this example we want to monitor the Order observable and select the Created, Fulfilled and Paid/Captured box.

Observes selection

Click Save to register your new Webhook with Moltin.

🚀 Deploy

You can easily deploy this function to now.

Contact Adam Grohs @ Particular. for any questions.