Configuring ChatGPT to work with node-red and companion app notifications

I have this flow

image

this is how I configured ChatGPT

and this is the debug output

shouldn’t the output be the joke?

Basically I want to take the output from ChatGPT and send it as a notification using the Home Assistant companion app.

What is the variable I must use here?

Click the add button to create an output.

image

then set msg.payload to results in the ai task node.

Use

{ "message": {{payload}} }

To pass it to the text node.

the last part appears to have a formatting error

Sorry {{payload}} needs to be in quotes

{ "message": "{{payload}}" }

Alternatively, you can also use jsonata. Jsonata is more powerful, variables can be manipulated and it handles certain values like web addresses better. To use jsonata change the data field to J and use

{ "message": payload }

the notification is received on the phone, but its like this

this is the whole flow

[
    {
        "id": "22e2e90dd2014948",
        "type": "tab",
        "label": "Flow 1",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "17863239cea5d585",
        "type": "api-call-service",
        "z": "22e2e90dd2014948",
        "name": "chatgpt",
        "server": "cd90eeeb2e8d7dc5",
        "version": 7,
        "debugenabled": false,
        "action": "ai_task.generate_data",
        "floorId": [],
        "areaId": [],
        "deviceId": [],
        "entityId": [],
        "labelId": [],
        "data": "{\"task_name\":\"joke\",\"entity_id\":\"ai_task.openai_ai_task\",\"instructions\":\"tell me a joke\"}",
        "dataType": "json",
        "mergeContext": "",
        "mustacheAltTags": false,
        "outputProperties": [
            {
                "property": "payload",
                "propertyType": "msg",
                "value": "",
                "valueType": "data"
            }
        ],
        "queue": "none",
        "blockInputOverrides": true,
        "domain": "ai_task",
        "service": "generate_data",
        "x": 420,
        "y": 320,
        "wires": [
            [
                "c6e3ad2d17d21046"
            ]
        ]
    },
    {
        "id": "fa3f20d5a8ddf18c",
        "type": "inject",
        "z": "22e2e90dd2014948",
        "name": "trigger manually",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 200,
        "y": 320,
        "wires": [
            [
                "17863239cea5d585"
            ]
        ]
    },
    {
        "id": "c6e3ad2d17d21046",
        "type": "api-call-service",
        "z": "22e2e90dd2014948",
        "name": "send app notification",
        "server": "cd90eeeb2e8d7dc5",
        "version": 7,
        "debugenabled": false,
        "action": "notify.mobile_app_aristos_phone",
        "floorId": [],
        "areaId": [],
        "deviceId": [],
        "entityId": [],
        "labelId": [],
        "data": "{ \"message\": \"{{payload}}\" }",
        "dataType": "json",
        "mergeContext": "",
        "mustacheAltTags": false,
        "outputProperties": [],
        "queue": "none",
        "blockInputOverrides": true,
        "domain": "notify",
        "service": "mobile_app_aristos_phone",
        "x": 840,
        "y": 320,
        "wires": [
            []
        ]
    },
    {
        "id": "cd90eeeb2e8d7dc5",
        "type": "server",
        "name": "Home Assistant",
        "version": 5,
        "addon": false,
        "rejectUnauthorizedCerts": true,
        "ha_boolean": "y|yes|true|on|home|open",
        "connectionDelay": true,
        "cacheJson": true,
        "heartbeat": false,
        "heartbeatInterval": 30,
        "areaSelector": "friendlyName",
        "deviceSelector": "friendlyName",
        "entitySelector": "friendlyName",
        "statusSeparator": ": ",
        "statusYear": "hidden",
        "statusMonth": "short",
        "statusDay": "numeric",
        "statusHourCycle": "default",
        "statusTimeFormat": "h:m",
        "enableGlobalContextStore": false
    },
    {
        "id": "258668c0e897acb2",
        "type": "global-config",
        "env": [],
        "modules": {
            "node-red-contrib-home-assistant-websocket": "0.78.2"
        }
    }
]

In the ChatGPT Action node, set the Output Properties to results (instead of sent data).
Then attach a Debug node and trigger the flow — this will show the complete object returned by ChatGPT.

When you see the value you want, hover over it in the Debug panel and click Copy Path.
You can paste that path directly into the data field of your next Action node.

For best results, set the data field type to J: Expression (JSONata) — it handles dynamic values much more reliably than plain JSON.

Example:

{ "message": payload.abc.xyz }
2 Likes

Thank you! It worked!