For users with minimal programming experience, Celigo AI simplifies the process of writing JavaScript code and establishing workflows, by generating explanations for various sections of the JavaScript code. Define the use case in a plain English prompt, and Celigo AI will generate the JavaScript code without requiring the user to manually write the syntax in the editor. You can use multiple prompts for complex use cases.
Prerequisite: Celigo AI must be enabled in your integrator.io account. Click the avatar icon in the upper right corner of integrator.io and click Profile.
Note
An error displays if your Celigo AI prompt is empty or invalid.
After the results of your initial prompt are retrieved, you can enter additional prompts that describe additional changes to the expression that Celigo AI might not have fully understood. All previously provided prompts will be saved and can be viewed or copied until you click Reset conversation or close the editor window. The editor also provides sample text that will inform your use of the text prompt field.
Click thumbs up or thumbs down for each prompt to indicate if the response provided by Celigo AI was helpful or unhelpful.
Sample JSON |
Prompt |
JavaScript Code |
Output after Auto preview |
Function: Filter |
|||
{ "record": { "id": 123, "name": "Bob", "age": 33 } } |
id should be even |
function Filter(options) { var record = options.record; var id = record.id; if (id % 2 === 0) { return true; } else { return false; } } |
false |
Sample JSON |
Prompt |
JavaScript Code |
Output after Auto preview |
Function: Filter |
|||
{ "record": { "id": 123, "name": "Bob", "age": 33, "payment_date": "10/06/2023" } } |
id should be even |
function Filter(options) { const { record } = options; const { id } = record; return id % 2 !== 0; } |
true |
can you add one more condition that name should be Bob |
function Filter(options) { const { record } = options; const { id, name } = record; return id % 2 !== 0 && name === 'Bob'; } |
true |
|
add one more condition that payment_date should be not older then 90 days |
function Filter(options) { const { record } = options; const { id, name, payment_date } = record; const currentDate = new Date(); const paymentDate = new Date(payment_date); const daysDifference = Math.floor((currentDate - paymentDate) / (1000 * 60 * 60 * 24)); return id % 2 !== 0 && name === 'Bob' && daysDifference <= 90; } |
true |
Celigo AI explains the JavaScript code for full or partial selection. Select the part of the code that you want Celigo AI to explain, and click Explain selection. Celigo AI will generate an explanation for the selected code. The selected lines remain highlighted until you close the explanation window. You can reposition the explanation window as needed.
Sample JSON |
Prompt |
JavaScript Code |
Explain selection |
{ "record": { "id": 123, "name": "Bob", "age": 33 } } |
id should be even |
function Filter(options) { var record = options.record; var id = record.id; if (id % 2 === 0) { return true; } else { return false; } } |
The `Filter` function takes an `options` object as a parameter and returns a boolean value. 1. The `id` property of the `options.record` object is assigned to a variable called `id`. 2. The function checks if the `id` is divisible by 2. If the `id` is divisible by 2 with no remainder, the function returns `true`. Otherwise, it returns `false`. The function can be used to filter out records with odd `id` values. |
Sample JSON |
Prompt |
JavaScript Code |
Explain selection |
{ "record": { "id": 123, "name": "Bob", "age": 33, "payment_date": "10/06/2023" } } |
id should be odd |
function Filter(options) { const { record } = options; const { id } = record; return id % 2 !== 0; } |
The `Filter` function takes an `options` object as a parameter and returns a boolean value. 1. The `record` property of the `options` object is destructured and assigned to a constant variable called `record`. 2. The `id`, `name`, and `payment_date` properties of the `record` object are destructured and assigned to separate constant variables. 3. The current date is obtained by creating a new `Date` object and assigned to a constant variable called `currentDate`. 4. The `payment_date` is converted to a `Date` object and assigned to a constant variable called `paymentDate`. 5. The difference in days between the `currentDate` and `paymentDate` is calculated using the formula `(currentDate - paymentDate) / (1000 * 60 * 60 * 24)`. The result is rounded down to the nearest whole number using `Math.floor()` and assigned to a constant variable called `daysDifference`. 6. The function returns `true` if the following conditions are met: - The `id` is not divisible by 2 with no remainder (`id % 2 !== 0`). - The `name` is equal to 'Bob'. - The `daysDifference` is less than or equal to 90. If any of these conditions are not met, the function returns `false`. The function can be used to filter out records that have an odd `id`, a name other than 'Bob', or a payment date that is more than 90 days ago. |
can you add one more condition that name should be Bob |
function Filter(options) { const { record } = options; const { id, name } = record; return id % 2 !== 0 && name === 'Bob'; } |
||
add one more condition that payment_date should be not older than 90 days |
function Filter(options) { const { record } = options; const { id, name, payment_date } = record; const currentDate = new Date(); const paymentDate = new Date(payment_date); const daysDifference = Math.floor((currentDate - paymentDate) / (1000 * 60 * 60 * 24)); return id % 2 !== 0 && name === 'Bob' && daysDifference <= 90; } |
Comments
0 comments
Please sign in to leave a comment.