Create an Algolia Object using Entry UID
This use case covers a scenario where Automations should be able to retrieve an entry's UID when a user creates/deletes/updates/publishes/unpublishes an entry in Contentstack. The entry UID is then passed as an object ID to the Transform connector, which creates an object with the same UID in the Algolia index once the transformation is complete.
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 All'' Entry Trigger Event: This trigger event is activated whenever a user performs an entry event such as create/delete/update etc., and in turn it activates the Automation.
- Set up the Transform Action: Once the above event triggers the Automation, you can fetch the entry UID and pass this value as an object in the transform field.
- Set up the Algolia Index Entries Action: Once the Transform action is completed, you can post the entry UID to the Algolia index as an object.
Lets look at the setup in detail.
Create an Automation
To create an automation, perform the steps given below:
- Log in to your Contentstack account and click the Automate icon.
- Click + New Project and provide the required details to create a new project.
- Click + New Automation to add the steps required to configure automation.
Next, lets look at the steps to set up the trigger event.
Set up the Contentstack Trigger Event
- Click Configure Trigger from the left navigation panel.
- Within the Configure Trigger step, click the Contentstack connector.
- Add your Contentstack account. For more information, refer to the Contentstack Trigger documentation.
- Once done, select Allfrom the list of trigger events and define the rest of the steps needed to set up the trigger (refer steps 3 to 12 in Contentstack Trigger).
- ClickTest Trigger to execute and test the trigger that you configured.
- Click Save and Exit.
Set up your Transform Action Connector
Lets configure the Transform action connector.
- Click Configure Action Step from the left navigation panel.
- Click Action Step to configure third-party services.
- Within the Configure Action Step, click the Transform connector.
- Under Choose an Action, select the Transform action.
- Click Add Input, and enter a variable name for the Input Name (say, uid) and an Input Value configured in the previous step (entry UID) (see the screenshot in next step).
- Enter the JSON code to fetch the UID value from the Input Value field in a variable. You can use the following code: {objectId: {uid}}
- ClickProceed.
- Click Test Action to test the configured action.
- After successful configuration, you should see the output shown below. Click Save and Exit.
This sets the Transform action connector.
Test the Automation
Now, lets see how you can test out your Automation. To do so, perform the steps given below:
- Click + Add New Step. Click Action Step to configure third-party services.
- Within the Configure Action Step, click the Algolia connector.
- Under Choose an Action, select the Index Entries action.
- In the Configure Action tab, click + Add New Account to add your Algolia account.
- To add your Algolia account, refer to the Algolia Connector document.
- Select the Index Name where you want to send data in the form of a list of objects. You can also select the value from the previous step.
- In the Entries field, enter the data to be added in the Algolia index. Pass the data configured in the previous step i.e., output from the Transform action.
Note: You must provide your index data in JSON format and based on your object schema.
- Click Proceed.
- Click Test Action to test the configured action.
- After successful configuration, you should see the output shown below. Click Save and Exit.
- Navigate to the Algolia Index section and check the latest index entry with the data we passed as objects within the connector configurations. You will be able to see the data added in the object.
Note: You need to enable automation in order to test it.
This sets the Algolia action connector.