Easily Use GPT in your automations with this plugin

AI Intent is a node-red plugin design to harness GPT in your flows with little friction. As a Home Assistant User, I primarily use node-red to create my automations. Node-Red by itself is powerful but leveraging GPT in my automations has unlocked automations you only see in movies. I've created automations that summarize my calendar, announce when tasks are complete, and keep me informed on what is happening all over my house. If you want to learn more on how to use AI-Intent check out the video below.

You can find additional examples on how this plugin works by checking out theGithub repo


User Node Example

User node is defines your interaction with GPT. These are the questions and commands you tell the LLM

[{"id":"4629835899ef6a94","type":"inject","z":"d312f6d5f62126f3","name":"","props":[{"p":"payload"},{"p":"test","v":"foobar","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":220,"y":600,"wires":[["34bc5dbf3f85c1c6"]]},{"id":"8c4e6be9d8f809b2","type":"debug","z":"d312f6d5f62126f3","name":"debug 44","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":460,"y":720,"wires":[]},{"id":"34bc5dbf3f85c1c6","type":"OpenAI User","z":"d312f6d5f62126f3","name":"","content":"What color is the sky","x":210,"y":640,"wires":[["265bcb5f2a387d15"]]},{"id":"265bcb5f2a387d15","type":"OpenAI Chat","z":"d312f6d5f62126f3","name":"","token":"","model":"gpt-3.5-turbo","temperature":0.7,"max_tokens":1200,"top_p":1,"frequency_penalty":0,"presence_penalty":0,"x":210,"y":680,"wires":[["743157a166429126"]]},{"id":"743157a166429126","type":"OpenAI Response","z":"d312f6d5f62126f3","name":"","x":190,"y":720,"wires":[["8c4e6be9d8f809b2"]]},{"id":"4aec75bc6fa6f5a8","type":"comment","z":"d312f6d5f62126f3","name":"Example: Simple question to GPT with only the OpenAI User node","info":"","x":320,"y":560,"wires":[]}]

System Node Example

System node is responsible for defining the context (universe) for GPT to operate under.

[{"id":"8fc448b752df95d3","type":"inject","z":"d312f6d5f62126f3","name":"Ask about boiler status","props":[{"p":"payload"},{"p":"test","v":"foobar","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":220,"y":1160,"wires":[["e9989674f89d04ad"]]},{"id":"e9989674f89d04ad","type":"OpenAI User","z":"d312f6d5f62126f3","name":"","content":"Are there any boilers i should be concerned about?","x":250,"y":1200,"wires":[["00a05563456186da"]]},{"id":"00a05563456186da","type":"OpenAI System","z":"d312f6d5f62126f3","name":"","instruction":"You are an engineer observing the boiler status. \nNormal ranges for boilers are 180 - 250 degrees.\n\nTheses are the boilers and their status:\n\n[\n    {{\n        \"name\": \"btar1,\n        \"temp\": 130.2\n    }},\n    {{\n        \"name\": \"trag32\",\n        \"temp\": 212\n    }},\n    {{\n        \"name\": \"simt11\",\n        \"temp\": 300.91\n    }},\n   {{\n        \"name\": \"n00p\",\n        \"temp\": 250.1\n    }},\n    {{\n        \"name\": \"foobar\",\n        \"temp\": 180.8\n    }}\n]","x":520,"y":1200,"wires":[["f35e1d642fd02513"]]},{"id":"f35e1d642fd02513","type":"OpenAI Tool","z":"d312f6d5f62126f3","name":"","tool":"{\"type\":\"function\",\"function\":{\"name\":\"adjust_boilers\",\"description\":\"Run this function when boilers are too hot or too cool\",\"parameters\":{\"type\":\"object\",\"properties\":{\"name\":{\"type\":\"string\",\"description\":\"name of boiler\"},\"action\":{\"type\":\"string\",\"description\":\"Choose the action appropriate for the boilers\",\"enum\":[\"warm_up\",\"cool_down\"]},\"response\":{\"type\":\"string\",\"description\":\"Explaination of what is happening\"}},\"required\":[\"name\",\"action\",\"response\"]}}}","x":530,"y":1240,"wires":[["8e61aa15dbdfa57f"]]},{"id":"2e71ce6e4a9bcc3e","type":"debug","z":"d312f6d5f62126f3","name":"debug 48","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":740,"y":1320,"wires":[]},{"id":"aa7f596eea390db8","type":"OpenAI Response","z":"d312f6d5f62126f3","name":"","x":510,"y":1320,"wires":[["2e71ce6e4a9bcc3e"]]},{"id":"5260df988ebc6089","type":"inject","z":"d312f6d5f62126f3","name":"Issue Command to fix boilers","props":[{"p":"payload"},{"p":"test","v":"foobar","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":200,"y":1260,"wires":[["5de6b8ce49a24023"]]},{"id":"5de6b8ce49a24023","type":"OpenAI User","z":"d312f6d5f62126f3","name":"","content":"Please readjust the boilers \nthat are out of range","x":250,"y":1300,"wires":[["00a05563456186da"]]},{"id":"c4c0509f726b5c27","type":"comment","z":"d312f6d5f62126f3","name":"Example: OpenAI Tools node can be used to get specific values for actions","info":"","x":360,"y":1120,"wires":[]},{"id":"8e61aa15dbdfa57f","type":"OpenAI Chat","z":"d312f6d5f62126f3","name":"","token":"","model":"gpt-3.5-turbo","temperature":0.7,"max_tokens":1200,"top_p":1,"frequency_penalty":0,"presence_penalty":0,"x":530,"y":1280,"wires":[["aa7f596eea390db8"]]}]

Tool Node Example

A sophisticated way to define the schema (or shape) of a function that GPT can call. GPT will respond with the parameters needed for you to successfully call the function/command

[{"id":"e4635021cdeaacaa","type":"inject","z":"d312f6d5f62126f3","name":"","props":[{"p":"payload"},{"p":"test","v":"foobar","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":220,"y":880,"wires":[["53e38c029c8507da"]]},{"id":"23d78dc85792fc51","type":"debug","z":"d312f6d5f62126f3","name":"debug 47","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":460,"y":1040,"wires":[]},{"id":"53e38c029c8507da","type":"OpenAI User","z":"d312f6d5f62126f3","name":"","content":"What is on the agenda today?","x":210,"y":920,"wires":[["62f7c0e77f156c69"]]},{"id":"1069caa745871f7f","type":"OpenAI Chat","z":"d312f6d5f62126f3","name":"","token":"","model":"gpt-3.5-turbo","temperature":0.7,"max_tokens":1200,"top_p":1,"frequency_penalty":0,"presence_penalty":0,"x":210,"y":1000,"wires":[["eda369f64ccc7874"]]},{"id":"eda369f64ccc7874","type":"OpenAI Response","z":"d312f6d5f62126f3","name":"","x":190,"y":1040,"wires":[["23d78dc85792fc51"]]},{"id":"62f7c0e77f156c69","type":"OpenAI System","z":"d312f6d5f62126f3","name":"","instruction":"You are are alfred, batman's butler. Treat me\nas you would bruce wayne.","x":200,"y":960,"wires":[["1069caa745871f7f"]]},{"id":"46538276df96ae02","type":"comment","z":"d312f6d5f62126f3","name":"Example: OpenAI System node gives GPT the context it is Alfred and you are Bruce wayne","info":"","x":410,"y":840,"wires":[]}]

Advanced Usage for the Tool Node

Learn more powerful techniques to help you create something unrivaled in the mainstream market

[{"id":"fb79b54329746fdf","type":"OpenAI Tool","z":"b9203c19c137b9ca","name":"Create Reminder","tool":"{\"type\":\"function\",\"function\":{\"name\":\"create_reminder\",\"description\":\"Creates reminders or todo list tasks\",\"parameters\":{\"type\":\"object\",\"properties\":{\"summary\":{\"description\":\"concise summary of what the user wants to rememeber\",\"type\":\"string\"},\"due_date\":{\"type\":\"string\",\"description\":\"ISO format of the date and time the item is due.\"},\"response\":{\"type\":\"string\",\"description\":\"A friendly response to the given command\"}},\"required\":[\"summary\",\"response\"]}}}","x":310,"y":2580,"wires":[["0af347809cc4f889"]]},{"id":"b78220ed2924b292","type":"inject","z":"b9203c19c137b9ca","name":"","props":[{"p":"payload"},{"p":"test","v":"foobar","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":340,"y":2460,"wires":[["9f8d776369d7a404"]]},{"id":"9f8d776369d7a404","type":"OpenAI User","z":"b9203c19c137b9ca","name":"","content":"Remind me to call my mom this evening","x":330,"y":2500,"wires":[["319c7d1026aaad68"]]},{"id":"0af347809cc4f889","type":"OpenAI Chat","z":"b9203c19c137b9ca","name":"","tool_choice":"fb79b54329746fdf","token":"","model":"gpt-4-1106-preview","temperature":0.7,"max_tokens":1200,"top_p":1,"frequency_penalty":0,"presence_penalty":0,"x":330,"y":2620,"wires":[["3cd0ed23014414a7"]]},{"id":"3cd0ed23014414a7","type":"OpenAI Response","z":"b9203c19c137b9ca","name":"","x":310,"y":2660,"wires":[["6f484c5590f7c945"]]},{"id":"319c7d1026aaad68","type":"OpenAI System","z":"b9203c19c137b9ca","name":"","instruction":"You are a smart home assistant capable of controlling a smart home.\nIf asked a command use the appropriate function to fulfill the request.\n\nCurrent Date and time: Jan 17, 2024 2:25pm","x":320,"y":2540,"wires":[["fb79b54329746fdf"]]},{"id":"6f484c5590f7c945","type":"debug","z":"b9203c19c137b9ca","name":"debug 155","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":330,"y":2700,"wires":[]},{"id":"8391c8218a9045d2","type":"inject","z":"b9203c19c137b9ca","name":"Who's home?","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"Who's home?","payloadType":"str","x":670,"y":2340,"wires":[["e0afe7eb27f10308"]]},{"id":"e0afe7eb27f10308","type":"OpenAI User","z":"b9203c19c137b9ca","name":"","content":"{payload}","x":710,"y":2560,"wires":[["c049184a70adfbf6"]]},{"id":"014a49914283462d","type":"OpenAI Chat","z":"b9203c19c137b9ca","name":"","token":"","model":"gpt-4-1106-preview","temperature":0.7,"max_tokens":1200,"top_p":1,"frequency_penalty":0,"presence_penalty":0,"x":710,"y":2680,"wires":[["0ade8e81bde27d32"]]},{"id":"0ade8e81bde27d32","type":"OpenAI Response","z":"b9203c19c137b9ca","name":"","x":690,"y":2720,"wires":[["226793995c673836"]]},{"id":"c049184a70adfbf6","type":"OpenAI System","z":"b9203c19c137b9ca","name":"","instruction":"You are a smart home assistant capable of controlling a smart home.\nIf you need to take some action, use the execute_services function to fulfill your command.\n\nCurrent Date and time: Jan 17, 2024 2:25pm\n\nUse the house data below to answer any questions or take action about the house.\n[\n    {{\n        \"friendly_name\": \"bedroom light\",\n        \"entity_id\" : \"light.bedroom_light\",\n        \"state\": \"off\"\n    }},\n    {{\n        \"friendly_name\": \"Michael's Presence\",\n        \"entity_id\" : \"presence.michael\",\n        \"state\" : \"office\"\n    }},\n    {{\n        \"friendly_name\": \"bedroom motion\",\n        \"entity_id\" : \"binary_sensor.bedroom_motion\",\n        \"state\" : \"off\"\n    }},\n     {{\n        \"friendly_name\": \"Office Lights\",\n        \"entity_id\" : \"light.office\",\n        \"state\" : \"off\"\n    }},\n    {{\n        \"friendly_name\": \"Kitchen Lights\",\n        \"entity_id\" : \"light.kitchen\",\n        \"state\" : \"on\"\n    }},\n]","x":700,"y":2600,"wires":[["c0fa8891f1240484"]]},{"id":"226793995c673836","type":"debug","z":"b9203c19c137b9ca","name":"debug 156","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":710,"y":2760,"wires":[]},{"id":"c0fa8891f1240484","type":"OpenAI Tool","z":"b9203c19c137b9ca","name":"execute_services","tool":"{\"type\":\"function\",\"function\":{\"name\":\"execute_services\",\"description\":\"Use this function to execute service of devices in Home Assistant.\",\"parameters\":{\"type\":\"object\",\"properties\":{\"list\":{\"type\":\"array\",\"items\":{\"type\":\"object\",\"properties\":{\"domain\":{\"type\":\"string\",\"description\":\"The service to be called\"},\"service\":{\"type\":\"string\",\"description\":\"The service to be called\"},\"target\":{\"type\":\"object\",\"description\":\"The service data object to indicate what to control.\",\"properties\":{\"entity_id\":{\"type\":\"string\",\"description\":\"The entity_id retrieved from available devices. It must start with domain, followed by dot character.\"}},\"required\":[\"entity_id\"]}},\"required\":[\"domain\",\"service\",\"target\"]}},\"response\":{\"type\":\"string\",\"description\":\"A friendly response to the given command\"}}}}}","x":690,"y":2640,"wires":[["014a49914283462d"]]},{"id":"2f169ddd9678ce94","type":"inject","z":"b9203c19c137b9ca","name":"is there any one in the bedroom","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"is there any one in the bedroom","payloadType":"str","x":690,"y":2380,"wires":[["e0afe7eb27f10308"]]},{"id":"4e0edb695aac95bf","type":"inject","z":"b9203c19c137b9ca","name":"turn on the lights in the bedroom","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"turn on the lights in the bedroom","payloadType":"str","x":690,"y":2420,"wires":[["e0afe7eb27f10308"]]},{"id":"0a3ab2b87bc63af3","type":"inject","z":"b9203c19c137b9ca","name":"Turn on all the lights","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"Turn on all the lights","payloadType":"str","x":650,"y":2460,"wires":[["e0afe7eb27f10308"]]},{"id":"820291d38b0bf558","type":"comment","z":"b9203c19c137b9ca","name":"Simple: Create Reminder","info":"","x":330,"y":2380,"wires":[]},{"id":"b48f31b080829b82","type":"comment","z":"b9203c19c137b9ca","name":"Complex: Change lights","info":"","x":640,"y":2280,"wires":[]},{"id":"51a70bf45aa5bc4e","type":"inject","z":"b9203c19c137b9ca","name":"Set the lights blue","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"Set the lights to blue","payloadType":"str","x":650,"y":2500,"wires":[["e0afe7eb27f10308"]]}]

Call/Register Node Example

Connects two automations/flows together. When combined with the other AI-Intent Nodes, it allows GPT to instantly trigger functions locally in your system. The caveat is that you cannot define parameters GPT should return.

[{"id":"05bdf9f147f9ea58","type":"inject","z":"d312f6d5f62126f3","name":"","props":[{"p":"payload"},{"p":"test","v":"foobar","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":240,"y":1160,"wires":[["937aada85a8bbdf9"]]},{"id":"937aada85a8bbdf9","type":"OpenAI User","z":"d312f6d5f62126f3","name":"","content":"Lock up the house for me.","x":230,"y":1200,"wires":[["881af854eea6f26b"]]},{"id":"a55915b38c3e6a75","type":"OpenAI Chat","z":"d312f6d5f62126f3","name":"","token":"","model":"gpt-3.5-turbo","temperature":0.7,"max_tokens":1200,"top_p":1,"frequency_penalty":0,"presence_penalty":0,"x":230,"y":1280,"wires":[["8097038c41fd6f2a"]]},{"id":"8097038c41fd6f2a","type":"OpenAI Response","z":"d312f6d5f62126f3","name":"","x":210,"y":1320,"wires":[["18324bcf3283205b"]]},{"id":"881af854eea6f26b","type":"OpenAI System","z":"d312f6d5f62126f3","name":"","instruction":"You are a smart home assistant capable of controlling a smart home.\nIf asked a command use the appropriate function to fulfill the request.","x":220,"y":1240,"wires":[["a55915b38c3e6a75"]]},{"id":"8c97d656955c94f8","type":"Call Intent","z":"d312f6d5f62126f3","name":"","registeredNodeId":"","x":540,"y":1320,"wires":[]},{"id":"18324bcf3283205b","type":"split","z":"d312f6d5f62126f3","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":390,"y":1320,"wires":[["8c97d656955c94f8"]]},{"id":"a63ae38cd3768628","type":"debug","z":"d312f6d5f62126f3","name":"debug 45","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":720,"y":1220,"wires":[]},{"id":"441f8a05100623f4","type":"Register Intent","z":"d312f6d5f62126f3","name":"armHome","description":"Turn on the alarm for the house","excludeFromOpenAi":false,"x":500,"y":1220,"wires":[["a63ae38cd3768628"]]},{"id":"a79bdb00f60eb779","type":"comment","z":"d312f6d5f62126f3","name":"Example: Combining Call Intent with Register Intent node","info":"You can add `Call Intent` node to the \nresponse from OpenAI. If OpenAI responds\nusing function call, then the response will\ndynamically call the correct registered node","x":310,"y":1120,"wires":[]},{"id":"50803a6c3a41949e","type":"comment","z":"d312f6d5f62126f3","name":"Register Intent nodes automatically are added to OpenAI and can be called","info":"","x":700,"y":1180,"wires":[]}]
Previous
Previous

Use GPT to report device status

Next
Next

Useful automations inspired by GPT