Giter Club home page Giter Club logo

sync-moltin-to-algolia's Introduction

@particular./sync-moltin-to-algolia

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

Add/Update a Algolia indexed object when an object is created or modified in moltin

Asynchronous microservice that is triggered by moltin webhooks to add/update an object inside of Algolia.

Built with Micro! ๐Ÿคฉ

๐Ÿ›  Setup

Both an Algolia 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=
ALGOLIA_APP_ID=
ALGOLIA_API_KEY=

MOLTIN_AGOLIA_INDICES is optional but it is used to restrict which Moltin objects to generate Algolia indices for (ie. products,brands,categories,collections,orders,customers).

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.

Find your ALGOLIA_APP_ID and ALGOLIA_API_KEY within your Algolia Dashboard by going to API keys for your App. Note, ALGOLIA_API_KEY should be set to your Algolia Admin API Key, not your Search-Only API Key.

๐Ÿ“ฆ 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 (ie. Products, Brands, Categories, Collections, Orders, Customers) will cause this webhook to be invoked. In this example we want to monitor the Products and Customers observables and select the Created, Updated and Deleted box.

Click Save to register your new Webhook with Moltin.

NOTE: this repository is based on a fantastic set of code from our partners at moltin, available at: https://github.com/moltin/integration-examples/tree/master/sync-catalog-to-algolia

๐Ÿš€ Deploy

You can easily deploy this function to now.

Contact Adam Grohs @ Particular. for any questions.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.