cs-icon.svg

Add New Entries to Algolia’s Search Index

In this use case, we will cover a scenario where, if a user creates a new entry in Contentstack, Automations should be able to add it immediately to Algolia s search index.

Let's break this scenario to see what must be the trigger event and the consequent action required to execute the Automation:

  • Set Up the Contentstack  New Entry  Trigger Event: This trigger event is activated whenever a user creates a new entry for a particular stack, and in turn, it executes the Automation.
  • Set Up the Algolia  Index Entries  Action: Once the above event triggers the Automation, it will add your entry to Algolia s Search index.

The steps to set up the Automation are as follows:

  1. Create an Automation
  2. Set up the Contentstack Trigger Event
  3. Set up your Algolia Action Connector
  4. Test out the Automation for Algolia Search Index

Let s look at the setup in detail.

  1. Create an Automation

    To create an automation, perform the steps given below:

    1. Log in to your Contentstack account and click the  Automation Hub  icon.
    2. Click + New Project and provide the required details to create a new project.
    3. Click + New Automation to add the steps required to configure the automation.

    Next, let s look at the steps to set up the trigger event.

  2. Set up the Contentstack Trigger Event

    1. Click Configure Trigger from the left navigation panel.
      Click-Configure-Trigger.png
    2. Within the Configure Trigger step, click the Contentstack connector.
      Select_the_Trigger.png
    3. Add your Contentstack account. For more information, refer to the Contentstack Trigger documentation.
    4. Once done, select Entry Created from the list of trigger events and define the rest of the steps needed to set up the trigger (refer to steps 3 to 12 in Contentstack Trigger).Select-Event-Stack.png
    5. Click Test Trigger to execute and test the trigger that you configured.
  3. Set up your Algolia Action Connector

    Let s configure the Algolia action connector.

    1. Click Configure Action Step from the left navigation panel.
      Click-Configure-Action-Step.png
    2. Click Action Step to configure third-party services.
      Select_Action_Step
    3. Within the Configure Action Step, click the Algolia connector.
      Select_the_Algolia_Connector.png
    4. Select the Index Entries action.
      Select-Index-Entries-Action.png
    5. Click the + Add New Account button to select your Algolia account.
      Add-New-Account.png
    6. To add your Algolia account, refer to the Algolia Connector document.
    7. Select the Index Name where you want to send the data.
    8. Enter the data to be added to the index in the Entries field.

      Note: Provide your index data as per your object schema and in JSON format only. You can also pass dynamic data from the output of the previous step i.e., Entry Trigger. For that, just create an entry in your stack and enable the automation. In the execution logs, you can see the status of the automation.

      Select-Algolia-Fields.png
    9. Click Proceed.

    10. This completes the configuration of your action. Now, click the Test Action button to send your data to the Algolia index.
      Test-Algolia-Action.png
    11. Once the execution is successful, you will get the final output as seen in the screenshot in step 13.
    12. This should initiate Algolia to add your entry into its Search Index. You need to navigate to your Algolia Index section and check the latest indexed entry. If it displays the data we passed as objects in the Algolia action connector, that means the automation works successfully.

    13. Navigate back to your automation set up page, and click Save and Exit to finish setting up the action.
      Save-Exit-Algolia.png
    14. You need to enable automation in order to test it.
    15. This sets the Algolia action connector.

  4. Test out the Automation for Algolia Search Index

    Now, let s see how you can test out your Automation. To do so, perform the steps given below:

    1. Go to Contentstack and create an entry for the content type that you selected in your trigger event in step 2.
      This should trigger your Automation.
    2. Now, navigate to Algolia, log in and check the latest indexed entry in your Algolia Index section. If your Automation worked, you should see the following output:
      Algolia-Output.png
Was this article helpful?
^