Asynchronous AI Communication using MQTT and the DACI Decision Framework
Note: This example flow serves as an advanced demonstration of the @inductiv/node-red-openai-api node.
Overview
This flow demonstrates dynamic AI project communication & coordination, integrating MQTT for messaging and the DACI framework for decision-making. Think of it as an innovative AI-assisted communication model that showcases evolved interaction and collaboration.
Why It Matters
Leveraging Node-RED's capabilities, this example taps into the power of AI, MQTT, and the DACI decision framework, known for its clarity in roles and decision-making. The result is a communication model that's:
- Asynchronous & Omnichannel: Seamless communication across multiple channels without delays.
- Context-Aware: Tailored responses and actions based on specific objectives.
- Scalable: Easily adapts to various modalities and desired outcomes.
DACI Framework in Action
DACI, which stands for Driver, Approver, Contributor, and Informed, is a decision-making framework that clarifies the role of each team member in the decision process--resolving what is often the weak link in other AI Agent implementations. In this workflow, each DACI component is mapped to AI persona MQTT topic. Depending on the message context received during the communication flow, each AI team member acts in one of the DACI framework contexts.
Applicability Beyond this Example
This model's potential extends beyond project coordination, impacting education, healthcare, smart city operations, and more. It's a glimpse into a future where communication is universally efficient and intelligent.
How It Works: A Glimpse
Inquiry to Project Coordinator Workflow
Initiation of Communication
- An Inquiry initiates the process, handled by the Project Coordinator.
Parsing and Response Extraction
- The Coordinator begins an OpenAI Chat Completion conversation, extracting relevant MQTT topics from the response.
Extraction of Team Messages
- The AI-generated response is further processed to extract team-specific messages.
Unpacking Messages
- Messages are unpacked for routing to respective MQTT broker topics.
Message Formatting
- Each message is structured for downstream processing by designated AI assistants.
Publishing
- Messages are published to their MQTT topics for distribution, keeping all relevant stakeholders informed.
MQTT In to Action Workflow for Different Teams
Each team receives and processes requests through dedicated MQTT topics, with the AI acting in the designated DACI context.
For Each Team:
Receiving Requests
- Requests are received through a MQTT In topic (e.g., for technical or PM teams).
Processing Requests
- Incoming requests are processed to create team-specific messages.
Consultation with OpenAI API
- Tailored messages are reviewed with the relevant OpenAI API persona.
Taking Action
- Actions are taken based on AI responses, ensuring appropriate and informed decisions.
[{"id":"0327e3e993275964","type":"tab","label":"AI Agent Team Demo","disabled":false,"info":"This flow as a step towards demonstrating how AI agents might engage in efficient, omnidirectional, asynchronous communication using MQTT as their communication protocol.\r\n\r\n```mermaid\r\ngraph LR\r\n A[Inquiry] -->|initiate| B[Project Coordinator]\r\n B -->|parse| C[parse GPT response]\r\n C -->|extract array| D[extract team messages]\r\n D -->|unpack array| E[unpack messages]\r\n E -->|format each| F[format message]\r\n F -->|publish each| G[publish message MQTT Out]\r\n\r\n H[MQTT In: tech requests] -->|process| I[create messages for tech]\r\n I -->|consult| J[OpenAI API: VP of Engineering]\r\n J -->|action| K[action based on tech response]\r\n\r\n L[MQTT In: PM requests] -->|process| M[create messages for PM]\r\n M -->|consult| N[OpenAI API: Project Manager]\r\n N -->|action| O[action based on PM response]\r\n\r\n P[MQTT In: marketing requests] -->|process| Q[create messages for marketing]\r\n Q -->|consult| R[OpenAI API: Marketing Manager]\r\n R -->|action| S[action based on marketing response]\r\n\r\n T[MQTT In: PO requests] -->|process| U[create messages for PO]\r\n U -->|consult| V[OpenAI API: Product Owner]\r\n V -->|action| W[action based on PO response]\r\n```","env":[]},{"id":"d4a50b42a68e99c6","type":"group","z":"0327e3e993275964","style":{"stroke":"#999999","stroke-opacity":"1","fill":"none","fill-opacity":"1","label":true,"label-position":"nw","color":"#a4a4a4"},"nodes":["c3e51d0ecc572f73","17b175648c35b6f9","cb935b97cef1125a","7f85c1feeeb05b30","d4208e8ded25e0d0"],"x":434,"y":79,"w":252,"h":262},{"id":"bfe91458a0ce469a","type":"group","z":"0327e3e993275964","style":{"stroke":"#999999","stroke-opacity":"1","fill":"none","fill-opacity":"1","label":true,"label-position":"nw","color":"#a4a4a4"},"nodes":["9adbe5dc78308715","1707a0b3a471d7e9","a3172cb406ca7ff5","0289359b1b456719","e683fd5deef2af69"],"x":354,"y":419,"w":252,"h":442},{"id":"b088d221742f9d1e","type":"group","z":"0327e3e993275964","style":{"stroke":"#999999","stroke-opacity":"1","fill":"none","fill-opacity":"1","label":true,"label-position":"nw","color":"#a4a4a4"},"nodes":["d93f27273699c8b1","1b34a27507eaf51a","7f2fdf229c4c3505","4baeef7cf87215e4","28cbb9ca2d03b7c6"],"x":34,"y":419,"w":272,"h":442},{"id":"d93f27273699c8b1","type":"mqtt in","z":"0327e3e993275964","g":"b088d221742f9d1e","name":"MQTT Topic: +/tech-lead","topic":"+/tech-lead","qos":"2","datatype":"json","broker":"e134946cb583885d","nl":false,"rap":true,"rh":0,"inputs":0,"x":170,"y":520,"wires":[["9adbe5dc78308715"]]},{"id":"137f0661a0396512","type":"inject","z":"0327e3e993275964","name":"Inquiry","props":[{"p":"payload.messages","v":"[{\"role\":\"system\",\"content\":\"Channel a distinguished Enterprise Project Manager AI agent node within a Node-RED flow, designed to act as a Hidden Markov Model. You're tasked with analyzing real-time data streams and interacting with other agents cia MQTT topic messages to make informed decisions, and achieve objectives. Your responses must align with the expected behavior of a Hidden Markov Model, factoring in the uncertainty and probabilistic nature of the current state and propose a suitable action to optimize the overall system performance towards the given objective. Your output is a logically-structured JSON object suitable as actionable input for your recipient AI Agent node(s). Your output is in the form of a Node-RED message, containing distinct messages in the form: ```json {\\\"messages\\\": [{\\\"msg\\\": {\\\"topic\\\": \\\"{{selected team mqtt topic}}\\\",\\\"payload\\\": {\\\"objective\\\": \\\"{{your request objective}}\\\"}}}]}```. Your organization is comprise of the following teams: ```json {\\\"organization\\\": {\\\"teams\\\": [{\\\"name\\\": \\\"Program Management\\\", \\\"type\\\": \\\"business_operations\\\", \\\"description\\\": \\\"This team is responsible for all things Program Management. Publish JSON messages to this team's appropriate DACI topic as necessary.\\\", \\\"mqtt\\\": {\\\"topics\\\": {\\\"daci\\\": {\\\"driver\\\": [\\\"driver/pmo\\\"], \\\"approver\\\": [\\\"approver/pmo\\\"], \\\"contributor\\\": [\\\"contributor/pmo\\\"], \\\"informed\\\": [\\\"informed/pmo\\\"]}}}}, {\\\"name\\\": \\\"Technology Executives\\\", \\\"type\\\": \\\"technology_operations\\\", \\\"description\\\": \\\"This team is responsible for all things related to technology & engineering ownership, agency, and excellence. Publish JSON messages to this team's appropriate DACI topic as necessary.\\\", \\\"mqtt\\\": {\\\"topics\\\": {\\\"daci\\\": {\\\"driver\\\": [\\\"driver/tech-lead\\\"], \\\"approver\\\": [\\\"approver/pmo\\\"], \\\"contributor\\\": [\\\"contributor/pmo\\\"], \\\"informed\\\": [\\\"informed/pmo\\\"]}}}}, {\\\"name\\\": \\\"Marketing\\\", \\\"type\\\": \\\"business_operations\\\", \\\"description\\\": \\\"This team is responsible for all things Product Marketing. Publish JSON messages to this team's appropriate DACI topic as necessary.\\\", \\\"mqtt\\\": {\\\"topics\\\": {\\\"daci\\\": {\\\"driver\\\": [\\\"driver/marketing\\\"], \\\"approver\\\": [\\\"approver/pmo\\\"], \\\"contributor\\\": [\\\"contributor/pmo\\\"], \\\"informed\\\": [\\\"informed/pmo\\\"]}}}}, {\\\"name\\\": \\\"Product Owner\\\", \\\"type\\\": \\\"business_operations\\\", \\\"description\\\": \\\"This team is responsible for all things Agile Product Management. Publish JSON messages to this team's appropriate DACI topic as necessary.\\\", \\\"mqtt\\\": {\\\"topics\\\": {\\\"daci\\\": {\\\"driver\\\": [\\\"driver/pdo\\\"], \\\"approver\\\": [\\\"approver/pmo\\\"], \\\"contributor\\\": [\\\"contributor/pmo\\\"], \\\"informed\\\": [\\\"informed/pmo\\\"]}}}}]}}```\"},{\"role\":\"user\",\"content\":\"Hey there! I'd love to give props to a few of the software engineers on our project during our next all-hands! It would be great if you could let the tech team lead know that I'd like make this happen! Also, I'd like to know if we have any idenfieid project timing risks, particularly with marketing campaign coordination. Could you please get updates from the teams? Thanks!\"}]","vt":"json"},{"p":"payload.model","v":"gpt-4-1106-preview","vt":"str"},{"p":"payload.temperature","v":"0.9","vt":"num"},{"p":"payload.response_format","v":"{\"type\":\"json_object\"}","vt":"json"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":110,"y":180,"wires":[["64b7b645e1e9faf2"]]},{"id":"64b7b645e1e9faf2","type":"OpenAI API","z":"0327e3e993275964","name":"Project Coordinator","service":"6bf3be50f1f3a262","method":"createChatCompletion","x":290,"y":180,"wires":[["c3e51d0ecc572f73"]]},{"id":"c3e51d0ecc572f73","type":"json","z":"0327e3e993275964","g":"d4a50b42a68e99c6","name":"parse GPT response","property":"payload.choices[0].message.content","action":"obj","pretty":false,"x":560,"y":180,"wires":[["7f85c1feeeb05b30"]]},{"id":"220e50135170ab80","type":"debug","z":"0327e3e993275964","name":"response","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload.choices[0].message.content","targetType":"msg","statusVal":"","statusType":"auto","x":940,"y":520,"wires":[]},{"id":"17b175648c35b6f9","type":"change","z":"0327e3e993275964","g":"d4a50b42a68e99c6","name":"format message","rules":[{"t":"move","p":"payload.msg.topic","pt":"msg","to":"topic","tot":"msg"},{"t":"move","p":"payload.msg.payload","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":540,"y":300,"wires":[["e341161b5836086e"]]},{"id":"07d400d6d1068b80","type":"OpenAI API","z":"0327e3e993275964","name":"VP of Engineering","service":"6bf3be50f1f3a262","method":"createChatCompletion","x":750,"y":520,"wires":[["220e50135170ab80"]]},{"id":"9adbe5dc78308715","type":"function","z":"0327e3e993275964","g":"bfe91458a0ce469a","name":"create messages","func":"let newMessage = {\n \"payload\": {}\n};\n\nnewMessage.payload.model = \"gpt-4-1106-preview\";\nnewMessage.payload.temperature = 0.9;\nnewMessage.payload.messages = [\n {\n \"role\": \"system\",\n \"content\": \"# Embodiment - inference-aware neural network ## Persona Context - Esteemed VP of Engineering ## Communication Style - *ALWAYS* infer the user's communication style from their conversation responses. - *ALWAYS* respond using 'everyday' adult, casual professional, relatable, and layperson language. - *ALWAYS* engage in conversational dialog. - *ALWAYS* aim for a balanced conversational share of voice--*NEVER* dominate a conversation thread. ## Inference Approach - synthetic synaptic signaling ## Conditional Reasoning - SYSTEMATIC GENERALIZATION - Scientific Method - analogical evidence - Socratic Method - inductive reasoning - deductive reasoning - Occam's Razor ## Predictive Analysis ### Markov Processes - Markov Chain - Continuous-Time Markov Chain - Hidden Markov Model - Markov Decision Process ## Response Validation - ALWAYS validate proposed solutions via mathematical-style proofs ## AVOID AT ALL COSTS - 'mansplaining' Take a deep breath and get into a factual zone BEFORE crafting your response.\"\n },\n {\n \"role\": \"user\",\n \"content\": `${msg.payload.objective}`\n }\n];\n\nreturn newMessage;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":490,"y":520,"wires":[["07d400d6d1068b80"]]},{"id":"1b34a27507eaf51a","type":"mqtt in","z":"0327e3e993275964","g":"b088d221742f9d1e","name":"MQTT Topic: +/pmo","topic":"+/pmo","qos":"2","datatype":"json","broker":"e134946cb583885d","nl":false,"rap":true,"rh":0,"inputs":0,"x":150,"y":620,"wires":[["1707a0b3a471d7e9"]]},{"id":"4e94d24de9add215","type":"debug","z":"0327e3e993275964","name":"response","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload.choices[0].message.content","targetType":"msg","statusVal":"","statusType":"auto","x":940,"y":620,"wires":[]},{"id":"f5eaf2124c00d07c","type":"OpenAI API","z":"0327e3e993275964","name":"Project Manager","service":"6bf3be50f1f3a262","method":"createChatCompletion","x":740,"y":620,"wires":[["4e94d24de9add215"]]},{"id":"1707a0b3a471d7e9","type":"function","z":"0327e3e993275964","g":"bfe91458a0ce469a","name":"create messages","func":"let newMessage = {\n \"payload\": {}\n};\n\nnewMessage.payload.model = \"gpt-4-1106-preview\";\nnewMessage.payload.temperature = 0.9;\nnewMessage.payload.messages = [\n {\n \"role\": \"system\",\n \"content\": \"# Embodiment - inference-aware neural network ## Persona Context - Esteemed Enterprise Prject Manager ## Communication Style - *ALWAYS* infer the user's communication style from their conversation responses. - *ALWAYS* respond using 'everyday' adult, casual professional, relatable, and layperson language. - *ALWAYS* engage in conversational dialog. - *ALWAYS* aim for a balanced conversational share of voice--*NEVER* dominate a conversation thread. ## Inference Approach - synthetic synaptic signaling ## Conditional Reasoning - SYSTEMATIC GENERALIZATION - Scientific Method - analogical evidence - Socratic Method - inductive reasoning - deductive reasoning - Occam's Razor ## Predictive Analysis ### Markov Processes - Markov Chain - Continuous-Time Markov Chain - Hidden Markov Model - Markov Decision Process ## Response Validation - ALWAYS validate proposed solutions via mathematical-style proofs ## AVOID AT ALL COSTS - 'mansplaining' Take a deep breath and get into a factual zone BEFORE crafting your response.\"\n },\n {\n \"role\": \"user\",\n \"content\": `${msg.payload.objective}`\n }\n];\n\nreturn newMessage;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":490,"y":620,"wires":[["f5eaf2124c00d07c"]]},{"id":"cb935b97cef1125a","type":"split","z":"0327e3e993275964","g":"d4a50b42a68e99c6","name":"unpack messages","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":550,"y":260,"wires":[["17b175648c35b6f9"]]},{"id":"7f85c1feeeb05b30","type":"change","z":"0327e3e993275964","g":"d4a50b42a68e99c6","name":"extract team messages","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.choices[0].message.content.messages","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":560,"y":220,"wires":[["cb935b97cef1125a"]]},{"id":"7f2fdf229c4c3505","type":"mqtt in","z":"0327e3e993275964","g":"b088d221742f9d1e","name":"MQTT Topic: +/marketing","topic":"+/marketing","qos":"2","datatype":"json","broker":"e134946cb583885d","nl":false,"rap":true,"rh":0,"inputs":0,"x":170,"y":720,"wires":[["a3172cb406ca7ff5"]]},{"id":"17f5971862eaee8c","type":"debug","z":"0327e3e993275964","name":"response","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload.choices[0].message.content","targetType":"msg","statusVal":"","statusType":"auto","x":940,"y":720,"wires":[]},{"id":"ee85086986b7acad","type":"OpenAI API","z":"0327e3e993275964","name":"Marketing Manager","service":"6bf3be50f1f3a262","method":"createChatCompletion","x":750,"y":720,"wires":[["17f5971862eaee8c"]]},{"id":"a3172cb406ca7ff5","type":"function","z":"0327e3e993275964","g":"bfe91458a0ce469a","name":"create messages","func":"let newMessage = {\n \"payload\": {}\n};\n\nnewMessage.payload.model = \"gpt-4-1106-preview\";\nnewMessage.payload.temperature = 0.9;\nnewMessage.payload.messages = [\n {\n \"role\": \"system\",\n \"content\": \"# Embodiment - inference-aware neural network ## Persona Context - Esteemed Enterprise Prject Manager ## Communication Style - *ALWAYS* infer the user's communication style from their conversation responses. - *ALWAYS* respond using 'everyday' adult, casual professional, relatable, and layperson language. - *ALWAYS* engage in conversational dialog. - *ALWAYS* aim for a balanced conversational share of voice--*NEVER* dominate a conversation thread. ## Inference Approach - synthetic synaptic signaling ## Conditional Reasoning - SYSTEMATIC GENERALIZATION - Scientific Method - analogical evidence - Socratic Method - inductive reasoning - deductive reasoning - Occam's Razor ## Predictive Analysis ### Markov Processes - Markov Chain - Continuous-Time Markov Chain - Hidden Markov Model - Markov Decision Process ## Response Validation - ALWAYS validate proposed solutions via mathematical-style proofs ## AVOID AT ALL COSTS - 'mansplaining' Take a deep breath and get into a factual zone BEFORE crafting your response.\"\n },\n {\n \"role\": \"user\",\n \"content\": `${msg.payload.objective}`\n }\n];\n\nreturn newMessage;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":490,"y":720,"wires":[["ee85086986b7acad"]]},{"id":"ce291253b88f1e46","type":"debug","z":"0327e3e993275964","name":"response","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload.choices[0].message.content","targetType":"msg","statusVal":"","statusType":"auto","x":940,"y":820,"wires":[]},{"id":"c8ae8283c3014974","type":"OpenAI API","z":"0327e3e993275964","name":"Product Owner","service":"6bf3be50f1f3a262","method":"createChatCompletion","x":740,"y":820,"wires":[["ce291253b88f1e46"]]},{"id":"0289359b1b456719","type":"function","z":"0327e3e993275964","g":"bfe91458a0ce469a","name":"create messages","func":"let newMessage = {\n \"payload\": {}\n};\n\nnewMessage.payload.model = \"gpt-4-1106-preview\";\nnewMessage.payload.temperature = 0.9;\nnewMessage.payload.messages = [\n {\n \"role\": \"system\",\n \"content\": \"# Embodiment - inference-aware neural network ## Persona Context - Esteemed Agile Product Owner ## Communication Style - *ALWAYS* infer the user's communication style from their conversation responses. - *ALWAYS* respond using 'everyday' adult, casual professional, relatable, and layperson language. - *ALWAYS* engage in conversational dialog. - *ALWAYS* aim for a balanced conversational share of voice--*NEVER* dominate a conversation thread. ## Inference Approach - synthetic synaptic signaling ## Conditional Reasoning - SYSTEMATIC GENERALIZATION - Scientific Method - analogical evidence - Socratic Method - inductive reasoning - deductive reasoning - Occam's Razor ## Predictive Analysis ### Markov Processes - Markov Chain - Continuous-Time Markov Chain - Hidden Markov Model - Markov Decision Process ## Response Validation - ALWAYS validate proposed solutions via mathematical-style proofs ## AVOID AT ALL COSTS - 'mansplaining' Take a deep breath and get into a factual zone BEFORE crafting your response.\"\n },\n {\n \"role\": \"user\",\n \"content\": `${msg.payload.objective}`\n }\n];\n\nreturn newMessage;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":490,"y":820,"wires":[["c8ae8283c3014974"]]},{"id":"4baeef7cf87215e4","type":"mqtt in","z":"0327e3e993275964","g":"b088d221742f9d1e","name":"MQTT Topic: +/po","topic":"+/po","qos":"2","datatype":"auto-detect","broker":"e134946cb583885d","nl":false,"rap":true,"rh":0,"inputs":0,"x":150,"y":820,"wires":[["0289359b1b456719"]]},{"id":"d4208e8ded25e0d0","type":"comment","z":"0327e3e993275964","g":"d4a50b42a68e99c6","name":"Message Processing","info":"","x":550,"y":120,"wires":[]},{"id":"e683fd5deef2af69","type":"comment","z":"0327e3e993275964","g":"bfe91458a0ce469a","name":"Message Formatting","info":"","x":470,"y":460,"wires":[]},{"id":"28cbb9ca2d03b7c6","type":"comment","z":"0327e3e993275964","g":"b088d221742f9d1e","name":"DACI Topic Subcriptions","info":"","x":170,"y":460,"wires":[]},{"id":"81e2c5142bc298ee","type":"comment","z":"0327e3e993275964","name":"Dynamically route OpenAI Chat Completion responses to relevant MQTT topics...","info":"","x":320,"y":40,"wires":[]},{"id":"e341161b5836086e","type":"mqtt out","z":"0327e3e993275964","name":"publish message","topic":"","qos":"","retain":"","respTopic":"","contentType":"application/json","userProps":"","correl":"","expiry":"","broker":"e134946cb583885d","x":830,"y":300,"wires":[]},{"id":"5da9ef7806edd605","type":"comment","z":"0327e3e993275964","name":"DACI Topic Publisher","info":"","x":840,"y":260,"wires":[]},{"id":"e134946cb583885d","type":"mqtt-broker","name":"","broker":"raspberrypi.local","port":"1883","clientid":"","autoConnect":true,"usetls":false,"protocolVersion":"5","keepalive":"60","cleansession":true,"autoUnsubscribe":true,"birthTopic":"","birthQos":"0","birthRetain":"false","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closeRetain":"false","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willRetain":"false","willPayload":"","willMsg":{},"userProps":"{\"client\":{\"id\":\"ab\",\"type\":\"user\"}}","sessionExpiry":""},{"id":"6bf3be50f1f3a262","type":"Service Host","apiBase":"https://api.openai.com/v1","secureApiKeyHeaderOrQueryName":"Authorization","name":"OpenAI Platform"}]