I'm trying to create an App using Zapier CLI.
I was successfully able to create a Trigger.
Trigger is followed by API Key Authentication, this step also works fine.
After this step, I need to show users a dynamic searchbox, for every character they type in the searchbox, I need to send the text they enter to my REST API and fetch the latest results to show it to the user.
I'm able to hit the API, but the searchbox text is not being sent.
Here is my code.
Initial Event - lead.js
const listLeads = (z, bundle) => {
return >{
title: 'File Name',
description: 'File Description',
embed_key: 'abcdefgh'
}]
}
module.exports = {
key: 'lead',
noun: 'Lead',
display: {
label: 'New File',
description: 'Trigger when a new File is Created'
},
operation: {
inputFields: >{
key: 'search',
type: 'string',
helpText: 'Title or Description of File',
dynamic: 'search.title.description',
required: true,
altersDynamicFields: true
}],
perform: listLeads,
sample: {
title: 'File Name',
description: 'File Description',
embed_key: 'abcdefgh'
}
}
}
I'm able to hit the API, but the searchbox test is not being sent.
Search Trigger File - search.js
module.exports = {
key: 'search',
noun: 'Search',
display: {
label: 'Find a File',
description: 'Search for File by title or description',
},
operation: {
inputFields: >
],
perform: (z, bundle) => {
const url = 'https://f03a51102182.ngrok.io/searchFile';
const options = {
params: {
search : bundle.inputData.search,
},
};
return z.request(url, options).then((response) => response.data);
},
// In cases where Zapier needs to show an example record to the user, but we are unable to get a live example
// from the API, Zapier will fallback to this hard-coded sample. It should reflect the data structure of
// returned records, and have obviously dummy values that we can show to any user.
sample: {
title: 'File Name',
description: 'File Description',
embed_key: 'sajfh479',
},
// If the resource can have fields that are custom on a per-user basis, define a function to fetch the custom
// field definitions. The result will be used to augment the sample.
// outputFields: () => { return :]; }
// Alternatively, a static field definition should be provided, to specify labels for the fields
outputFields: <
{ key: 'embed_key', label: 'File Unqiue ID' },
{ key: 'title', label: 'File Title' },
{ key: 'description', label: 'File Description' },
],
},
};
From search.js, it's hitting my REST API when I enter something in the search box, query parameter is being passed as ?search, but the value is empty.
IMage for reference.
Could you help or guide me in the right direction whether I'm doing it the right way or not?