agenticDatasetGeneration
ChatGPTONLY for NEW datasets. NEVER call when user picked an existing dataset. Calls the GoSure AI service to suggest a dataset structure based on the user's requirement. Returns rootDatasetName and childDatasets. After getting the response: - Show the user the recommended root dataset and child datasets - Ask for confirmation before creating anything - On confirmation: check each child for exact name match in getAllJobTypesFromSystem result - Create missing children first (one createJobType per child, properties=[]) - Create root last with SubJob properties for each child - Only AFTER all datasets confirmed in a SEPARATE turn: call agenticFlowGeneration parentDataset for agenticFlowGeneration = rootDatasetName from this response childDatasets for agenticFlowGeneration = childDatasets from this response NEVER call createJobType and agenticFlowGeneration in the same turn.
agenticFlowGeneration
ChatGPTTriggers the agentic flow build. Call ONLY after all datasets exist. This is always the LAST tool call in a turn. NEVER call createJobType in the same turn as this. NEVER call agenticFlowStatus after this returns COMPLETED. parentDataset rule — always the ROOT dataset: CHOICE A (existing): use name/datasetName from getJobTypeById response CHOICE B (new): use rootDatasetName from agenticDatasetGeneration response NEVER a child dataset name childDatasets rule: CHOICE A: use _extractedSubJobFields from getJobTypeById response CHOICE B: use childDatasets from agenticDatasetGeneration response Pass [] if no children This tool polls internally every 15 seconds for up to 5 minutes. Returns ONCE — either COMPLETED with full flow or TIMEOUT. When COMPLETED: show shownMessages one per line then present the full flow in clean plain-English. Never show raw JSON, IDs, or field names. When TIMEOUT: show shownMessages, tell user to say 'check my agentic flow status' when ready. Do NOT call agenticFlowStatus automatically.
agenticFlowStatus
ChatGPTONLY call when agenticFlowGeneration returned TIMEOUT AND the user explicitly asks to check status. DO NOT call automatically. DO NOT call after agenticFlowGeneration returned COMPLETED. Pass the instanceId from the TIMEOUT response of agenticFlowGeneration. status=COMPLETED: present the full flow in clean plain-English. Never show raw JSON, IDs, or field names. status=PENDING: still building — tell user to check back in a minute. Do NOT call again automatically. status=NOT_FOUND: flow was already completed by agenticFlowGeneration. Tell user the flow is ready and ask what they want to do next.
bulkCreateInstances
ChatGPTCreates multiple child records in bulk for any parent record. Supports Excel file upload or JSON array — works for any service/sub-record type. WHEN TO CALL: When user wants to upload or create many records at once under a parent record. TWO MODES: FILE MODE (Excel upload): - User uploads an Excel file - Pass fileDownloadUrl and fileName from the attachment - Platform parses the file and creates all records automatically - Say: "I'll process your file and create all records automatically! 📊" JSON MODE (structured data): - Pass records[] array with field values for each record - Say: "I'll create [N] records now. Shall I proceed? ✅" BOTH MODES REQUIRE: - jobTypeId: the sub-record type ID (from session memory or getSubJobTypes) - parentJobInstanceId: PARENT_INSTANCE_ID from memory FLOW: 1. Confirm parentJobInstanceId = PARENT_INSTANCE_ID from memory 2. Confirm jobTypeId for the sub-record type 3. For file mode: ask user to upload the file if not already uploaded 4. Confirm with user then call this tool 5. After success: call getInstanceActivity on PARENT_INSTANCE_ID to monitor AFTER SUCCESS: "✅ Bulk submission complete! All records have been queued for processing. ⏳ Let me monitor the background processing..." Then call getInstanceActivity with PARENT_INSTANCE_ID.
createInstance
ChatGPTCreates a record when a FILE upload is involved. Use INSTEAD OF createInstanceForJobType when user uploads a file. Works for root records and sub-records on any tenant. ⚠️ CRITICAL TIMING: Must be called in the EXACT SAME MESSAGE as the upload. If called in a different turn, openaiFileIdRefs will be empty and upload fails silently. If this happens, ask the user to upload again. ════════════════════════════════════════════════════════════════════ TWO MODES ════════════════════════════════════════════════════════════════════ MODE 1 — Session + File (most common): Pass: sessionId + openaiFileIdRefs + fileFieldMappings Backend automatically merges all session answers with the uploaded file. MODE 2 — Direct + File (no active session): Pass: jobTypeId + data{} + openaiFileIdRefs + fileFieldMappings All non-file field values go in data{} with exact backend field names. FILE MAPPING RULES: fileFieldMappings: [{fileRefIndex: 0, fieldKey: "exact field name from session"}] fieldKey = EXACT field name from startFormSession fieldsToCollect[].name FILE fields must NOT be in data{} — only in fileFieldMappings. Multiple files: [{fileRefIndex:0, fieldKey:"Field A"}, {fileRefIndex:1, fieldKey:"Field B"}] For sub-records: parentJobInstanceId = PARENT_INSTANCE_ID from memory. For root records: omit parentJobInstanceId entirely. ASKING USER TO UPLOAD: "Please attach your file now 📎 Make sure to send the file and your confirmation in the same message so I can process it instantly!" ════════════════════════════════════════════════════════════════════ MANDATORY POST-CREATION SEQUENCE — ALL STEPS REQUIRED ════════════════════════════════════════════════════════════════════ ── STEP 1: STORE IN MEMORY ────────────────────────────────────────── Store from response: PARENT_INSTANCE_ID = response.instanceId PARENT_JOB_TYPE_ID = response.jobTypeId ── STEP 2: SUB-JOB WORKFLOW CHECK ─────────────────────────────────── Check response for subJobWorkflowInfo. If present, handle it FIRST. subJobWorkflowInfo contains: subJobInstanceId → ID of the sub-record just created subJobTypeName → name of that sub-record type availableNextStatuses → list of stages it can move to Each entry: { sequenceNo, secondaryStatus, primaryStatus } Show the user: "✅ [subJobTypeName] has also been created! Would you like to move it to the next stage? Available stages: 1️⃣ [first secondaryStatus] 2️⃣ [second secondaryStatus] ..." If user says YES and picks a stage: Call updateRecord with: instanceId = subJobWorkflowInfo.subJobInstanceId updateType = STATUS targetWorkflowSequenceNo = sequenceNo of the chosen stage ⚠️ ALWAYS use subJobWorkflowInfo.subJobInstanceId here. ⚠️ NEVER use PARENT_INSTANCE_ID for this updateRecord call. After success: show confirmation then continue to STEP 3. If user says NO: skip directly to STEP 3. ── STEP 3: AGENTIC ANALYSIS DISPLAY ───────────────────────────────── Check response for agenticAnalysisReport and agenticChecksSummary. agenticAnalysisReport is a structured JSON object — not plain text. If present, display it fully — never skip or truncate any part. agenticChecksSummary contains: total, passed, failed, passRate agenticAnalysisReport contains these fields — use ALL of them: overview → 3-4 sentence summary — show as intro paragraph passRate → number 0-100 — use to draw a text progress bar checks[] → array of individual check objects, each has: question, result, answer, reason, impact passedChecks[] → labels of passed checks failedChecks[] → labels of failed checks keyFindings → detailed paragraph about failures recommendedActions[] → array of specific actions tips[] → array of practical tips assessment → honest overall assessment paragraph priority → HIGH / MEDIUM / LOW rawChecks[] → original check data (use as fallback if above fields missing) DISPLAY FORMAT — USE THIS EXACT STRUCTURE: "🤖 Automated Verification Report ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 📊 Overall Score: [passRate]% Pass Rate ✅ Passed: [passed] ❌ Failed: [failed] 📋 Total: [total] [Draw a text progress bar based on passRate: 100% → ██████████ 100% 80% → ████████░…
createInstanceForJobType
ChatGPTCreates a new record instance for any confirmed record type. ════════════════════════════════════════════════════════════ CALL THIS TOOL ONLY AFTER: ════════════════════════════════════════════════════════════ 1. retrieveAllJobTypes → record type confirmed 2. getMandatoryFieldsOfJobType → fields retrieved 3. All non-file field values collected from user 4. Values mapped to exact allowed options (for Selection fields) 5. Confirmation summary shown to user in plain English 6. User explicitly confirmed 7. File/Attachment fields collected one at a time with per-file confirmation 8. fileFieldMappings built from confirmed attachments 9. parentJobInstanceId resolved from SESSION STACK (for sub-records only) ════════════════════════════════════════════════════════════ DATA OBJECT RULES ════════════════════════════════════════════════════════════ The "data" object must use EXACT backend field names as keys (from getMandatoryFieldsOfJobType). Values for Selection fields must be an exact allowed value. Values for Text / Number / Date fields use the user's input directly. File / Attachment fields are NOT included in "data" — they are handled via openaiFileIdRefs and fileFieldMappings by the controller layer. ════════════════════════════════════════════════════════════ PARENT-CHILD LINKAGE ════════════════════════════════════════════════════════════ When creating a child record (sub-job): → Include "parentJobInstanceId" = STACK_TOP.instanceId → Read this value from the SESSION STACK only — never from conversation history → Never guess or assume this value When creating a root record (no parent): → DO NOT include "parentJobInstanceId" at all — omit it entirely The response will echo back ParentJobInstanceId in response[0] when it was sent correctly. ════════════════════════════════════════════════════════════ LOOP PREVENTION ════════════════════════════════════════════════════════════ ✔ Call this tool exactly once per record type per creation flow ❌ Do NOT call getMandatoryFieldsOfJobType again after fields are collected ❌ Do NOT ask for the same fields again ❌ Do NOT restart the flow after calling this tool
createJobType
ChatGPTCreates a new job type in the system. Only call this after retrieveAllJobTypes confirms no matching job type exists, or after the user explicitly requests a new one. Collect the following from the user before calling: REQUIRED: name → string: unique name for the job type description → string: what this job type is for OPTIONAL (ask user, use empty/defaults if not specified): isPublished → boolean: default true isSubJobType → boolean: default false isReadOnly → boolean: default false parentJobType → string: parent job type name if sub job type parentJobIdentifier → string: identifier field for parent identifier → string: unique identifier field name report → string: default empty enableServices → boolean: default false sendMailRequired → boolean: default false isEmailTemplate → boolean: default false enableWizard → boolean: default false isAllowPublicAccess → boolean: default false acknowledgeText → string: default empty onSubmitActions → string: default empty downloadURL → string: default empty displayAPI → string: default empty associationRule → string: default empty maxRiskScoreProperty → string: default empty enablePromoteTrackableChangesToParent → boolean: default false FIELDS (properties array): Collect fields the user wants. For each field ask: name → string: field name (no spaces, use underscore) displayName → string: label shown to user (default empty) fieldType → string: one of Small_Text, Large_Text, Numeric_Text, Date, Date_Time, Dropdown, Multi_Select, Checkbox, File_Upload, ReadOnly_Small_Text, JSON_KEY, Yml_Key fieldGroup → string: section/group name for this field isMandatory → boolean: default false isSearchable → boolean: default false enableShowInListView → boolean: default false displayOrder → integer: order in form defaultValue → string: default empty Always confirm full summary with user before calling. Never fabricate field names or IDs.
exportJobTypeExcel
ChatGPTExports all instances for a specified job type to an Excel file. BEHAVIOR: If the result set is large, the AI should recommend exporting to Excel and ask the user to confirm. - The export should be requested with a jobTypeId (retrieved from retrieveAllJobTypes). - Before export, the AI may prompt the user to restrict results (filters, date range, pagination) if appropriate. - The tool should validate jobTypeId and return clear error messages on failure.
fetchTenants
ChatGPTFetches tenant names from MongoDB databases for tenant selection. USAGE GUIDELINES: - Use this tool to search for tenants based on a keyword - Extract ONLY the tenant name/keyword from user input (ignore filler words) - The tool performs fuzzy matching on the searchTerm INPUT: - searchTerm: The clean tenant keyword extracted from user message Example: If user says "I want Nodak insurance", extract only "Nodak" OUTPUT: - matchedTenants: List of tenants that match the searchTerm - allTenants: Complete list of all available tenants RESPONSE PROTOCOL: After using this tool, you MUST respond in one of these exact formats: 1. Single match found: VALID:[exact_tenant_name] Example: VALID:nodakinsurance 2. Multiple matches found: LIST:[tenant1,tenant2,tenant3] Example: LIST:nodakinsurance,vrcinsurance,nodakhealth 3. No matches found: ERROR:No tenants found. Please try again. DO NOT add any conversational text. Respond ONLY with the format above.
getAllJobTypesFromSystem
ChatGPTRetrieves slim list of ALL job types in the system (id, name, description). Use this in side menu management to find Module Type and ModuleCategories jobTypeIds and to find the underlying jobTypeId for a module. Call ONCE per turn. Never call multiple times in the same conversation turn. If you already have the jobTypeId from this response do NOT call again.
getCurrentDateTime
ChatGPTReturns the real, current date and time. Call this before resolving ANY relative date or time a caller gives you — "today", "tomorrow", "next Monday", "in two weeks" — and before reading back or saving any date/time field. Never state or save an absolute date you have not just computed from this tool's result. This has no side effects and needs no arguments. RESPONSE: date → ISO date, e.g. "2026-09-21" time → ISO time (24h), e.g. "14:32:07" dayOfWeek → e.g. "Monday" spokenDate → natural-language date for reading aloud, e.g. "Monday, 21 September 2026" spokenTime → natural-language time for reading aloud, e.g. "2:32 PM" timezone → the zone this was computed in, e.g. "UTC"
getInstanceActivity
ChatGPTChecks the activity history and background processing status of any record. Call after every creation or update to monitor what the platform did automatically. ALWAYS use PARENT_INSTANCE_ID from memory — NEVER a sub-record ID. WHEN TO CALL: Immediately after createInstanceForJobType or createInstance succeeds. Tell user: "Let me check the background processing status... ⏳" Retry up to 5 times with brief waits if processing is still running. HOOK STATUS DETECTION: Filter activities where activityType = "AGENTIC_HOOK_ACTIVITY". Group by hookId. For each unique hookId: message contains "execution started" ONLY → still running → wait and poll again message contains "executed" (without "started") → completed ✅ message contains "failed" or "error" → failed ❌ When ALL unique hookIds show a terminal state → processing is complete. When complete → call getJobInstanceById(PARENT_INSTANCE_ID) and show final record. DISPLAY — PLAIN ENGLISH TIMELINE: Show a header: "Here's what happened after your submission:" Then show ALL activities as a timeline — never skip any. For each activity: 📅 [time in readable format] — [plain English description] — [✅/❌/⏳] Translate activityType to plain language: AGENTIC_HOOK_ACTIVITY → "Automated verification check" STATUS_CHANGE → "Record moved to a new stage" FIELD_UPDATE → "Record details were updated" Any other value → "System processing step" For failed hooks: explain in plain English what failed — no technical terms. For still running: "⏳ Still processing — checking again..." When all done: "✅ All background processing is complete!" Then immediately call getJobInstanceById(PARENT_INSTANCE_ID) and show the final record.
getJobInstanceById
ChatGPTFetches complete details of any single record by ID. Fields returned are fully dynamic based on the record's service type. WHEN TO CALL: 1. After getInstanceActivity confirms all processing complete. 2. When user asks to view full details of a specific record. 3. When user picks "Move to next stage" and availableNextStatuses was NOT already in the creation response. 4. Before updateRecord to see current state. INSTANCE ID STRICT PRIORITY: 1. PARENT_INSTANCE_ID from memory (highest priority) 2. instanceId from creation response 3. id from getJobInstancesByName result Never guess. Never read from conversation text. Never mix parent and child record IDs. DISPLAY — FULL, RICH, NOTHING SKIPPED: Show ALL non-empty fields with displayName labels. Skip: isHidden=true fields, SubJob/Service_Type/JSON_KEY/Yml_Key/Tat/Report field types. Strip "(mongoId)" or "(objectId)" from ALL selection values before showing. Format monetary values with context. Format dates in human-readable form. "📋 [ServiceType] — Record Details ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ [Display Name]: [Value] [Display Name]: [Value] ... all non-empty non-hidden fields ... 📊 Current Stage: [secondaryStatus from currentWorkflowStep] 🔄 Available Next Stages: 1️⃣ [secondaryStatus] — requires additional form ← if requiresForm=true 2️⃣ [secondaryStatus] — direct move ← if requiresForm=false ... 📁 Sub-Records: [from CreatedSubJobs — name + status for each] 💡 Tips: [1-2 contextual tips based on current stage]" Never show sequenceNo, raw IDs, or technical codes to user. AFTER SHOWING — HANDLE NEXT STAGE CHOICE: If user picks a stage: requiresForm=false: → updateRecord(instanceId=PARENT_INSTANCE_ID, STATUS, targetWorkflowSequenceNo=sequenceNo) → Show confirmation with new stage name → Show ➕ What next menu again requiresForm=true: → Tell user: "Moving to [stage] requires a short form. Let me pull it up..." → getJobTypeById(subJobTypeId from requiresSubJobTypeIds[0]) → startFormSession(returned jobTypeName, parentInstanceId=PARENT_INSTANCE_ID) → Collect fields via submitFieldAnswer one at a time → createInstanceForJobType(sessionId) → Status moves AUTOMATICALLY — NEVER call updateRecord STATUS in this path → After creation: check response for subJobWorkflowInfo and handle it → Show ➕ What next menu again
getJobInstancesByName
ChatGPTFetches instances for a specific job type using its name, with pagination, filtering, and sorting support. BEHAVIOR: 1. When a user requests data filtered by a specific field (e.g., "Show all Claims where Policy Number is 2023-78945"): - Use the field name as provided by the user. Apply case-insensitive fuzzy matching to determine the most likely exact field name (e.g., user says "Policy Number" → use "Policy No"). - Construct the filter JSON as: [{"fieldName":"<ExactMatchedFieldName>","condition":"is","value":"<UserProvidedValue>"}] - Dynamically URL-encode this JSON at runtime before making the API call. (Do NOT hardcode encoded text; always encode dynamically based on actual field name and value.) - Example: Input JSON → [{"fieldName":"Policy No","condition":"is","value":"2023-78945"}] Encoded URL → %5B%7B%22fieldName%22%3A%22Policy%20No%22%2C%22condition%22%3A%22is%22%2C%22value%22%3A%222023-78945%22%7D%5D - Final API endpoint example: /api/v1/job-types/name/Claims/instances?pageNumber=0&pageSize=150&filters=%5B%7B%22fieldName%22%3A%22Policy%20No%22%2C%22condition%22%3A%22is%22%2C%22value%22%3A%222023-78945%22%7D%5D 2. Always encode dynamically at runtime — never store or reuse pre-encoded filters. 3. If the user does not specify a filter, fetch default paginated results with pageNumber=0 and pageSize=150. 4. When the result set is large, the AI should suggest exporting the records using ‘exportJobTypeExcel’ and confirm whether to export all or partial records. 5. Always use the exact job type name when invoking this tool, along with pagination, filters, keyword, and sorting parameters when applicable. ERROR HANDLING: - Provide user-friendly messages when: • The specified job type name does not exist. • The API call fails or returns an unexpected response.
getJobTypeById
ChatGPTFetches field definitions for any service or form type by its ID. Fields are completely dynamic — specific to the service type and tenant. USE CASE 1 — Getting exact filterable field names before searching: Call with jobTypeId from retrieveAllJobTypes. Use returned fieldsToCollect[].name as exact filter keys for getJobInstancesByName. Never filter without doing this first — field names vary completely by service type. USE CASE 2 — Status change requiring a form (requiresForm=true): When getJobInstanceById returns Next_Job_Statuses with requiresForm=true: Call with the subJobTypeId from requiresSubJobTypeIds[0]. Use returned jobTypeName to call: startFormSession(jobTypeName, parentInstanceId=PARENT_INSTANCE_ID) Collect fields via submitFieldAnswer one at a time. Then createInstanceForJobType(sessionId). ⚠️ The stage change happens AUTOMATICALLY — NEVER call updateRecord(STATUS) after this. After creation: check response for subJobWorkflowInfo — if present offer stage move for the sub-record using subJobWorkflowInfo.subJobInstanceId (NOT PARENT_INSTANCE_ID). Then show ➕ What next menu. RESPONSE: jobTypeName → use as-is for startFormSession — do not modify fieldsToCollect → mandatory fields with their options hiddenFields → conditionally shown fields
getMandatoryFieldsOfJobType
ChatGPTRetrieves the mandatory fields for a confirmed record type. PRE-CONDITIONS: Call ONLY after retrieveAllJobTypes has been called and the user has confirmed which record type they want. Use the EXACT id from the stored retrieveAllJobTypes response. RETURNS either: A) { "mode": "WIZARD", "redirectUrl": "https://..." } → Share the URL with the user and stop this branch. B) { "mode": "FIELDS", "mandatoryFields": [ { "name": "...", "fieldType": "...", "allowedValues": "...", "defaultValue": "...", "isHidden": bool }, ... ] } → Process every field using the rules below before asking the user anything. ════════════════════════════════════════════════════════════ STEP 1 — CLASSIFY ALL FIELDS BEFORE ASKING ANYTHING ════════════════════════════════════════════════════════════ For every field in mandatoryFields, apply this classification in order: AUTO_FIELDS (never ask the user, always include in data silently): A field is AUTO if ANY of these are true: • fieldType starts with "ReadOnly" (e.g. ReadOnly_Small_Text, ReadOnly_Numeric) • isHidden = true • defaultValue is present AND non-empty AND fieldType is not Selection/File/Attachment (for these, use the defaultValue as the value) • There is no defaultValue and the field is ReadOnly/Hidden → still include it with value = "" (empty string) so the backend receives the key Rule: AUTO_FIELDS go directly into the data object. Never mention them to the user. If defaultValue exists → data[field.name] = field.defaultValue If no defaultValue → data[field.name] = "" USER_TEXT_FIELDS (ask the user): fieldType is Text, Small_Text, Numeric_Text, Number, Date, or Selection AND the field is NOT classified as AUTO above FILE_FIELDS (ask the user, one at a time): fieldType is File or Attachment AND the field is NOT classified as AUTO above ════════════════════════════════════════════════════════════ STEP 2 — ASK (one message for all USER_TEXT_FIELDS) ════════════════════════════════════════════════════════════ If there are zero USER_TEXT_FIELDS and zero FILE_FIELDS: → Skip to confirmation summary immediately using only AUTO_FIELDS values. Otherwise compose one friendly message listing every USER_TEXT_FIELD. Derive a human-readable label from each field's name or displayName if present. For Selection fields: list allowed values naturally in parentheses. Never show raw backend field names to the user. ════════════════════════════════════════════════════════════ STEP 3 — PARSE USER RESPONSE (accept ANY format) ════════════════════════════════════════════════════════════ Users may reply as prose, bullet lists, comma-separated, key=value, or any format. YOU must: 1. Parse their entire response 2. Map each piece to the correct USER_TEXT_FIELD using semantic / fuzzy matching 3. For Selection fields: match user words to the closest allowed value automatically 4. For Text / Number / Date fields: use the value directly 5. Never ask the user to reformat their reply ════════════════════════════════════════════════════════════ STEP 4 — HANDLE GAPS ════════════════════════════════════════════════════════════ If a USER_TEXT_FIELD value is genuinely missing → ask only for that field. If a value is ambiguous between two or more allowed options → ask one short question. Never re-ask for fields already answered. ════════════════════════════════════════════════════════════ STEP 5 — CONFIRMATION SUMMARY (mandatory before creating) ════════════════════════════════════════════════════════════ Show only USER_TEXT_FIELDS in the summary (do not mention AUTO_FIELDS to the user): "Here's what I've captured — please confirm: • [Human label]: [value] • [Human label]: [value] ... Shall I go ahead and create this?" Wait for explicit user confirmation. ════════════════════════════════════════════════════════════ STEP 6 — FILE_FIELDS (after text confirmation, one at a time) ════════════════════════════════════════════════════════════ "Please attach the file for '[human-readable label]'." After attach: "Got it — '[filename]' will be saved for '[label]'. Does that look right?" Wait for confirmation before the next file field. ════════════════════════════════════════════════════════════ STEP 7 — BUILD data OBJECT ════════════════════════════════════════════════════════════ The final data object sent to createInstanceForJobType MUST contain: • Every AUTO_FIELD → key = field.name, value = defaultValue or "" • Every USER_TEXT_FIELD → key = field.name, value = user-provided (mapped) value File fields are handled separately via openaiFileIdRefs / fileFieldMappings. FORBIDDEN: ❌ Skipping AUTO_FIELDS from the data object ❌ Asking the user about AUTO_FIELDS ❌ Calling this tool more than once for the same record type ❌ Showing raw backend field names to the user ❌ Creating the record without the confirmation summary
getSubJobTypes
ChatGPTChecks whether a newly created record instance has child record types that also need to be filled. WHEN TO CALL: Immediately after every successful createInstanceForJobType call. Pass: parentJobTypeName = the name of the record type just created parentInstanceId = response[0].InstanceId from that createInstanceForJobType call ════════════════════════════════════════════════════════════ SESSION STACK ════════════════════════════════════════════════════════════ Maintain an internal stack. Each node: { jobTypeName: string, jobTypeId: string, instanceId: string, ← from createInstanceForJobType response[0].InstanceId — LOCKED pendingChildren: [{ id, name }, ...], currentChildIndex: number } ✅ Push node immediately when createInstanceForJobType returns an InstanceId ✅ Populate pendingChildren when this tool returns child types ✅ Increment currentChildIndex after each child is fully processed ✅ Pop the node when all children are processed ✅ After popping, resume the parent node from its currentChildIndex ❌ Never overwrite instanceId once stored ❌ Never use one node's instanceId for another node's call ❌ Never read instanceId from conversation history — always from stack ════════════════════════════════════════════════════════════ RECURSIVE ALGORITHM ════════════════════════════════════════════════════════════ FUNCTION process(jobTypeId, jobTypeName, parentInstanceId=null): 1. Say: "Just a moment — pulling up the required details for this." 2. Call getMandatoryFieldsOfJobType(jobTypeId, jobTypeName) 3. mode=WIZARD → send redirectUrl to user → RETURN 4. mode=FIELDS: a. Classify fields: AUTO_FIELDS (ReadOnly / Hidden / has defaultValue) vs USER_TEXT_FIELDS vs FILE_FIELDS b. AUTO_FIELDS → add to data silently (defaultValue or ""), never ask the user c. Ask ALL USER_TEXT_FIELDS in one friendly message (human-readable labels) d. Accept user response in any format — map to allowed values e. Show confirmation summary of USER_TEXT_FIELDS only → wait for user confirmation f. Collect FILE_FIELDS one at a time with per-file confirmation 5. Build data object: AUTO_FIELDS + USER_TEXT_FIELDS (all with EXACT backend field names as keys) 6. Call createInstanceForJobType: - data: the built data object - parentJobInstanceId = parentInstanceId (ONLY if parentInstanceId is not null; omit entirely otherwise) 7. ON SUCCESS: - newInstanceId = response[0].InstanceId - PUSH { jobTypeName, jobTypeId, instanceId: newInstanceId, pendingChildren: [], currentChildIndex: 0 } - Call getSubJobTypes(parentJobTypeName=jobTypeName, parentInstanceId=newInstanceId) - children = response.childJobTypes - If children empty → POP → RETURN - If children present: STACK_TOP.pendingChildren = children FOR each child automatically (no user prompt needed between children): Say: "I need a few more details for the next section. Let's keep going!" CALL process(child.id, child.name, STACK_TOP.instanceId) STACK_TOP.currentChildIndex++ POP → RETURN 8. ON FAILURE (createInstanceForJobType returns error): - Do NOT lose the stack state - Do NOT restart the flow - Do NOT ask the user to start a new record - Retry the same createInstanceForJobType call up to 3 times automatically - If all 3 retries fail: tell the user there was a temporary issue and ask them to confirm once more — then retry with the SAME data already collected - NEVER re-ask the user for field values that were already confirmed - NEVER clear the pending data on failure ════════════════════════════════════════════════════════════ FLOW INTERRUPTION RULES — CRITICAL ════════════════════════════════════════════════════════════ Once the creation flow is running (after user says "create" / "yes" / "confirm"): ✅ Continue processing all child sections automatically after each successful create ✅ Only pause to ask the user for field values for the next child section ✅ Only pause if createInstanceForJobType fails and all retries are exhausted ❌ NEVER stop and ask the user "shall I continue?" between sections ❌ NEVER ask the user to say "proceed" between child sections ❌ NEVER restart the creation flow because of a single failure ❌ NEVER treat a failure as "done" — always retry with existing data START: retrieveAllJobTypes → match → confirm → CALL process(id, name, null) When stack empty → "All done! Everything has been created successfully." ════════════════════════════════════════════════════════════ RESPONSE FORMAT ════════════════════════════════════════════════════════════ { "confirmedJobTypeName": "...", "confirmedInstanceId": "...", "childJobTypes": [ { "id": "...", "name": "..." }, ... ] } Always read instanceId from confirmedInstanceId — not from memory. Empty childJobTypes means this is a leaf node. USER COMMUNICATION: Never show IDs, stack, or internal state to the user. Use warm, conversational language throughout.
getWorkflow
ChatGPTFetches the current workflow for a job type or by workflow ID. Use before workflowCreate to check if a workflow exists. Use before workflowUpdate to read current steps. Pass either: jobTypeId — fetches workflow by job type workflowId — fetches workflow directly by its own ID Returns: workflowId, workflowName, jobTypeId, steps array, stepsCount. If no workflow exists returns success: false with error message.
jobTypeUpdate
ChatGPTUpdates field definitions on an existing job type (schema/configuration level). Use this to modify job type metadata such as ModuleConstants configuration fields — NOT for updating instance data records (use updateRecord for that). ALWAYS fetch the job type first via getJobTypeById before calling this tool, so you know the current field values and can show a before/after confirmation. Parameters: - jobTypeId: the ID of the job type to update - fieldsToUpdate: FLAT object containing ONLY the fields being changed Keys = exact field names as returned by getJobTypeById Values = new values as strings Example: {"LOGIN_TITLE": "My Portal", "CURRENCY": "USD"} FLOW: 1. User describes a configuration change 2. getJobTypeById(jobTypeId) → read current values 3. Map user's request to the correct field(s) and new value(s) 4. Show before/after summary and ask user to confirm 5. jobTypeUpdate(jobTypeId, { only changed fields }) 6. Confirm success and summarise what changed NEVER include unchanged fields in fieldsToUpdate. NEVER call this without first showing the user a confirmation summary.
retrieveAllJobTypes
ChatGPTRetrieves all available record types. Returns list of { "id", "name" } entries. STORAGE RULE: Store the ENTIRE response in session memory (id + name for every entry). Use EXACT id values when calling other tools. Never invent or guess IDs. DISPLAY RULE: Never show IDs to the user. Show names only. MATCHING RULE: Always fuzzy-match the user's intent to the name field before doing anything else. ZERO matches → show all names, ask user to pick one ONE match → confirm with user: "I found '[Name]'. Is that right?" MULTI matches → show numbered list of matched names, wait for selection Never call any other tool until the user has confirmed which record type they want. After confirmation say: "Great! Let me gather the information needed to set this up for you."
singleJobInstanceDownload
ChatGPT• Step 1: Call 'GetJobInstancesByNameTool' with jobTypeName, fieldName, and fieldValue to find the matching Job Instance. - Step 2: Retrieve the jobInstanceId from the matching record. - Step 3: Call 'singleJobInstanceDownload' with that jobInstanceId to download the Job Instance as an Excel (.xlsx) file.
startEditSession
ChatGPTLoads any existing record for editing. ALWAYS call before updateRecord FIELDS. Returns current field values and all editable fields — dynamic per service type. WHEN TO CALL: When user wants to edit or update any field in any existing record. FLOW: 1. Call startEditSession(instanceId) 2. Display ALL current non-empty values using displayName labels. Strip "(mongoId)" from all selection values before showing. Never show raw backend field names. 3. Ask: "Which of these would you like to update? 📝" 4. Collect new values ONLY for what user wants to change — one at a time. 5. Call updateRecord with: instanceId = same instanceId updateType = "FIELDS" fieldsToUpdate = flat object with ONLY the changed fields Keys = EXACT editableFields[].name from this response Values = new values as strings Example: {"Exact Field Name": "new value", "Other Field": "other value"} 6. NEVER include unchanged fields in fieldsToUpdate. 7. NEVER nest fieldsToUpdate inside another object. 8. NEVER call getJobInstanceById after a successful field update. FIELD NAME RULE — CRITICAL: fieldsToUpdate keys MUST be EXACT editableFields[].name values from THIS response. These are dynamic, service-specific, may contain spaces and special characters. Use exactly as returned — never modify, camelCase, or abbreviate. Example: use "Gross Loss" not "grossLoss", "Policy Number" not "policyNumber". FIELD_UNLOCKED during editing: If editing a selection field causes FIELD_UNLOCKED response: Show newFields options EXACTLY as returned — never guess or fabricate. DISPLAYING CURRENT VALUES: "Here's what's currently on this record: 📋 [Display Name]: [Current Value] 📋 [Display Name]: [Current Value] ... all non-empty editable fields ... What would you like to change? 😊" AFTER SUCCESSFUL UPDATE: Show a clear confirmation of exactly what changed and the new values. Ask if user wants to change anything else or proceed to next step.
startFormSession
ChatGPTStarts a guided data-collection session for creating a new record of any service type. The service type is determined by jobTypeName — it could be a Claim, Proposal, Policy, Survey, Inspection, or any other service this tenant supports. Call this FIRST before asking the user any field questions. WHEN TO CALL: When the user wants to create any new record of any type. Call ONCE per record — it returns everything needed for the full conversation. WHAT IT RETURNS: - sessionId: pass to every submitFieldAnswer and createInstanceForJobType call - fieldsToCollect: ordered mandatory fields specific to this service type - optionalFields: service-specific optional fields — only collect if user mentions them - autoFilledValues: already pre-filled system defaults - hasSubJobs: whether sub-records can be added (varies by service type) ═══════════════════════════════════════════════════════ SMART BULK COLLECTION — CRITICAL BEHAVIOR ═══════════════════════════════════════════════════════ If the user has already provided information upfront in their message: 1. Call startFormSession silently — do NOT ask questions yet 2. Match user's provided info against fieldsToCollect + optionalFields 3. Call submitFieldAnswer silently for each matched field 4. Then say: "Got it! I've pre-filled [N] fields from what you shared. I just need a few more details:" 5. Ask ONLY remaining mandatory fields ONE AT A TIME 6. If user mentioned optional field values — include them too, never ignore NEVER re-ask fields the user already provided. FIELD ASKING RULES (apply regardless of service type): - TEXT fields: ask conversationally, like a human colleague - SELECTION fields: show ALL available options as a clean numbered list - DATE fields: ask in DD-MM-YYYY format, give today as example - NUMERIC fields: ask clearly, mention currency/unit if context suggests it - FILE fields: SKIP — never use submitFieldAnswer for files - Fields with defaultValue: say "This defaults to '[value]' — want to keep or change? 😊" After each answer: call submitFieldAnswer immediately. Follow status codes from submitFieldAnswer exactly. After all mandatory fields: ask "Is there anything else you'd like to add? 😊" Only collect optional fields if user specifically mentions matching info. TONE: Warm, friendly, encouraging. Make it feel like talking to a helpful colleague.
submitBatchAnswers
ChatGPTSubmits multiple field answers at once during an active form session. This tool allows batch submission of answers for fields collected via startFormSession. The backend will process all answers sequentially and handle dependent fields, AJAX rules, and field un-hiding automatically. Parameters: - sessionId: The session ID returned from startFormSession - answers: A flat key-value map where key = fieldName and value = user answer - dateConstraints: optional key-value map, fieldName -> "FUTURE_ONLY" | "PAST_ONLY", for any DATE/DATETIME field in this batch that needs a direction check Important Notes: - For SELECTION fields, values must exactly match one of the options provided in the session. - For array fields (e.g. Menu_key), pass value as JSON string array like: ["Tab1", "Tab2"] - Only call this tool with fields that were returned in fieldsToCollect. - After calling, check the status in response: CONTINUE → More fields remaining (use remainingFields) READY_TO_SUBMIT → All fields collected, ask user for final confirmation Always show the user what will be submitted before calling this tool. DATE / DATETIME FIELDS — dateConstraints: For every field in this batch whose inputType is DATE or DATETIME, decide for yourself — from the field's displayName and what this record represents — whether it needs a direction check, and add it to dateConstraints: "Field Name": "FUTURE_ONLY" → forward-scheduled dates: booking date, appointment date, delivery date, policy start date, renewal date. Rejected if before today. "Field Name": "PAST_ONLY" → historical/biographical dates: date of birth, date of incorporation, date of loss, date of last claim. Rejected if after today. (omit the field entirely) → anything else, or you are not confident. No validation is applied — this is always the safe default. There is no server-side config that decides this — you decide it, per field, from context, every time. Never mark a clearly historical/birth date as FUTURE_ONLY, and never mark a clearly forward-scheduled date as PAST_ONLY.
submitFieldAnswer
ChatGPTSubmits the user's answer for one field at a time in the active form session. Works for any service type — the fields are dynamic based on the record type. Call after EVERY field answer — both main form fields AND sub-record fields. NEVER use for FILE fields — use createInstance instead. STATUS CODES — EXACT BEHAVIOR FOR EACH: CONTINUE → More fields remain. Ask for nextField shown in response. → Keep the energy going: "Got it! 👍 Moving on..." FIELD_UNLOCKED → A previously hidden field became visible based on the user's answer. → Ask for each field in newFields immediately. → Say: "Based on that answer, I need one more detail:" READY_TO_SUBMIT → All mandatory fields collected. → Show a beautiful, readable summary of ALL collected values. → Use displayName labels — never raw field names. → Check pendingFileFields[]: If present → "Almost there! Please upload: [field names] 📎 — this is required." If absent → "Everything looks good! Got a document to attach? 📎 (optional — or say skip)" → Wait for user confirmation before submitting. SUBJOB_CONTINUE → Currently collecting sub-record fields. Ask for nextField. SUBJOB_FIELD_UNLOCKED → Hidden sub-record field appeared. Ask for each in newFields. SUBJOB_INSTANCE_COMPLETE → One sub-record saved successfully ✅ → Ask: "Sub-record added! Would you like to add another?" → If yes: call submitFieldAnswer with isSubJobField=true for first field. → If no: call createInstanceForJobType. SUBJOB_NO_MANDATORY_FIELDS → No required fields for this sub-record section. → Ask: "No required fields here. Would you like to add optional details? 😊" → If yes: collect optionalFields with isSubJobField=true. → If no: call createInstanceForJobType. FIELD NAME RULE — CRITICAL: Always use the EXACT field name from fieldsToCollect[].name. Field names are dynamic and service-specific — may contain spaces. Use exactly what the server returns — never modify or guess field names. NEVER batch multiple answers in one call — strictly one field at a time. NEVER call this for FILE fields. DATE / DATETIME FIELDS — dateConstraint: When fieldsToCollect[].inputType is DATE or DATETIME, decide for yourself — from the field's displayName and what this record represents — whether it needs a direction check, and pass dateConstraint accordingly: FUTURE_ONLY → the date is something being scheduled going forward: a booking date, appointment date, delivery date, policy start date, renewal date. Rejected if the caller gives a date before today. PAST_ONLY → the date is a historical/biographical fact: date of birth, date of incorporation, date of loss, date of last claim, date of issue. Rejected if the caller gives a date after today. (omit) → anything else, or you are not confident which direction applies. No validation is applied — this is always the safe default. There is no server-side config that decides this — you are the one deciding it, per field, from context, every time. Never guess FUTURE_ONLY for a field that is clearly a birth/historical date, and never guess PAST_ONLY for a field that is clearly a forward-scheduled date.
terminateSession
ChatGPTThis tool allows the user to securely terminate or log out of their current session. It should only be executed when the user explicitly requests to end, exit, switch, or log out of the session. Before execution, the tool must confirm the user’s intent to proceed with termination to prevent accidental logouts. Once executed, the user’s session and related authentication data will be cleared, ensuring a clean and secure exit. IMPORTANT: When this tool is executed successfully it MUST return this EXACT text string: "Termination tool has been called successfully"
updateRecord
ChatGPTUpdates an existing record of any service type. Supports two update types: updating field values, or changing workflow status. ════════════════ UPDATE TYPE: FIELDS ════════════════ Updates specific field values. Works for any service type. ALWAYS call startEditSession FIRST — never update fields without loading the record. Parameters: - instanceId: from startEditSession response - updateType: "FIELDS" - fieldsToUpdate: FLAT object with ONLY the changed fields Keys = EXACT field names from editableFields[].name (dynamic, service-specific) Values = new values as strings Example: {"[Exact Field Name]": "new value", "[Another Field]": "new value"} - Field names are service-specific — use exactly what startEditSession returned - NEVER include unchanged fields - NEVER nest inside another object DATE / TIME VALUE FORMAT — CRITICAL: Always provide date and time values in IST (India Standard Time) in human-readable form. The system converts them to UTC automatically. - Date fields → "YYYY-MM-DD" (e.g. "2026-08-03") - Time fields → "HH:MM" 24-hour IST (e.g. "18:00" for 6 PM IST) - DateTime → "YYYY-MM-DD HH:MM" (e.g. "2026-08-03 18:00") NEVER send ISO UTC strings (e.g. "2026-08-03T18:00:00Z") — they bypass IST conversion and will save the wrong time. If user says "6 PM", send "18:00". If user says "tomorrow", resolve the date and send "YYYY-MM-DD". When a booking/record has BOTH a Date field and a Time field, update BOTH when the user changes date or time. FLOW FOR FIELD UPDATE: 1. User says "edit/update record X" 2. getJobInstancesByName → get instanceId 3. startEditSession(instanceId) → show current values 4. User confirms what to change 5. updateRecord(instanceId, FIELDS, {only changed fields}) 6. Show confirmation ════════════════ UPDATE TYPE: STATUS ════════════════ Moves a record to a new workflow stage. Only use when requiresForm=false. If requiresForm=true → use the form path instead. Parameters: - instanceId: the record ID - updateType: "STATUS" - targetWorkflowSequenceNo: from Next_Job_Statuses[].sequenceNo FLOW FOR STATUS UPDATE: 1. getJobInstanceById → see Next_Job_Statuses 2. User picks a stage 3. Check requiresForm: false → updateRecord(STATUS, targetWorkflowSequenceNo) true → getJobTypeById → startFormSession → createInstanceForJobType (auto-moves status) NEVER call updateRecord(STATUS) in the true path AFTER SUCCESS (both types): Show a clear confirmation of what changed and the current state. Add a helpful tip about what the new status/values mean. DATE / DATETIME FIELDS IN fieldsToUpdate — dateConstraints: updateRecord has no session to remember earlier hints, so for every DATE/DATETIME field in fieldsToUpdate, decide for yourself — from the field's displayName and what the record represents — whether it needs a direction check, and pass it in dateConstraints: "Field Name": "FUTURE_ONLY" → forward-scheduled dates (booking date, appointment date, policy start/renewal date). Rejected if before today. "Field Name": "PAST_ONLY" → historical/biographical dates (date of birth, date of incorporation, date of loss). Rejected if after today. (omit the field entirely) → no validation applied — the safe default. There is no backend config for this — you decide it, per field, every call.
workflowCreate
ChatGPTCreates a new workflow for a job type. Use when a job type has NO existing workflow. Always call getWorkflow first to confirm no workflow exists. Each step must include: sequenceNo : integer — position in workflow primaryStatus : string — top-level status group secondaryStatus : string — sub-status label nextWorkflowSteps : array of integers — valid transitions isInitialStatus : boolean — true for entry point step only isTerminationStatus : boolean — true for final/closed steps isPendingStatus : boolean — true for awaiting-action steps isHidden : boolean — true to hide from UI followupRole : string — "" if none apiOnStatusChange : string — "" if none jobStatusRule : string — "" if none fieldsForGroupingTotal : string — "" if none emailTemplateIds : array — [] if none attachmentEmailTemplateIds : array — [] if none subJobTypeIds : array of strings — [] if none taskActionTemplateIds : array — [] if none roles : array of full Role objects — [] if none RULES: - Exactly ONE step must have isInitialStatus: true - Terminal steps must have isTerminationStatus: true and nextWorkflowSteps: [] - sequenceNo must be unique integers - nextWorkflowSteps must reference valid sequenceNo values in the same workflow - Boolean fields: true/false/null only — never strings - Always confirm full step summary with user before calling
workflowUpdate
ChatGPTUpdates the workflow steps for a job type. Reads the current workflow for the given jobTypeId, replaces its steps with stepsUpdate, then saves the full workflow. WorkflowStep field types — must match exactly: sequenceNo : int — integer, never a string nextWorkflowSteps : Set<Integer> — array of integers e.g. [2, 3] subJobTypeIds : Set<String> — array of strings or null attachmentEmailTemplateIds : Set<String> — array of strings or null taskActionTemplateIds : Set<String> — array of strings or null isInitialStatus : Boolean — true | false | null only isPendingStatus : Boolean — true | false | null only isTerminationStatus : Boolean — true | false | null only isHidden : Boolean — true | false | null only roles (step-level) : List<Role> — full Role objects or null or [] {id, name, description, properties, scope, routerUrl} NEVER bare ID strings emailTemplates : List<{templateInstanceId}> or null or [] JobWorkflowType top-level: roles : List<String> — plain role ID strings or null isVisibleInDashboard : Boolean or null lockStatusSequenceNo / unlockStatusSequenceNo : Integer or null FLOW: 1. Call getJobInstanceById to read the current workflow and steps 2. Apply the changes in memory 3. Show before/after summary and confirm with the user 4. Call workflowUpdate with the COMPLETE updated steps array 5. Confirm success CRITICAL RULES: - Send the COMPLETE steps array — partial array deletes the missing steps - sequenceNo : integer, never a string - nextWorkflowSteps : array of integers, never strings - Boolean flags : true | false | null — never "true" / "false" / 1 / 0 - Step roles : full Role objects — never bare ID strings - Only one step should have isInitialStatus: true - When removing a step, remove its sequenceNo from all other steps' nextWorkflowSteps