Algolia - Add Incoming HTTP Payload to Search Index
@dylburger
code:
data:privatelast updated:3 years ago
today
Build integrations remarkably fast!
You're viewing a public workflow template.
Sign up to customize, add steps, modify code and more.
Join 800,000+ developers using the Pipedream platform
steps.
trigger
HTTP API
Deploy to generate unique URL
This workflow runs on Pipedream's servers and is triggered by HTTP / Webhook requests.
steps.
objects
auth
to use OAuth tokens and API keys in code via theauths object
code
Write any Node.jscodeand use anynpm package. You can alsoexport datafor use in later steps via return or this.key = 'value', pass input data to your code viaparams, and maintain state across executions with$checkpoint.
async (event, steps) => {
1
2
3
4
}
5
// Take the HTTP payload, assumed to be a JavaScript object, and add it to an array,
// which we'll add to our Algolia index below
this.array = [event.body]
steps.
add_objects_to_index
Adds an array of JavaScript objects to the given index
auth
(auths.algolia)
params
Index

The name of your Algolia index

 
string ·params.index
Objects

An array of JavaScript objects, each corresponding to a new object in your search index. It's recommended you create this array of objects in a prior code step, then select expression mode and enter a variable reference to that array here.

{{steps.objects.array}}
array ·params.objects
Auto Generate Object ID If Not Present

If an objectID property is not present on objects, automatically assign on. Defaults to true.

boolean ·params.autoGenerateObjectIDIfNotExist
code
async (params, auths) => {
1
2
3
4
5
6
7
8
9
}
10
const algoliasearch = require("algoliasearch");
 
const client = algoliasearch(auths.algolia.application_id, auths.algolia.api_key);
const index = client.initIndex(params.index);
 
this.objectIds = await index.saveObjects(params.objects, {
  autoGenerateObjectIDIfNotExist: params.autoGenerateObjectIDIfNotExist || true 
})