### Help Static JSON Example
Source: https://github.com/roystonsanctis/dh-planner-viasocket/blob/main/knowledge-base/dh-Input-fields-json-builder.md
Provides example JSON objects for help fields. Demonstrates the structure for 'help_webhook' and 'help_send_message', including HTML formatting and a visibility condition.
```json
[
{
"key": "help_webhook",
"help": "
- Sign in to WordPress account.
- Locate and edit the form that you wish to integrate.
- Within the form settings, navigate to the \"Actions after submit\" section.
- Add a new action by selecting \"Webhook\".
- Enable the Webhook functionality by toggling it on.
- Enter the previously copied webhook URL into the designated field.
- Save the changes made to the page.
- Access the live version of the page.
- Fill out and submit the form.
- This submission will trigger the sending of the webhook to viaSocket.
",
"type": "help"
},
{
"key": "help_send_message",
"help": "You can send a message on Instagram DM up to 24 hours after receiving a message from a user.
A maximum of 3 buttons (URL and postback combined) are allowed in the button template message.",
"type": "help",
"visibilityCondition": "context?.inputData?.message_type === 'button_template'"
}
]
```
--------------------------------
### Help Static TOON Example
Source: https://github.com/roystonsanctis/dh-planner-viasocket/blob/main/knowledge-base/dh-Input-fields-json-builder.md
Provides examples of help text configurations within a TOON structure, including detailed HTML lists and simple text messages with visibility conditions.
```toon
[2]:
- key: help_webhook
help: " - Sign in to WordPress account.
- Locate and edit the form that you wish to integrate.
- Within the form settings, navigate to the \"Actions after submit\" section.
- Add a new action by selecting \"Webhook\".
- Enable the Webhook functionality by toggling it on.
- Enter the previously copied webhook URL into the designated field.
- Save the changes made to the page.
- Access the live version of the page.
- Fill out and submit the form.
- This submission will trigger the sending of the webhook to viaSocket.
"
type: help
- key: help_send_message
help: You can send a message on Instagram DM up to 24 hours after receiving a message from a user.
A maximum of 3 buttons (URL and postback combined) are allowed in the button template message.
type: help
visibilityCondition: context?.inputData?.message_type === 'button_template'
```
--------------------------------
### Dictionary JSON Example
Source: https://github.com/roystonsanctis/dh-planner-viasocket/blob/main/knowledge-base/dh-Input-fields-json-builder.md
Provides examples of dictionary input fields in JSON format. Includes fields for quick replies, URL buttons, and custom fields.
```json
[
{
"key": "quick_replies",
"help": "Quick replies provide a way to present a set of buttons in-conversation for users to reply with.",
"type": "dictionary",
"label": "Quick Replies",
"required": true,
"template": {
"key": {
"type": "string",
"placeholder": "Title"
},
"value": {
"type": "string",
"placeholder": "PAYLOAD TEXT"
}
}
},
{
"key": "url_button",
"help": "The URL Button opens a web page in the in-app browser.",
"type": "dictionary",
"label": "URL Button",
"template": {
"key": {
"type": "string",
"placeholder": "Button Title"
},
"value": {
"type": "string",
"placeholder": "Link"
}
},
"visibilityCondition": "context.inputData.message_type === 'text'"
},
{
"key": "custom_fields",
"help": "Enter Custom Fields with custom fields title and value.",
"type": "dictionary",
"label": "Custom Fields",
"template": {
"key": {
"type": "string",
"placeholder": "Custom Field Name"
},
"value": {
"type": "string",
"placeholder": "Enter Value"
}
}
}
]
```
--------------------------------
### Dictionary TOON Example
Source: https://github.com/roystonsanctis/dh-planner-viasocket/blob/main/knowledge-base/dh-Input-fields-json-builder.md
Illustrates dictionary input fields using TOON syntax, mirroring the JSON example for quick replies, URL buttons, and custom fields.
```toon
[3]:
- key: quick_replies
help: Quick replies provide a way to present a set of buttons in-conversation for users to reply with.
type: dictionary
label: Quick Replies
required: true
template:
key:
type: string
placeholder: Title
value:
type: string
placeholder: PAYLOAD TEXT
- key: url_button
help: The URL Button opens a web page in the in-app browser.
type: dictionary
label: URL Button
template:
key:
type: string
placeholder: Button Title
value:
type: string
placeholder: Link
visibilityCondition: context.inputData.message_type === 'text'
- key: custom_fields
help: Enter Custom Fields with custom fields title and value.
type: dictionary
label: Custom Fields
template:
key:
type: string
placeholder: Custom Field Name
value:
type: string
placeholder: Enter Value
```
--------------------------------
### Custom Placeholder Example
Source: https://github.com/roystonsanctis/dh-planner-viasocket/blob/main/knowledge-base/dh-Input-fields-json-builder.md
Defines a custom placeholder for an input field, providing an example value.
```json
customPlaceholder: E.g. 1161533432455827
```
--------------------------------
### Example Directory Structure for Docstar
Source: https://github.com/roystonsanctis/dh-planner-viasocket/blob/main/docstar.md
This structure shows how folders and files map to the Docstar navigation hierarchy. Use `page.md` for folder-level content.
```text
docs/
├── getting-started.md (Individual page)
├── api/ (Folder/Category)
│ ├── page.md (Content for the 'api' category page)
│ ├── authentication.md (Page under 'api')
│ └── users/ (Nested Folder)
│ └── create.md (Page under 'api/users')
```
--------------------------------
### Multiselect Static TOON Schema Example
Source: https://github.com/roystonsanctis/dh-planner-viasocket/blob/main/knowledge-base/dh-Input-fields-json-builder.md
Represents the same multiselect input field configurations as the JSON example, but using a custom TOON schema format. This format might be used for internal configuration or a specific DSL.
```toon
[2]:
- key: output_response
help: "Choose response output possible markdown, notion blocks."
type: multiselect
label: Output Response
options[3]{label,value,sample}:
Markdown,markdown,markdown
Blocks,blocks,blocks
HTML,html,html
required: true
placeholder: Choose Return Type
defaultValue[1]{label,value,sample}:
Markdown,markdown,markdown
customInputLabel: Enter output responses to include in array.
customPlaceholder: "E.g., [\"markdown\",\"block\"]"
- key: search_by
help: Select fields to search from will return the result containing any of the matching fields
type: multiselect
label: Search By
options[4]{label,value,sample}:
ID,id,id
Phone,phone,phone
Email,email,email
First Name,first_name,first_name
required: true
customHelp: You can enter the required fields ID in the array to search from
customPlaceholder: "E.g., [\"first_name\",\"email\"]"
customInputLabel: Enter fields ids in array
placeholder: Choose Search Filelds
```
--------------------------------
### Dynamic Dropdown JSON Configuration
Source: https://github.com/roystonsanctis/dh-planner-viasocket/blob/main/knowledge-base/dh-Input-fields-json-builder.md
Configure a dynamic dropdown input field. This example shows how to set up a field that fetches options from an API, with custom placeholder text and a visibility condition.
```json
{
"label": "Leadgen Form",
"type": "dropdown",
"name": "leadgen_form_id",
"options": {
"fetchUrl": "/api/v2/leadgen_forms",
"fetchParams": {
"page_id": "context?.inputData?.page_id"
}
},
"customPlaceholder": "E.g. 1161533432455827",
"visibilityCondition": "context?.inputData?.page_id"
}
```
--------------------------------
### Example Endpoint Definition
Source: https://github.com/roystonsanctis/dh-planner-viasocket/blob/main/docstar.md
This snippet shows how to define an API endpoint using the `type: endpoint` in the YAML frontmatter, followed by an OpenAPI/Swagger definition.
```APIDOC
## post /users
### Description
Create a new user
### Method
POST
### Endpoint
/users
### Parameters
#### Request Body
- **username** (string) - Required - The username for the new user.
### Response
#### Success Response (200)
- **description** (string) - User created successfully
```
--------------------------------
### Key Normalization Example
Source: https://github.com/roystonsanctis/dh-planner-viasocket/blob/main/knowledge-base/dh-Input-fields-json-builder.md
Normalize generated field keys to prevent issues with full stops. Replace dots with underscores or other suitable characters to ensure valid key formats.
```javascript
const normalizedKey = column.name.replace('.', '_');
return {
key: normalizedKey,
type: 'string',
label: column.name
};
```
--------------------------------
### Dropdown Dynamic TOON Example
Source: https://github.com/roystonsanctis/dh-planner-viasocket/blob/main/knowledge-base/dh-Input-fields-json-builder.md
Handles errors during fetch operations for dynamic dropdowns, providing specific messages for permission errors or a fallback to a default 'All' option with a general error message.
```javascript
(error.response?.status === 400 || error.response?.status === 403) {
return { message: "Insufficient permissions to access Lead Forms. Ensure 'leads_retrieval' permission is granted." };
}
// Fallback: return only "All" option
return {
data: [{ label: 'All Leadgen Forms', value: '0' }],
offset: null,
message: error?.message || "Could not load forms. Using 'All Leadgen Forms' as default."
};
}
}
// Execute and return
return await fetchLeadFormsWithPagination(context);
```
--------------------------------
### Fetch and Format Table Columns for Query Help
Source: https://github.com/roystonsanctis/dh-planner-viasocket/blob/main/knowledge-base/dh-Input-fields-json-builder.md
This snippet fetches available columns from a specified table and formats them into a markdown message, including example values. It excludes certain default keys like 'rowid' and 'autonumber'. Requires 'axios' for HTTP requests.
```toon
- key: dynamic_help_query
type: help
label: Available Columns
source: "async function convertToDesiredFormat() {
const URL = `https://table-api.viasocket.com/dbs/${context.authData.dbId}/${context?.inputData?.table}/field`;
const EXCLUDED_KEYS = ["rowid", "autonumber"];
try {
const response = await axios.get(URL);
const data = response.data.data.fields;
let markdownMessage = "Available Columns in your selected table:\n";
let index = 1;
let fieldObjs = [];
Object.keys(data).forEach((key) => {
if (!EXCLUDED_KEYS.includes(key)) {
const field = data[key];
markdownMessage += `${index}. ${field.fieldName} (${field.fieldType})\n`;
fieldObjs.push(field);
index++;
}
});
function exampleValue(field) {
if (/_id$/.test(field.fieldName) || field.fieldType.match(/(int|number|bigint)/i)) {
return 12345;
} else if (/status|type/i.test(field.fieldName)) {
return "'Active'";
} else if (field.fieldType.match(/(text|longtext|varchar)/i)) {
return "'John Doe'";
} else {
return "'John Doe'";
}
}
let example = '';
if (fieldObjs.length >= 2) {
example = `Example: ${fieldObjs[0].fieldName} is equal to ${exampleValue(fieldObjs[0])} and ${fieldObjs[1].fieldName} is equal to ${exampleValue(fieldObjs[1])}`;
} else if (fieldObjs.length === 1) {
example = `Example: ${fieldObjs[0].fieldName} is equal to ${exampleValue(fieldObjs[0])}`;
} else {
example = `No filterable columns available.`;
}
return { message: markdownMessage + '\n' + example };
} catch (error) {
return { message: "Could not fetch table columns." };
}
}
return convertToDesiredFormat();
```
--------------------------------
### Dropdown Static TOON Example
Source: https://github.com/roystonsanctis/dh-planner-viasocket/blob/main/knowledge-base/dh-Input-fields-json-builder.md
Defines a static dropdown input field for message type selection. It includes options with labels and values, and specifies whether the field is required.
```toon
[3]:
- key: message_type
help: Select the type of message you want to send. Choose the appropriate option based on the media you are sending.
type: dropdown
label: Message Type
options[6]{label,value}:
Text,text
Image or GIF,image
Audio,audio
Video,video
Sticker,sticker
Send Published Post,media_share
required: true
placeholder: Choose Message Type
customInputLabel: Enter Message Type
customPlaceholder: "E.g., text"
- key: video_status
help: "Choose the video visibility status (public, private, unlisted)."
type: dropdown
label: Video Status
options[3]{label,value}:
Public,public
Private,private
Unlisted,unlisted
required: true
placeholder: Choose visibility status
defaultValue:
label: Public
value: public
- key: category_id
help: Choose video category or enter the video category ID.
type: dropdown
label: Category
options[15]{label,value,sample}:
Film & Animation,"1","1"
Autos & Vehicles,"2","2"
Music,"10","10"
Pets & Animals,"15","15"
Sports,"17","17"
Travel & Events,"19","19"
Gaming,"20","20"
People & Blogs,"22","22"
Comedy,"23","23"
Entertainment,"24","24"
News & Politics,"25","25"
Howto & Style,"26","26"
Education,"27","27"
Science & Technology,"28","28"
Nonprofits & Activism,"29","29"
required: true
placeholder: Choose Category
customInputLabel: Enter the video category ID.
customPlaceholder: "E.g., 22"
customHelp: "If you don't know the video category ID, you can choose the video category from the dropdown.Additionally you can get the category ID from the List Categories Action."
```
--------------------------------
### Multiselect Static JSON Example
Source: https://github.com/roystonsanctis/dh-planner-viasocket/blob/main/knowledge-base/dh-Input-fields-json-builder.md
Defines multiselect input fields for 'Output Response' and 'Search By' using a static JSON structure. This is useful for configuring dynamic form elements.
```json
[
{
"key": "output_response",
"help": "Choose response output possible markdown, notion blocks.",
"type": "multiselect",
"label": "Output Response",
"options": [
{
"label": "Markdown",
"value": "markdown",
"sample": "markdown"
},
{
"label": "Blocks",
"value": "blocks",
"sample": "blocks"
},
{
"label": "HTML",
"value": "html",
"sample": "html"
}
],
"required": true,
"placeholder": "Choose Return Type",
"defaultValue": [
{
"label": "Markdown",
"value": "markdown",
"sample": "markdown"
}
],
"customInputLabel": "Enter output responses to include in array.",
"customPlaceholder": "E.g., [\"markdown\",\"block\"]"
},
{
"key": "search_by",
"help": "Select fields to search from will return the result containing any of the matching fields",
"type": "multiselect",
"label": "Search By",
"options": [
{
"label": "ID",
"value": "id",
"sample": "id"
},
{
"label": "Phone",
"value": "phone",
"sample": "phone"
},
{
"label": "Email",
"value": "email",
"sample": "email"
},
{
"label": "First Name",
"value": "first_name",
"sample": "first_name"
}
],
"required": true,
"customHelp": "You can enter the required fields ID in the array to search from",
"customPlaceholder": "E.g., [\"first_name\",\"email\"]",
"customInputLabel": "Enter fields ids in array",
"placeholder": "Choose Search Filelds"
}
]
```
--------------------------------
### Static Help Field Generation Rules
Source: https://github.com/roystonsanctis/dh-planner-viasocket/blob/main/knowledge-base/dh-Input-fields-json-builder.md
Defines the rules for generating a static help field in JSON. This field is used for displaying instructional content, warnings, or guides within the UI. It supports plain text, HTML, and Markdown. Visibility can be controlled via a condition.
```json
{
"type": "help",
"key": "help_webhook",
"help": "Use a Static Help field when you need to provide detailed step-by-step instructions, display important information, or guide the user visually within the form."
}
```
--------------------------------
### Calculate Execution Start Time for Scheduled Trigger
Source: https://github.com/roystonsanctis/dh-planner-viasocket/blob/main/knowledge-base/perform-code.md
Use this snippet to dynamically calculate a timestamp representing a past point in time based on the current execution start time and a user-defined interval. This is useful for filtering API results.
```javascript
// __executionStartTime__ = Current run's exact timestamp
// context?.inputData?.scheduledTime = User-defined interval (e.g., 10 mins)
const minutesAgo = new Date(__executionStartTime__ - context?.inputData?.scheduledTime * 60 * 1000);
```
--------------------------------
### Complex Condition: Calculation
Source: https://github.com/roystonsanctis/dh-planner-viasocket/blob/main/knowledge-base/dh-Input-fields-json-builder.md
Use this condition for complex logic, such as performing calculations. This example checks if the product of price and quantity exceeds 100.
```javascript
(context?.inputData?.price * context?.inputData?.quantity) > 100
```
--------------------------------
### Visibility Condition Example
Source: https://github.com/roystonsanctis/dh-planner-viasocket/blob/main/knowledge-base/dh-Input-fields-json-builder.md
Sets a condition for the visibility of an input field based on the page ID present in the context's input data.
```json
visibilityCondition: context?.inputData?.page_id
```
--------------------------------
### Notion Data Source Dropdown Configuration
Source: https://github.com/roystonsanctis/dh-planner-viasocket/blob/main/knowledge-base/dh-Input-fields-json-builder.md
Configures a dynamic dropdown for selecting a Notion Data Source. It includes help text, required fields, and an options generator to fetch data sources.
```json
{
"key": "data_source_id",
"help": "If you don’t see your expected Data Source, please check that it is shared with the same integration that you’re using to authenticate with. Update the connection and grant the page access or give the access in notion UI under integrations.",
"type": "dropdown",
"label": "Data Source",
"required": true,
"customHelp": "You can get the data source id from the action list data source or from the find data source by title action. ",
"canPaginate": true,
"placeholder": "Choose Data Source",
"enableSearchApi": true,
"customInputLabel": "Enter Data Source ID.",
"optionsGenerator": "try{\n return await fetchDataSources(__searchText,context?.paginateData?.['data_source_id'], 30) ;\n}\ncatch(e){\n throw e;
}"
}
```
--------------------------------
### DH-Reviewer JSON Verdict Examples
Source: https://context7.com/roystonsanctis/dh-planner-viasocket/llms.txt
These JSON objects illustrate the expected output from the DH-Reviewer agent, showing both cases where issues are found and where the action is approved.
```json
// Invocation context:
// actionName = "Create Card"
// service = "Trello"
// domain = "api.trello.com"
// inputFields = [ ...field config array... ]
// performCode = "async function createCard() { ... }"
// Example output — issues found:
{
"approved": false,
"issues": [
"field 'due_date' uses type 'string' — should be type 'date'",
"perform code missing try-catch block",
"label 'Select Trello Board' must not include service name — use 'Select Board'"
],
"review": [
"dropdown schema for board_id is correct",
"context.inputData mapping looks accurate"
]
}
```
```json
// Example output — clean approval:
{
"approved": true,
"issues": [],
"review": [
"all field types conform to TOON Schema",
"perform code has correct async/try-catch structure",
"no auth logic present",
"endpoint matches provided cURL"
]
}
```
--------------------------------
### Slack Channel Dropdown Configuration
Source: https://github.com/roystonsanctis/dh-planner-viasocket/blob/main/knowledge-base/dh-Input-fields-json-builder.md
Configures a dynamic dropdown for selecting a Slack channel. It fetches public and private channels, handles pagination, and formats the results for display.
```json
{
"key": "channel_id",
"help": "Select the channel to send the message.",
"type": "dropdown",
"label": "Channel",
"required": true,
"canPaginate": true,
"optionsGenerator": "try {
function convertToDesiredFormat(allChannels) {
return allChannels
?.map(channel => ({
label: channel.name,
sample: channel.id,
value: channel.id
}))
.sort((a, b) => a.label.localeCompare(b.label));
}
function replaceEqualsWithPercent3D(inputString) {
return inputString.replace(/=/g, '');
}
let response = await axios.get(
'https://slack.com/api/conversations.list?types=public_channel,private_channel&exclude_archived=true&limit=999'
);
let channelArray = response?.data?.channels || [];
while (response?.data?.response_metadata?.next_cursor) {
const next_cursor = replaceEqualsWithPercent3D(response.data.response_metadata.next_cursor);
response = await axios.get(
https://slack.com/api/conversations.list?types=public_channel,private_channel&exclude_archived=true&cursor=${next_cursor}&limit=999
);
channelArray = [...channelArray, ...(response?.data?.channels || [])];
}
return convertToDesiredFormat(channelArray);
} catch (error) {
switch (error?.response?.status) {
case 401:
if (error?.response?.data?.error === 'token_revoked') {
throw {
success: false,
status: error?.response?.status,
message: 'Token has been revoked. Please check your credentials and try again.'
};
}
break;
case 429:
if (error?.response?.data?.error === 'ratelimited') {
throw {
success: false,
status: error?.response?.status,
message: 'You have made too many requests in a short period. Please wait before trying again.'
};
}
break;
default:
throw error;
}
}"
}
```
--------------------------------
### Dropdown: Slack Channel Configuration
Source: https://github.com/roystonsanctis/dh-planner-viasocket/blob/main/knowledge-base/dh-Input-fields-json-builder.md
Configures a dropdown to select a Slack channel. It fetches public and private channels, handles pagination, and formats the results for display. Includes error handling for common API issues like revoked tokens and rate limiting.
```javascript
{
"key": "channel_id",
"help": "Select the channel to send the message.",
"type": "dropdown",
"label": "Channel",
"required": true,
"canPaginate": true,
"optionsGenerator": "try {
function convertToDesiredFormat(allChannels) {
return allChannels
?.map(channel => ({
label: channel.name,
sample: channel.id,
value: channel.id
}))
.sort((a, b) => a.label.localeCompare(b.label));
}
function replaceEqualsWithPercent3D(inputString) {
return inputString.replace(/=/g, '');
}
let response = await axios.get(
'https://slack.com/api/conversations.list?types=public_channel,private_channel&exclude_archived=true&limit=999'
);
let channelArray = response?.data?.channels || [];
while (response?.data?.response_metadata?.next_cursor) {
const next_cursor = replaceEqualsWithPercent3D(response.data.response_metadata.next_cursor);
response = await axios.get(
https://slack.com/api/conversations.list?types=public_channel,private_channel&exclude_archived=true&cursor=${next_cursor}&limit=999
);
channelArray = [...channelArray, ...(response?.data?.channels || [])];
}
return convertToDesiredFormat(channelArray);
} catch (error) {
switch (error?.response?.status) {
case 401:
if (error?.response?.data?.error === 'token_revoked') {
throw {
success: false,
status: error?.response?.status,
message: 'Token has been revoked. Please check your credentials and try again.'
};
}
break;
case 429:
if (error?.response?.data?.error === 'ratelimited') {
throw {
success: false,
status: error?.response?.status,
message: 'You have made too many requests in a short period. Please wait before trying again.'
};
}
break;
default:
throw error;
}
}"}
```
--------------------------------
### Integrate Fetch Lead Forms in Dynamic Dropdown
Source: https://github.com/roystonsanctis/dh-planner-viasocket/blob/main/knowledge-base/dh-Input-fields-json-builder.md
This JSON configuration shows how to use the `fetchLeadForms` function within a dynamic dropdown's `optionsGenerator`. It retrieves context data for the selected page, offset, and limit to make the API call.
```json
{
"optionsGenerator": "try{
const selectedPage = context?.inputData?.selectedPage;
const offset = context?.paginateData?.['page_id'];
const limit = context?.inputData?.limit;
return await fetchLeadForms(selectedPage, offset, limit);
}catch(e){
throw e;
}"
}
```
--------------------------------
### Multiselect Field for Filtering Properties (Generic Fetch)
Source: https://github.com/roystonsanctis/dh-planner-viasocket/blob/main/knowledge-base/dh-Input-fields-json-builder.md
This multiselect field is used for filtering properties, similar to the Notion API example, but utilizes a generic `fetchDatasourceProperties` function. It requires `context.inputData.data_source_id` to be set.
```javascript
try{
const data_source_id =context.inputData.data_source_id
return await fetchDatasourceProperties(data_source_id)
}catch(e){
throw e;
}
```
--------------------------------
### Fetch Veeqo Orders with Client-Side Filtering and Pagination
Source: https://github.com/roystonsanctis/dh-planner-viasocket/blob/main/knowledge-base/perform-code.md
Fetches Veeqo orders, filters them by creation date and selected fields, and implements pagination. Use this when you need to process orders on the client-side after fetching.
```javascript
try {
const scheduledMinutes = context?.inputData?.scheduledTime || 15;
const selectedFields = context?.inputData?.cxGsrrwn || [];
const pageSize = 50;
// 1. Calculate time window
const timeAgo = new Date(__executionStartTime__ - scheduledMinutes * 60 * 1000);
// 2. Determine which page to fetch (Default to 1 if no saved cursor)
let currentPage = context?.paginationData || 1;
// 3. Single API Request
const res = await axios.get('https://api.veeqo.com/orders', {
params: {
page: currentPage,
page_size: pageSize
}
});
const orders = res.data || [];
let finalOrders = [];
// 4. Process and Filter Data
if (Array.isArray(orders) && orders.length > 0) {
// Filter raw orders by timestamp first
const recentOrders = orders.filter(order =>
order.created_at && new Date(order.created_at) >= timeAgo
);
// Map to selected fields
for (const order of recentOrders) {
const filteredOrder = {};
if (selectedFields.length > 0) {
for (const field of selectedFields) {
// Only add the field if it exists in the order object
if (order[field] !== undefined) {
filteredOrder[field] = order[field];
}
}
finalOrders.push(filteredOrder);
} else {
// If no fields selected, keep the whole order
finalOrders.push(order);
}
}
}
// 5. Pagination Logic
// LOGIC UPDATE:
// - orders.length >= pageSize: Checks if there is potentially a next page from API.
// - finalOrders.length !== 0: Checks if THIS page had any relevant data.
// If finalOrders is empty, it means we passed the time window, so we stop.
if (orders.length >= pageSize && finalOrders.length !== 0) {
context.paginationData = currentPage + 1;
}
// 6. Return Result
return finalOrders;
} catch (error) {
throw error;
}
```
--------------------------------
### Build Boolean Field (Send Notification)
Source: https://context7.com/roystonsanctis/dh-planner-viasocket/llms.txt
Use for true/false toggle fields for binary settings. Always include helpText explaining the effect of toggling and default to false if unclear.
```json
// Input: key = "send_notification", purpose = "Toggle whether to notify card members"
{
"key": "send_notification",
"label": "Send Notification",
"type": "boolean",
"default": false,
"required": false,
"helpText": "When enabled, an email notification is sent to all members assigned to the card."
}
// Rules:
// - Default to false when the correct default is unclear
// - Always include helpText explaining the effect of toggling
// - Confirm API's expected format: true/false, 1/0, "yes"/"no"
```
--------------------------------
### Fetch New Items from API with Pagination
Source: https://github.com/roystonsanctis/dh-planner-viasocket/blob/main/knowledge-base/perform-code.md
Use this function to fetch new items from an API. It calculates a lookback time, prepares a request payload with optional pagination, configures the API request, executes the call, filters results by creation time, sorts them, and updates pagination data if available. Enable pagination in the UI first.
```javascript
async function fetchItems() {
try {
// 1. Calculate lookback time
const minutesAgo = new Date(__executionStartTime__ - context?.inputData?.scheduledTime * 60 * 1000);
// 2. Prepare request payload
let requestPayload = {
key: "value"
};
// -----------------------------------
// OPTIONAL PAGINATION (Generic)
// -----------------------------------
// Use existing pagination value if present
// Initial expected value: 0 or null
// User need to enable pagination in UI first
if (context?.paginationData) {
requestPayload.cursor = context.paginationData;
}
// 3. Configure API request
const requestConfig = {
method: "GET", // Can be GET or POST
url: "https://api.service.com/endpoint",
params: requestPayload, // Use "data" instead if POST
headers: {
"API-Version": "v1"
}
};
// 4. Execute API call
const response = await httpRequest(requestConfig);
const allItems = response?.data?.items || [];
// 5. Filter the results to include only those created in the last scheduled time
let filteredData = allItems.filter((item) => {
const createdTime = new Date(item.created_time);
return createdTime >= minutesAgo;
});
// 6. Sort the filtered data by creation time (oldest first)
filteredData.sort(
(a, b) => new Date(a.created_time) - new Date(b.created_time)
);
// -----------------------------------
// OPTIONAL PAGINATION UPDATE
// -----------------------------------
// User need to enable pagination in UI first
// Only update if:
// 1. We actually have filtered results
// 2. API returned next cursor
if (filteredData.length !== 0 && response?.data?.next_cursor) {
context.paginationData = response.data.next_cursor;
}
// 7. Return results
return filteredData;
} catch (error) {
throw error;
}
}
// Execute function
return await fetchItems();
```
--------------------------------
### Dropdown Static JSON Example
Source: https://github.com/roystonsanctis/dh-planner-viasocket/blob/main/knowledge-base/dh-Input-fields-json-builder.md
This JSON defines static dropdown input fields for message type, video status, and category. It includes options, labels, required fields, placeholders, and custom input configurations.
```json
[
{
"key": "message_type",
"help": "Select the type of message you want to send. Choose the appropriate option based on the media you are sending.",
"type": "dropdown",
"label": "Message Type",
"options": [
{
"label": "Text",
"value": "text"
},
{
"label": "Image or GIF",
"value": "image"
},
{
"label": "Audio",
"value": "audio"
},
{
"label": "Video",
"value": "video"
},
{
"label": "Sticker",
"value": "sticker"
},
{
"label": "Send Published Post",
"value": "media_share"
}
],
"required": true,
"placeholder": "Choose Message Type",
"customInputLabel": "Enter Message Type",
"customPlaceholder": "E.g., text"
},
{
"key": "video_status",
"help": "Choose the video visibility status (public, private, unlisted).",
"type": "dropdown",
"label": "Video Status",
"options": [
{
"label": "Public",
"value": "public"
},
{
"label": "Private",
"value": "private"
},
{
"label": "Unlisted",
"value": "unlisted"
}
],
"required": true,
"placeholder": "Choose visibility status",
"defaultValue": {
"label": "Public",
"value": "public"
}
},
{
"key": "category_id",
"help": "Choose video category or enter the video category ID.",
"type": "dropdown",
"label": "Category",
"options":[
{
"label": "Film & Animation",
"value": "1",
"sample": "1"
},
{
"label": "Autos & Vehicles",
"value": "2",
"sample": "2"
},
{
"label": "Music",
"value": "10",
"sample": "10"
},
{
"label": "Pets & Animals",
"value": "15",
"sample": "15"
},
{
"label": "Sports",
"value": "17",
"sample": "17"
},
{
"label": "Travel & Events",
"value": "19",
"sample": "19"
},
{
"label": "Gaming",
"value": "20",
"sample": "20"
},
{
"label": "People & Blogs",
"value": "22",
"sample": "22"
},
{
"label": "Comedy",
"value": "23",
"sample": "23"
},
{
"label": "Entertainment",
"value": "24",
"sample": "24"
},
{
"label": "News & Politics",
"value": "25",
"sample": "25"
},
{
"label": "Howto & Style",
"value": "26",
"sample": "26"
},
{
"label": "Education",
"value": "27",
"sample": "27"
},
{
"label": "Science & Technology",
"value": "28",
"sample": "28"
},
{
"label": "Nonprofits & Activism",
"value": "29",
"sample": "29"
}
],
"required": true,
"placeholder": "Choose Category",
"customInputLabel": "Enter the video category ID.",
"customPlaceholder": "E.g., 22",
"customHelp": "If you don't know the video category ID, you can choose the video category from the dropdown.Additionally you can get the category ID from the List Categories Action."
}
]
```
--------------------------------
### Valid JSON Output Example for Review
Source: https://github.com/roystonsanctis/dh-planner-viasocket/blob/main/dh-review.md
This JSON object represents a valid output format for review results. It includes boolean approval status, a list of identified issues, and a list of general review comments.
```json
{
"approved": false,
"issues": [
"add try-catch block in performAPI",
"field project_id has an invalid key 'data' in the input json"
],
"review": [
"try-catch handled correctly in other generators",
"dropdown schema looks good"
]
}
```