Commit 5dc5264f authored by Ajit Deshmukh's avatar Ajit Deshmukh

Added the flow json body for Vision Assistant in WhatsApp through MSG91

parent 5d5093ab
{
"version": "1.0",
"export_timestamp": "2026-06-01T07:02:23.412301",
"flow": {
"flow_name": "Vision Assistant Invocation From Whatsapp",
"description": "Receives a message via WhatsApp, sends it to Vision Assistant, and returns the response to WhatsApp.",
"category": "",
"trigger_config": {
"type": "event",
"app_id": "2413fb63-ae6f-4da1-8b2e-f9e00ec280f3",
"event_name": "message_received",
"schedule": null,
"manual_variables": [],
"execute_immediately": null,
"folder_path": null,
"listener_type": null,
"file_pattern": null,
"recursive": null,
"debounce_seconds": null,
"system_prompt": null,
"placeholder_text": null,
"session_timeout_minutes": null,
"_seed_key": "msg91_whatsapp",
"_app_reference": "seed_key",
"app_name": "MSG91 WhatsApp"
},
"flow_definition": {
"nodes": [
{
"id": "whatsapp_webhook_trigger",
"type": "trigger",
"position": {
"x": 87.20990731097481,
"y": 106.75656859962783
},
"data": {
"label": "WhatsApp Webhook Trigger Event: Msg recieved",
"triggerType": "application_event",
"outputs": {
"sender_number": "{{sender_number}}",
"message_data_json_string": "{{text}}",
"message_text": "{{message_text}}"
},
"width": 242,
"height": 88,
"manualVariables": [],
"executeImmediately": null,
"appId": "2413fb63-ae6f-4da1-8b2e-f9e00ec280f3",
"eventId": "4073dceb-9564-4b66-9b29-01a722083b5b",
"eventName": "message_received",
"serviceId": "",
"parameterMapping": {},
"parametersRaw": "",
"appName": "MSG91 WhatsApp",
"appIcon": "https://www.msg91.com/img/logo.svg",
"appType": "api",
"appCategory": "Communication",
"eventDisplayName": "message_received",
"eventVariables": [],
"_seed_key": "msg91_whatsapp",
"_app_reference": "seed_key",
"_instance_number": 1,
"_instance_name": null
}
},
{
"id": "prepare_vision_assistant_contents",
"type": "transform",
"position": {
"x": 400,
"y": 100
},
"data": {
"label": "Prepare Vision Assitant Contents",
"script": "import json\nimport time\nimport urllib.parse\n\n# Extract the nested data properly\nmessage_body = \"\"\nuser_phone = \"\"\nmessage_id = \"\"\n\n# The data now resides under variables.intent_param.messages\nif isinstance(input, dict):\n # First, try top-level \"text\" field\n if \"text\" in input and isinstance(input[\"text\"], str):\n message_body = input[\"text\"]\n # Fallback to messages[0].text.body\n elif \"messages\" in input and isinstance(input[\"messages\"], list) and len(input[\"messages\"]) > 0:\n first_message = input[\"messages\"][0]\n if \"text\" in first_message and \"body\" in first_message[\"text\"]:\n message_body = first_message[\"text\"][\"body\"]\n\n# Construct the intent_param JSON for invokeIntent API\nintent_param = {\n \"BIS_INTENT_ID\": \"\",\n \"identity\": str(int(time.time() * 1000)),\n \"USER_MSG\": message_body,\n \"IS_BROWSER\": True,\n \"INPUT_TEXT\": message_body,\n \"USER_ID\": user_phone,\n \"UUID\": message_id\n}\n\n# Encode JSON for query parameter\nencoded_intent_param = urllib.parse.quote(json.dumps(intent_param), safe='')\n\n# Optional debug print for workflow logs\nprint(\"Raw intent_param:\", json.dumps(intent_param, indent=2))\nprint(\"Encoded intent_param:\", encoded_intent_param)\n\n# Output for the next node (API call)\noutput = {\n \"intent_param\": encoded_intent_param\n}\n",
"width": 206,
"height": 108
}
},
{
"id": "vision_generate_content",
"type": "action",
"position": {
"x": 702.806934405826,
"y": 96.84324324324322
},
"data": {
"label": "Vision Assistant",
"appId": "2d30db4a-1579-48b1-84ae-b1f5bccad06f",
"appName": "Vision ID Verification",
"serviceId": "1642e38f-d2ad-4d12-9694-a63b38ab92e6",
"service": "vision_assistant",
"parameterMapping": {
"intent_param": {
"source": "variable",
"value": "node_outputs.prepare_vision_assistant_contents.intent_param"
}
},
"width": 226,
"height": 88,
"serviceDisplayName": "Vision Assistant",
"serviceName": "Generate Content",
"parametersRaw": "",
"appIcon": "https://proteusvision.com/ibase/E12BROWSER/images/visionLogo1.png",
"appType": "api",
"appCategory": "Business",
"_app_reference": "custom",
"_service_name": "vision_assistant",
"_service_reference": "has_name"
}
},
{
"id": "parse_vision_assistant_response",
"type": "transform",
"position": {
"x": 998.4216216216216,
"y": 98.42162162162163
},
"data": {
"label": "Parse Assistant Response",
"script": "import json\n\nresponse_data = node_outputs.vision_generate_content # your API node\nmessage_text = \"\"\n\ntry:\n # ✅ Step 1: Extract text or data from both possible response types\n data_candidate = None\n\n # Case A: Normal API success structure\n if (\n isinstance(response_data, dict)\n and \"Response\" in response_data\n and \"results\" in response_data[\"Response\"]\n and \"Root\" in response_data[\"Response\"][\"results\"]\n ):\n root = response_data[\"Response\"][\"results\"][\"Root\"]\n\n if \"Detail\" in root and \"result\" in root[\"Detail\"]:\n result = root[\"Detail\"][\"result\"]\n data_candidate = result.get(\"data\")\n\n elif \"Errors\" in root and \"error\" in root[\"Errors\"]:\n error = root[\"Errors\"][\"error\"]\n data_candidate = error.get(\"description\", \"\") or error.get(\"message\", \"\")\n\n # Case B: Text response structure\n elif isinstance(response_data, dict) and \"text\" in response_data:\n data_candidate = response_data.get(\"text\")\n\n # ✅ Step 2: Handle both plain text and table-type responses\n if isinstance(data_candidate, str):\n message_text = data_candidate.strip()\n\n elif isinstance(data_candidate, list) and len(data_candidate) > 0:\n\n # Handle table-like data (cols + rows)\n table_obj = data_candidate[0] if isinstance(data_candidate[0], dict) else None\n if table_obj and \"cols\" in table_obj and \"rows\" in table_obj:\n\n cols = table_obj.get(\"cols\", [])\n rows = table_obj.get(\"rows\", [])\n\n if cols and rows:\n # Format each row as key-value pairs with bold column names\n formatted_rows = \"\\n\".join([\n f\"*{cols[i]}* : {r[i]}\"\n for i in range(len(cols))\n for r in rows\n ])\n message_text = formatted_rows\n else:\n message_text = \"No table data found.\"\n\n else:\n # If list but not a table, convert to plain string\n message_text = str(data_candidate)\n\n # Fallback\n if not message_text:\n message_text = \"No valid response found from Vision Assistant.\"\n\n # Ensure output is plain string\n message_text = str(message_text).strip()\n\nexcept Exception as e:\n message_text = f\"Error while processing response: {str(e)}\"\n\n# Final output\noutput = {\n \"_description\": message_text\n}\n\nset_global('vision_response', message_text)\n",
"width": 206,
"height": 108
}
},
{
"id": "whatsapp_send_response",
"type": "action",
"position": {
"x": 1300,
"y": 104.21040160873909
},
"data": {
"label": "WhatsApp: Send Text Message",
"appId": "2413fb63-ae6f-4da1-8b2e-f9e00ec280f3",
"appName": "MSG91 WhatsApp",
"serviceId": "f48b580e-2b5e-4bc2-9adc-96f55bbbef19",
"service": "send_text_message",
"parameterMapping": {
"recipient_number": {
"source": "variable",
"value": "{{input.recipient_number}}"
},
"to_number": {
"source": "variable",
"value": "{{input.sender_number}}"
},
"message_text": {
"source": "variable",
"value": "{{global.vision_response}}"
},
"integrated_number": {
"source": "variable",
"value": "{{input.recipient_number}}"
}
},
"width": 260,
"height": 88,
"serviceDisplayName": "send_text_message",
"serviceName": "send_text_message",
"parametersRaw": "",
"appIcon": "https://www.msg91.com/img/logo.svg",
"appType": "api",
"appCategory": "Communication",
"_seed_key": "msg91_whatsapp",
"_app_reference": "seed_key",
"_instance_number": 1,
"_instance_name": null,
"_service_name": "send_text_message",
"_service_reference": "has_name"
}
}
],
"edges": [
{
"id": "edge_prepare_gemini_to_gemini",
"source": "prepare_vision_assistant_contents",
"target": "vision_generate_content",
"sourceHandle": "right",
"targetHandle": "left",
"label": null
},
{
"id": "evision_generate_content-parse_vision_assistant_response-right-left",
"source": "vision_generate_content",
"target": "parse_vision_assistant_response",
"sourceHandle": "right",
"targetHandle": "left",
"label": null
},
{
"id": "eparse_vision_assistant_response-whatsapp_send_response-right-left",
"source": "parse_vision_assistant_response",
"target": "whatsapp_send_response",
"sourceHandle": "right",
"targetHandle": "left",
"label": null
},
{
"id": "ewhatsapp_webhook_trigger-prepare_vision_assistant_contents-bottom-top",
"source": "whatsapp_webhook_trigger",
"target": "prepare_vision_assistant_contents",
"sourceHandle": "bottom",
"targetHandle": "top",
"label": null
}
]
},
"is_synchronous": false,
"sync_timeout": 30
},
"metadata": {
"required_applications": [
"msg91_whatsapp"
],
"source_instance": {
"tenant_id": "274b8f90-25b3-4d01-aab5-a77715d38e6b",
"user_email": "ajit.deshmukh@proteustech.in"
},
"warnings": [
{
"type": "missing_seed_keys",
"message": "Some applications do not have seed keys and may need manual mapping after import",
"applications": [
{
"app_id": "2d30db4a-1579-48b1-84ae-b1f5bccad06f",
"app_name": "Vision ID Verification",
"node_id": "vision_generate_content",
"node_label": "Vision Assistant"
}
]
}
]
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment