Synchronize search with Algolia
This example provides instructions to clone and configure the repository that contains the code required to synchronize data between Elastic Path Commerce Cloud and Algolia, and use webhooks to synchronize data.
Prerequisite
- Ensure that you have an account in the ngrok service to tunnel your development environment externally.
- Ensure that yarn and other dependencies are installed.
Procedure
To clone repository, run the following command:
git clone https://github.com/moltin/examples.git
In the terminal, go to the
examples/webhooks/sync-catalog-to-algolia
directory.Go to Algolia and do the following:
Create an account.
Create a new app with a name.
Go to Settings > API Keys.
Make a note of your Application ID and Admin API Key.
In the
/sync-catalog-to-algolia
directory, create an.env
file and add the keys for the following environment variables:ALGOLIA_APP_ID=
ALGOLIA_API_KEY=
MOLTIN_WEBHOOK_SECRET=
Use any value that you want for
MOLTIN_WEBHOOK_SECRET
.Run the following command and start the development server:
yarn dev
By default, the server starts on port 3000. If the server starts on a different port, use that port number in the next step.
Start ngrok using the following command:
ngrok http 3000
This exposes port 3000 externally.
Go to the ngrok status page and make a note of the URL.
Create a new integration in Commerce Manager by doing the following:
Log into the Commerce Manager.
Go to Settings > Integrations.
Click New Integration.
In the Integration details section, enter a name and description for your integration.
We recommend to prefix the name with
DEVELOPMENT
for easier referencing.In the Configuration section, enter the ngrok URL and a secret key.
In the Observes section, select the following options in *Category and Collection:
- Created
- Updated
- Deleted
Select Enabled.
Click Save.
Related Resources
- Integrations
- Integrations API
- Synchronize search example (Source code)