Skip to content

Latest commit

 

History

History

sync-catalog-to-algolia

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

Sync catalog to Algolia

This example demonstrates how you can sync products, collections, categories and brands to Algolia using Moltin webhooks.

How to use locally

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.

1. Download the example

Clone the repository:

git clone git@github.com:moltin/integration-examples.git

Install dependencies with Yarn

cd integration-examples/sync-catalog-to-algolia
yarn

2. Configure Algolia

In this example we will sync data to Algolia. You will need an account an account to continue.

Once you've signed up to Algolia, create a new app and give it a name.

Next head to the API keys section and make a note of your Application ID and Admin API Key, we will need these next.

3. Configure your ENV variables

You will want to create an .env inside the directory /sync-catalog-to-algolia containing all the keys for the below:

ALGOLIA_APP_ID=
ALGOLIA_API_KEY=
MOLTIN_WEBHOOK_SECRET=

MOLTIN_WEBHOOK_SECRET can be anything you want.

4. Start the server and ngrok

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.

5. Create a new Moltin integration

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.

URL and Secret Key

Now finally you'll want to configure when this webhook will be invoked, in this example check any of created/updated/deleted observables for Product, Collection, Category or Brand.

Observes selection

That's it! Click Save