{ "kind": "open-flow-workflow", "version": 1, "name": "Google Sheets Community Lead Rating", "content": { "modelVersion": 14, "document": { "bindings": {}, "graph": { "nodes": { "n_b59e907c7bd7bcb0": { "name": "Watch for new applications", "kind": "poll", "config": { "spreadsheetId": { "kind": "value", "value": "YOUR_GOOGLE_SHEET_ID" }, "sheet": { "kind": "value", "value": "Form Responses 1" }, "columnRange": { "kind": "value", "value": "A:Z" }, "headerRow": { "kind": "value", "value": 1 }, "firstDataRow": { "kind": "value", "value": 2 }, "maxRowsPerPoll": { "kind": "value", "value": 100 }, "valueRender": { "kind": "value", "value": "UNFORMATTED_VALUE" }, "dateTimeRender": { "kind": "value", "value": "FORMATTED_STRING" } }, "definition": { "configInputs": [ { "jsonSchema": { "type": "string", "pattern": "^[A-Za-z]{1,3}(?::[A-Za-z]{1,3})?$" }, "nullable": false, "handle": "columnRange", "value": "A:ZZZ" }, { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "sheet" }, { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "spreadsheetId" }, { "collapsed": true, "group": "Advanced settings" }, { "jsonSchema": { "type": "string", "enum": [ "FORMATTED_STRING", "SERIAL_NUMBER" ] }, "nullable": false, "handle": "dateTimeRender", "value": "FORMATTED_STRING" }, { "jsonSchema": { "type": "integer", "minimum": 1 }, "nullable": false, "handle": "firstDataRow", "value": 2 }, { "jsonSchema": { "type": "integer", "minimum": 1 }, "nullable": false, "handle": "headerRow", "value": 1 }, { "jsonSchema": { "type": "integer", "minimum": 1, "maximum": 500 }, "nullable": false, "handle": "maxRowsPerPoll", "value": 100 }, { "jsonSchema": { "type": "string", "enum": [ "UNFORMATTED_VALUE", "FORMATTED_VALUE", "FORMULA" ] }, "nullable": false, "handle": "valueRender", "value": "UNFORMATTED_VALUE" } ], "definitionVersion": 2, "description": "Polls a sheet and triggers once for every new row appended below the last row already seen.", "displayName": "New Row Added", "key": "googlesheets.on_row_added", "name": "on_row_added", "outputs": [ { "jsonSchema": { "type": "array", "items": { "type": "object", "properties": { "row": { "type": "object" }, "rowNumber": { "type": "integer" }, "sheetId": { "type": "integer" }, "sheetTitle": { "type": "string" }, "spreadsheetId": { "type": "string" }, "values": { "type": "array", "items": {} } }, "additionalProperties": false, "required": [ "spreadsheetId", "sheetId", "sheetTitle", "rowNumber", "row", "values" ] } }, "nullable": false, "handle": "events" } ], "provider": "googlesheets", "type": "poll" }, "pollTimes": [ { "type": "every", "unit": "minute", "value": 1 } ] }, "n_fc455638d21c724b": { "inputs": { "events": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_b59e907c7bd7bcb0", "output": "events" } ] } }, "name": "Keep every new lead", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "array", "items": { "type": "object", "properties": { "row": { "type": "object" }, "rowNumber": { "type": "integer" }, "sheetId": { "type": "integer" }, "sheetTitle": { "type": "string" }, "spreadsheetId": { "type": "string" }, "values": { "type": "array", "items": {} } }, "additionalProperties": false, "required": [ "spreadsheetId", "sheetId", "sheetTitle", "rowNumber", "row", "values" ] } }, "nullable": false, "handle": "events" } ], "outputs": [ { "jsonSchema": { "type": "array", "items": { "type": "object", "additionalProperties": true } }, "nullable": false, "handle": "leads" }, { "jsonSchema": { "type": "integer" }, "nullable": false, "handle": "count" } ], "name": "Keep every new lead", "moduleId": "n_0631046a69c8c49d", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_499021df69963126": { "inputs": { "leads": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_fc455638d21c724b", "output": "leads" } ] }, "previousState": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_499021df69963126", "output": "state" } ] }, "response": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_8580dc99d4f0b142", "output": "output" } ] } }, "name": "Collect all lead ratings", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "array", "items": { "type": "object", "additionalProperties": true } }, "nullable": false, "handle": "leads" }, { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": true, "handle": "previousState" }, { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": true, "handle": "response" } ], "outputs": [ { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "state" }, { "jsonSchema": { "type": "boolean" }, "nullable": false, "handle": "more" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "prompt" }, { "jsonSchema": { "type": "array", "items": { "type": "object", "additionalProperties": true } }, "nullable": false, "handle": "results" }, { "jsonSchema": { "type": "integer" }, "nullable": false, "handle": "count" } ], "name": "Collect all lead ratings", "moduleId": "n_20e22ae2d31e8787", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_87dc9985342b22a4": { "inputs": {}, "name": "Another lead to rate", "kind": "condition", "matchMode": "first", "cases": [ { "output": "more", "groups": [ { "expressions": [ { "left": { "kind": "source", "source": { "kind": "node", "nodeId": "n_499021df69963126", "output": "more" } }, "operator": "==", "right": { "kind": "value", "value": true } } ] } ] } ] }, "n_8580dc99d4f0b142": { "inputs": { "prompt": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_499021df69963126", "output": "prompt" } ] } }, "name": "Apply the community criteria", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "prompt" } ], "outputs": [ { "description": "The final result produced by the Agent.", "jsonSchema": { "type": "object", "properties": { "rating": { "type": "string", "enum": [ "qualified", "not qualified" ] }, "explanation": { "type": "string" } }, "required": [ "rating", "explanation" ], "additionalProperties": false }, "nullable": false, "handle": "output" } ], "name": "Apply the community criteria", "executor": { "kind": "agent", "code": false, "model": "gpt-4.1", "prompt": "Your task is to qualify incoming leads. Leads are form submissions to a closed community group. Use the following criteria for a quality lead:\n\n1. We are looking for decision makers who run companies or who have some teams. The bigger the team - the better. Basically, everyone with some level of responsibility should be accepted. This is the main criterion.\n2. Email from a non-standard domain. Ideally this should be a corporate domain, but this is a secondary criterion.\n\nPlease thing step by step whether a lead is quality or not?\n\nIf at least one of the criteria satisfy, reply with \"qualified\" in response. Otherwise reply \"not qualified\". Reply with a JSON of the following structure: {\"rating\":\"string\",\"explanation\":\"string\"}. Reply only with with the JSON and nothing more!\n\n{{prompt}}", "maxRounds": 1, "tools": [] } } }, "n_c38ed8b1da14e180": { "inputs": { "spreadsheetId": { "kind": "value", "value": "YOUR_GOOGLE_SHEET_ID" }, "range": { "kind": "value", "value": "'Form Responses 1'!A:Z" }, "majorDimension": { "kind": "value", "value": "ROWS" }, "valueRenderOption": { "kind": "value", "value": "FORMATTED_VALUE" }, "dateTimeRenderOption": { "kind": "value", "value": "FORMATTED_STRING" } }, "name": "Read current Timestamp matches", "kind": "task", "task": { "inputs": [ { "description": "The spreadsheet ID.", "jsonSchema": { "type": "string", "minLength": 1, "description": "The spreadsheet ID." }, "nullable": true, "handle": "spreadsheetId", "value": null }, { "description": "The A1 notation of the range to retrieve.", "jsonSchema": { "type": "string", "minLength": 1, "description": "The A1 notation of the range to retrieve." }, "nullable": false, "handle": "range" }, { "description": "The major dimension for the returned values.", "jsonSchema": { "type": "string", "enum": [ "DIMENSION_UNSPECIFIED", "ROWS", "COLUMNS" ], "description": "The major dimension for the returned values." }, "nullable": true, "handle": "majorDimension", "value": null }, { "description": "How values should be rendered in the output.", "jsonSchema": { "type": "string", "enum": [ "FORMATTED_VALUE", "UNFORMATTED_VALUE", "FORMULA" ], "description": "How values should be rendered in the output." }, "nullable": true, "handle": "valueRenderOption", "value": null }, { "description": "How dates and times should be rendered in the output.", "jsonSchema": { "type": "string", "enum": [ "SERIAL_NUMBER", "FORMATTED_STRING" ], "description": "How dates and times should be rendered in the output." }, "nullable": true, "handle": "dateTimeRenderOption", "value": null } ], "outputs": [ { "description": "The A1 notation of the range.", "jsonSchema": { "type": "string", "description": "The A1 notation of the range." }, "nullable": false, "handle": "range" }, { "description": "The major dimension of the values (ROWS or COLUMNS).", "jsonSchema": { "type": "string", "description": "The major dimension of the values (ROWS or COLUMNS)." }, "nullable": false, "handle": "majorDimension" }, { "description": "The data values in the range.", "jsonSchema": { "type": "array", "items": { "type": "array", "items": { "anyOf": [ { "type": "string", "description": "A union variant." }, { "type": "number", "description": "A union variant." }, { "type": "boolean", "description": "A union variant." }, { "const": null, "description": "A union variant." } ], "description": "The cell value schema." }, "description": "An array item." }, "description": "The data values in the range." }, "nullable": false, "handle": "values" } ], "name": "Read current Timestamp matches", "executor": { "kind": "connector", "action": "googlesheets.values_get" } } }, "n_3c5db2cb41b37024": { "inputs": { "values": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_c38ed8b1da14e180", "output": "values" } ] }, "results": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_499021df69963126", "output": "results" } ] }, "sheetName": { "kind": "value", "value": "Form Responses 1" } }, "name": "Plan only Rating cells", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "array", "items": { "type": "array", "items": { "anyOf": [ { "type": "string", "description": "A union variant." }, { "type": "number", "description": "A union variant." }, { "type": "boolean", "description": "A union variant." }, { "const": null, "description": "A union variant." } ], "description": "The cell value schema." }, "description": "An array item." }, "description": "The data values in the range." }, "nullable": false, "handle": "values" }, { "jsonSchema": { "type": "array", "items": { "type": "object", "additionalProperties": true } }, "nullable": false, "handle": "results" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "sheetName" } ], "outputs": [ { "jsonSchema": { "type": "array", "items": { "type": "object", "properties": { "range": { "type": "string", "minLength": 1, "description": "The A1 notation of the range to write to." }, "values": { "type": "array", "items": { "type": "array", "items": { "anyOf": [ { "type": "string", "description": "A union variant." }, { "type": "number", "description": "A union variant." }, { "type": "boolean", "description": "A union variant." }, { "const": null, "description": "A union variant." } ], "description": "The cell value schema." }, "description": "An array item." }, "description": "The data to write into the range." }, "majorDimension": { "type": "string", "enum": [ "ROWS", "COLUMNS" ], "description": "The major dimension of the values array." } }, "required": [ "range", "values" ], "additionalProperties": false, "description": "A batch values update item." }, "description": "The list of value ranges to update." }, "nullable": false, "handle": "data" }, { "jsonSchema": { "type": "boolean" }, "nullable": false, "handle": "hasUpdates" }, { "jsonSchema": { "type": "integer" }, "nullable": false, "handle": "expectedCells" }, { "jsonSchema": { "type": "integer" }, "nullable": false, "handle": "matched" }, { "jsonSchema": { "type": "array", "items": { "type": "integer" } }, "nullable": false, "handle": "unmatched" }, { "jsonSchema": { "type": "array", "items": { "type": "object", "additionalProperties": true } }, "nullable": false, "handle": "results" } ], "name": "Plan only Rating cells", "moduleId": "n_9cc104630ba2f561", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_a0a36bcefd450b16": { "inputs": {}, "name": "Any matching Rating cells", "kind": "condition", "matchMode": "first", "cases": [ { "output": "updates", "groups": [ { "expressions": [ { "left": { "kind": "source", "source": { "kind": "node", "nodeId": "n_3c5db2cb41b37024", "output": "hasUpdates" } }, "operator": "==", "right": { "kind": "value", "value": true } } ] } ] } ] }, "n_bdffe25fb01eaf1f": { "inputs": { "data": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_3c5db2cb41b37024", "output": "data" } ] } }, "name": "Validate selected Rating writes", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "array", "items": { "type": "object", "properties": { "range": { "type": "string", "minLength": 1, "description": "The A1 notation of the range to write to." }, "values": { "type": "array", "items": { "type": "array", "items": { "anyOf": [ { "type": "string", "description": "A union variant." }, { "type": "number", "description": "A union variant." }, { "type": "boolean", "description": "A union variant." }, { "const": null, "description": "A union variant." } ], "description": "The cell value schema." }, "description": "An array item." }, "description": "The data to write into the range." }, "majorDimension": { "type": "string", "enum": [ "ROWS", "COLUMNS" ], "description": "The major dimension of the values array." } }, "required": [ "range", "values" ], "additionalProperties": false, "description": "A batch values update item." }, "description": "The list of value ranges to update." }, "nullable": false, "handle": "data" } ], "outputs": [ { "jsonSchema": { "type": "array", "items": { "type": "object", "properties": { "range": { "type": "string", "minLength": 1, "description": "The A1 notation of the range to write to." }, "values": { "type": "array", "items": { "type": "array", "items": { "anyOf": [ { "type": "string", "description": "A union variant." }, { "type": "number", "description": "A union variant." }, { "type": "boolean", "description": "A union variant." }, { "const": null, "description": "A union variant." } ], "description": "The cell value schema." }, "description": "An array item." }, "description": "The data to write into the range." }, "majorDimension": { "type": "string", "enum": [ "ROWS", "COLUMNS" ], "description": "The major dimension of the values array." } }, "required": [ "range", "values" ], "additionalProperties": false, "description": "A batch values update item." }, "minItems": 1, "description": "The list of value ranges to update." }, "nullable": false, "handle": "data" } ], "name": "Validate selected Rating writes", "moduleId": "n_5de9365346e71b41", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_c618a6924c8f2e55": { "inputs": { "spreadsheetId": { "kind": "value", "value": "YOUR_GOOGLE_SHEET_ID" }, "valueInputOption": { "kind": "value", "value": "USER_ENTERED" }, "data": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_bdffe25fb01eaf1f", "output": "data" } ] }, "includeValuesInResponse": { "kind": "value", "value": false } }, "name": "Update matching Rating cells", "kind": "task", "task": { "inputs": [ { "description": "The spreadsheet ID.", "jsonSchema": { "type": "string", "minLength": 1, "description": "The spreadsheet ID." }, "nullable": true, "handle": "spreadsheetId", "value": null }, { "description": "The list of value ranges to update.", "jsonSchema": { "type": "array", "items": { "type": "object", "properties": { "range": { "type": "string", "minLength": 1, "description": "The A1 notation of the range to write to." }, "values": { "type": "array", "items": { "type": "array", "items": { "anyOf": [ { "type": "string", "description": "A union variant." }, { "type": "number", "description": "A union variant." }, { "type": "boolean", "description": "A union variant." }, { "const": null, "description": "A union variant." } ], "description": "The cell value schema." }, "description": "An array item." }, "description": "The data to write into the range." }, "majorDimension": { "type": "string", "enum": [ "ROWS", "COLUMNS" ], "description": "The major dimension of the values array." } }, "required": [ "range", "values" ], "additionalProperties": false, "description": "A batch values update item." }, "minItems": 1, "description": "The list of value ranges to update." }, "nullable": false, "handle": "data" }, { "description": "How the input data should be interpreted.", "jsonSchema": { "type": "string", "enum": [ "INPUT_VALUE_OPTION_UNSPECIFIED", "RAW", "USER_ENTERED" ], "description": "How the input data should be interpreted." }, "nullable": true, "handle": "valueInputOption", "value": null }, { "description": "Whether to include the written values in the response.", "jsonSchema": { "type": "boolean", "description": "Whether to include the written values in the response." }, "nullable": true, "handle": "includeValuesInResponse", "value": null }, { "description": "How values in the response should be rendered.", "jsonSchema": { "type": "string", "enum": [ "FORMATTED_VALUE", "UNFORMATTED_VALUE", "FORMULA" ], "description": "How values in the response should be rendered." }, "nullable": true, "handle": "responseValueRenderOption", "value": null }, { "description": "How dates in the response should be rendered.", "jsonSchema": { "type": "string", "enum": [ "SERIAL_NUMBER", "FORMATTED_STRING" ], "description": "How dates in the response should be rendered." }, "nullable": true, "handle": "responseDateTimeRenderOption", "value": null } ], "outputs": [ { "description": "The unique ID of the spreadsheet.", "jsonSchema": { "type": "string", "description": "The unique ID of the spreadsheet." }, "nullable": false, "handle": "spreadsheetId" }, { "description": "The total number of rows updated across all ranges.", "jsonSchema": { "type": "integer", "description": "The total number of rows updated across all ranges." }, "nullable": false, "handle": "totalUpdatedRows" }, { "description": "The total number of columns updated across all ranges.", "jsonSchema": { "type": "integer", "description": "The total number of columns updated across all ranges." }, "nullable": false, "handle": "totalUpdatedColumns" }, { "description": "The total number of cells updated across all ranges.", "jsonSchema": { "type": "integer", "description": "The total number of cells updated across all ranges." }, "nullable": false, "handle": "totalUpdatedCells" }, { "description": "The per-range update responses.", "jsonSchema": { "type": "array", "items": { "type": "object", "properties": { "updatedRange": { "type": "string", "description": "The A1 notation of the range that was updated." }, "updatedRows": { "type": "integer", "description": "The number of rows that were updated." }, "updatedColumns": { "type": "integer", "description": "The number of columns that were updated." }, "updatedCells": { "type": "integer", "description": "The number of cells that were updated." }, "updatedData": { "type": "object", "properties": { "range": { "type": "string", "description": "The A1 notation of the range." }, "majorDimension": { "type": "string", "description": "The major dimension of the values (ROWS or COLUMNS)." }, "values": { "type": "array", "items": { "type": "array", "items": { "anyOf": [ { "type": "string", "description": "A union variant." }, { "type": "number", "description": "A union variant." }, { "type": "boolean", "description": "A union variant." }, { "const": null, "description": "A union variant." } ], "description": "The cell value schema." }, "description": "An array item." }, "description": "The data values in the range." } }, "required": [ "range", "majorDimension", "values" ], "additionalProperties": false, "description": "The values of the cells after the update." } }, "required": [ "updatedRange", "updatedRows", "updatedColumns", "updatedCells" ], "additionalProperties": false, "description": "The batch update item schema." }, "description": "The per-range update responses." }, "nullable": false, "handle": "responses" } ], "name": "Update matching Rating cells", "executor": { "kind": "connector", "action": "googlesheets.update_values_batch" } } }, "n_4435e6e68bd4765d": { "inputs": { "results": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_3c5db2cb41b37024", "output": "results" } ] }, "matched": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_3c5db2cb41b37024", "output": "matched" } ] }, "unmatched": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_3c5db2cb41b37024", "output": "unmatched" } ] }, "expectedCells": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_3c5db2cb41b37024", "output": "expectedCells" } ] }, "actualCells": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_c618a6924c8f2e55", "output": "totalUpdatedCells" } ] } }, "name": "Confirm the rating update", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "array", "items": { "type": "object", "additionalProperties": true } }, "nullable": false, "handle": "results" }, { "jsonSchema": { "type": "integer" }, "nullable": false, "handle": "matched" }, { "jsonSchema": { "type": "array", "items": { "type": "integer" } }, "nullable": false, "handle": "unmatched" }, { "jsonSchema": { "type": "integer" }, "nullable": false, "handle": "expectedCells" }, { "jsonSchema": { "type": "integer", "description": "The total number of cells updated across all ranges." }, "nullable": true, "handle": "actualCells" } ], "outputs": [ { "jsonSchema": { "type": "integer" }, "nullable": false, "handle": "rated" }, { "jsonSchema": { "type": "integer" }, "nullable": false, "handle": "updated" }, { "jsonSchema": { "type": "array", "items": { "type": "integer" } }, "nullable": false, "handle": "unmatched" }, { "jsonSchema": { "type": "array", "items": { "type": "object", "additionalProperties": true } }, "nullable": false, "handle": "results" } ], "name": "Confirm the rating update", "moduleId": "n_754095b9eb4d0ae1", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_58ceb2ab6d3b9275": { "name": "Lead rating results", "kind": "outputs", "outputDefs": [ { "jsonSchema": { "type": "integer" }, "nullable": false, "handle": "rated" }, { "jsonSchema": { "type": "integer" }, "nullable": false, "handle": "updated" }, { "jsonSchema": { "type": "array", "items": { "type": "integer" } }, "nullable": false, "handle": "unmatched" }, { "jsonSchema": { "type": "array", "items": { "type": "object", "additionalProperties": true } }, "nullable": false, "handle": "results" } ], "outputMappings": { "rated": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_4435e6e68bd4765d", "output": "rated" } ] }, "updated": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_4435e6e68bd4765d", "output": "updated" } ] }, "unmatched": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_4435e6e68bd4765d", "output": "unmatched" } ] }, "results": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_4435e6e68bd4765d", "output": "results" } ] } } } }, "edges": [ { "source": "n_b59e907c7bd7bcb0", "target": "n_fc455638d21c724b" }, { "source": "n_fc455638d21c724b", "target": "n_499021df69963126" }, { "source": "n_499021df69963126", "target": "n_87dc9985342b22a4" }, { "source": "n_87dc9985342b22a4", "target": "n_8580dc99d4f0b142", "sourceHandle": "more" }, { "source": "n_8580dc99d4f0b142", "target": "n_499021df69963126" }, { "source": "n_87dc9985342b22a4", "target": "n_c38ed8b1da14e180", "sourceHandle": "otherwise" }, { "source": "n_c38ed8b1da14e180", "target": "n_3c5db2cb41b37024" }, { "source": "n_3c5db2cb41b37024", "target": "n_a0a36bcefd450b16" }, { "source": "n_a0a36bcefd450b16", "target": "n_4435e6e68bd4765d", "sourceHandle": "otherwise" }, { "source": "n_a0a36bcefd450b16", "target": "n_bdffe25fb01eaf1f", "sourceHandle": "updates" }, { "source": "n_bdffe25fb01eaf1f", "target": "n_c618a6924c8f2e55" }, { "source": "n_c618a6924c8f2e55", "target": "n_4435e6e68bd4765d" }, { "source": "n_4435e6e68bd4765d", "target": "n_58ceb2ab6d3b9275" } ] } }, "modules": { "n_0631046a69c8c49d": { "name": "Keep every new lead", "imports": [], "source": "export default function prepareLeadRatings({events}) {\n if(!Array.isArray(events))throw new Error('Expected all new-row events.');\n const keys=['Timestamp','Email Address','Your name','Your business area','Your team size'];\n const leads=events.map((event,index)=>{const row=event?.row;if(!row||typeof row!=='object'||Array.isArray(row))throw new Error('Each event needs its original row.');if(!row.Timestamp)throw new Error('A lead needs a nonempty Timestamp match key.');for(const key of keys)if(row[key]!=null&&typeof row[key]==='object')throw new Error('Lead cells must be scalar values.');return {index,row:{...row},timestamp:String(row.Timestamp),prompt:\"Here's a lead info:\\nName: \"+String(row['Your name']||'')+'\\nEmail: '+String(row['Email Address']||'')+'\\nBusiness area: '+String(row['Your business area']||'')+'\\nSize of the team: '+String(row['Your team size']||'')};});\n return {leads,count:leads.length};\n}\n" }, "n_20e22ae2d31e8787": { "name": "Collect all lead ratings", "imports": [], "source": "export default function collectLeadRatings({leads,previousState,response}) {\n if(!Array.isArray(leads))throw new Error('Expected all selected leads.');\n const state=previousState==null?{next:0,results:[]}:structuredClone(previousState);\n if(!Number.isInteger(state.next)||!Array.isArray(state.results)||state.results.length!==state.next||state.next>leads.length)throw new Error('Invalid lead rating progress.');\n if(state.awaiting===true){if(!response||typeof response!=='object'||!['qualified','not qualified'].includes(response.rating)||typeof response.explanation!=='string')throw new Error('The model must return a valid rating and explanation.');const lead=leads[state.next];state.results.push({index:lead.index,timestamp:lead.timestamp,row:lead.row,rating:response.rating,explanation:response.explanation});state.next++;state.awaiting=false;}\n if(state.next===leads.length)return {state,more:false,prompt:'',results:state.results,count:state.results.length};\n state.awaiting=true;return {state,more:true,prompt:leads[state.next].prompt,results:state.results,count:state.results.length};\n}\n" }, "n_9cc104630ba2f561": { "name": "Plan only Rating cells", "imports": [], "source": "export default function planLeadRatingWrites({values,results,sheetName}) {\n if(!Array.isArray(values)||!Array.isArray(results)||typeof sheetName!=='string'||!sheetName)throw new Error('Invalid lead rating write inputs.');const headers=values[0];if(!Array.isArray(headers))throw new Error('Missing sheet header.');const timestamp=headers.indexOf('Timestamp'),rating=headers.indexOf('Rating');if(timestamp<0||rating<0||headers.lastIndexOf('Timestamp')!==timestamp||headers.lastIndexOf('Rating')!==rating)throw new Error('Use exactly one Timestamp and one Rating header.');\n const rows=new Map();for(let i=1;i{let text='';for(n++;n;n=Math.floor((n-1)/26))text=String.fromCharCode(65+(n-1)%26)+text;return text;},data=[],unmatched=[];\n for(const result of results){if(!result||typeof result.timestamp!=='string'||!['qualified','not qualified'].includes(result.rating)||typeof result.explanation!=='string')throw new Error('Invalid completed rating.');const row=rows.get(result.timestamp);if(row==null){unmatched.push(result.index);continue;}data.push({range:sheet+'!'+column(rating)+row,values:[[result.rating]]});}\n return {data,hasUpdates:data.length>0,expectedCells:data.length,matched:data.length,unmatched,results};\n}\n" }, "n_5de9365346e71b41": { "name": "Validate selected Rating writes", "imports": [], "source": "export default function leadRatingRequest({data}) {if(!Array.isArray(data)||data.length===0)throw new Error('The selected write needs at least one Rating cell.');for(const entry of data){if(typeof entry.range!=='string'||!entry.range||!Array.isArray(entry.values)||entry.values.length!==1||!Array.isArray(entry.values[0])||entry.values[0].length!==1||!['qualified','not qualified'].includes(entry.values[0][0]))throw new Error('Invalid Rating cell request.');}return {data};}\n" }, "n_754095b9eb4d0ae1": { "name": "Confirm the rating update", "imports": [], "source": "export default function leadRatingReceipt({results,matched,unmatched,expectedCells,actualCells}) {\n if(!Array.isArray(results)||!Array.isArray(unmatched)||!Number.isInteger(matched)||!Number.isInteger(expectedCells))throw new Error('Invalid rating receipt.');if(expectedCells>0&&actualCells!==expectedCells)throw new Error('Rating update receipt does not match the requested cells.');return {rated:results.length,updated:matched,unmatched,results};\n}\n" } } }, "presentation": { "designer": { "version": 1, "flow": { "direction": "vertical" } } } }