[NodeRed] Morning R...
 
Notifications
Clear all

[NodeRed] Morning Routine

1 Posts
1 Users
0 Reactions
123 Views
(@andre)
Posts: 55
Member Admin
Topic starter
 

[NodeRed] Morning Routine

sends the morning briefing to various social networks. this is achieved by running a node-red routine to gather all the info for the day and use it to build a prompt.

 

Prompt:

You are an artificial intelligence called Valley Community AI.The Valley is group of small towns on the coast of Cape town. You are tasked with giving residents of the Valley information on what's happening in the area and recommending local businesses for them to support. You have the following upcoming event listed on your calendar; \" & msg.upevents & \". Give a morning briefing and include the following information. The folowing weather information : \" & msg.forecast & \" , Refuse collection for the following areas\"  & msg.ref & \", an activity to do in Fish Hoek or a Surrounding area, the next upcoming event on your calendar, recommend the following randomly selected business : \" & msg.bus & \" , include the following hint : \" & msg.hint & \". the briefing will be sent via telegram and should not exceed 1200 charactters. the message must be formatted in a way that is stylish for the platform and include emoji's. Include up to 5 hashtags and sign off with Valley Community AI 🤖

 

msg.forecast :

Pulls from HomeAssistant

msg.upevents: https://api.valleycommunity.co.za/Events/GetWeekendRandom

msg.bus: https://api.valleycommunity.co.za/Business/GetRandomBusinesses

msg.hint: https://api.valleycommunity.co.za/Help/RandomHint

msg.ref: https://api.valleycommunity.co.za/Refuse/GetToday

 

NodeRed Flow:

[
    {
        "id": "ba39bd3bde5fbbfc",
        "type": "tab",
        "label": "Flow 1",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "6afda524ee3a73c8",
        "type": "http request",
        "z": "ba39bd3bde5fbbfc",
        "name": "Ollama Post",
        "method": "POST",
        "ret": "obj",
        "paytoqs": "ignore",
        "url": "http://192.168.1.51:11434/api/generate",
        "tls": "",
        "persist": true,
        "proxy": "",
        "insecureHTTPParser": false,
        "authType": "",
        "senderr": false,
        "headers": [
            {
                "keyType": "Content-Type",
                "keyValue": "",
                "valueType": "other",
                "valueValue": "application/json; charset=utf-8"
            }
        ],
        "x": 1410,
        "y": 260,
        "wires": [
            [
                "1a486357f4e4392a"
            ]
        ]
    },
    {
        "id": "af82f520582f61d0",
        "type": "api-current-state",
        "z": "ba39bd3bde5fbbfc",
        "name": "Forecast",
        "server": "621ccdea4936d754",
        "version": 3,
        "outputs": 1,
        "halt_if": "",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "entity_id": "weather.forecast_tiltman_home",
        "state_type": "str",
        "blockInputOverrides": false,
        "outputProperties": [
            {
                "property": "data",
                "propertyType": "msg",
                "value": "",
                "valueType": "entity"
            }
        ],
        "for": "0",
        "forType": "num",
        "forUnits": "minutes",
        "override_topic": false,
        "state_location": "payload",
        "override_payload": "msg",
        "entity_location": "data",
        "override_data": "msg",
        "x": 460,
        "y": 200,
        "wires": [
            [
                "6632f3da5fd9a9e6"
            ]
        ]
    },
    {
        "id": "9f2473952031da5d",
        "type": "change",
        "z": "ba39bd3bde5fbbfc",
        "name": "Set Payload",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "{\"model\":\"phi3\",\"prompt\":\"You are an artificial intelligence called Valley Community AI.The Valley is group of small towns on the coast of Cape town. You are tasked with giving residents of the Valley information on what's happening in the area and recommending local businesses for them to support. You have the following upcoming event listed on your calendar; \" & msg.upevents & \". Give a morning briefing and include the following information. The folowing weather information : \" & msg.forecast & \" , Refuse collection for the following areas\"  & msg.ref & \", an activity to do in Fish Hoek or a Surrounding area, the next upcoming event on your calendar, recommend the following randomly selected business : \" & msg.bus & \" , include the following hint : \" & msg.hint & \". the briefing will be sent via telegram and should not exceed 1200 charactters. the message must be formatted in a way that is stylish for the platform and include emoji's. Include up to 5 hashtags and sign off with Valley Community AI 🤖\" ,\"stream\":false}",
                "tot": "jsonata"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 1330,
        "y": 340,
        "wires": [
            [
                "6afda524ee3a73c8"
            ]
        ]
    },
    {
        "id": "92ae6f6bb1c10a13",
        "type": "http request",
        "z": "ba39bd3bde5fbbfc",
        "name": "Events",
        "method": "GET",
        "ret": "obj",
        "paytoqs": "ignore",
        "url": "https://api.valleycommunity.co.za/Events/GetWeekendRandom",
        "tls": "",
        "persist": false,
        "proxy": "",
        "insecureHTTPParser": false,
        "authType": "",
        "senderr": false,
        "headers": [],
        "x": 530,
        "y": 320,
        "wires": [
            [
                "f8a473867586c83d"
            ]
        ]
    },
    {
        "id": "f8a473867586c83d",
        "type": "change",
        "z": "ba39bd3bde5fbbfc",
        "name": "set property",
        "rules": [
            {
                "t": "set",
                "p": "upevents",
                "pt": "msg",
                "to": "payload",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 670,
        "y": 360,
        "wires": [
            [
                "94b4301fb04fd159"
            ]
        ]
    },
    {
        "id": "1a486357f4e4392a",
        "type": "change",
        "z": "ba39bd3bde5fbbfc",
        "name": "Save Response",
        "rules": [
            {
                "t": "set",
                "p": "telemessage",
                "pt": "msg",
                "to": "payload.response",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 1540,
        "y": 300,
        "wires": [
            [
                "28f68f799826182f"
            ]
        ]
    },
    {
        "id": "6632f3da5fd9a9e6",
        "type": "change",
        "z": "ba39bd3bde5fbbfc",
        "name": "set property",
        "rules": [
            {
                "t": "set",
                "p": "forecast",
                "pt": "msg",
                "to": "data.attributes.forecast[0]",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 510,
        "y": 260,
        "wires": [
            [
                "92ae6f6bb1c10a13"
            ]
        ]
    },
    {
        "id": "9b1c23dedb2eb6ca",
        "type": "inject",
        "z": "ba39bd3bde5fbbfc",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "00 06 * * *",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 370,
        "y": 160,
        "wires": [
            [
                "af82f520582f61d0"
            ]
        ]
    },
    {
        "id": "28f68f799826182f",
        "type": "debug",
        "z": "ba39bd3bde5fbbfc",
        "name": "Morning Routine",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload.response",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 1880,
        "y": 300,
        "wires": []
    },
    {
        "id": "94b4301fb04fd159",
        "type": "http request",
        "z": "ba39bd3bde5fbbfc",
        "name": "Business",
        "method": "GET",
        "ret": "obj",
        "paytoqs": "ignore",
        "url": "https://api.valleycommunity.co.za/Business/GetRandomBusinesses",
        "tls": "",
        "persist": false,
        "proxy": "",
        "insecureHTTPParser": false,
        "authType": "",
        "senderr": false,
        "headers": [],
        "x": 740,
        "y": 300,
        "wires": [
            [
                "523515d61e5a4bc0"
            ]
        ]
    },
    {
        "id": "523515d61e5a4bc0",
        "type": "change",
        "z": "ba39bd3bde5fbbfc",
        "name": "set property",
        "rules": [
            {
                "t": "set",
                "p": "bus",
                "pt": "msg",
                "to": "payload",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 810,
        "y": 260,
        "wires": [
            [
                "d26e9080bc13be95"
            ]
        ]
    },
    {
        "id": "2880848b574b3396",
        "type": "http request",
        "z": "ba39bd3bde5fbbfc",
        "name": "Refuse",
        "method": "GET",
        "ret": "obj",
        "paytoqs": "ignore",
        "url": "https://api.valleycommunity.co.za/Refuse/GetToday",
        "tls": "",
        "persist": false,
        "proxy": "",
        "insecureHTTPParser": false,
        "authType": "",
        "senderr": false,
        "headers": [],
        "x": 1060,
        "y": 300,
        "wires": [
            [
                "5392504614fe1e2b"
            ]
        ]
    },
    {
        "id": "5392504614fe1e2b",
        "type": "change",
        "z": "ba39bd3bde5fbbfc",
        "name": "set property",
        "rules": [
            {
                "t": "set",
                "p": "ref",
                "pt": "msg",
                "to": "payload",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 1210,
        "y": 260,
        "wires": [
            [
                "9f2473952031da5d"
            ]
        ]
    },
    {
        "id": "d26e9080bc13be95",
        "type": "http request",
        "z": "ba39bd3bde5fbbfc",
        "name": "Hint",
        "method": "GET",
        "ret": "txt",
        "paytoqs": "ignore",
        "url": "https://api.valleycommunity.co.za/Help/RandomHint",
        "tls": "",
        "persist": false,
        "proxy": "",
        "insecureHTTPParser": false,
        "authType": "",
        "senderr": false,
        "headers": [],
        "x": 910,
        "y": 300,
        "wires": [
            [
                "fd4fda2c3048c018"
            ]
        ]
    },
    {
        "id": "fd4fda2c3048c018",
        "type": "change",
        "z": "ba39bd3bde5fbbfc",
        "name": "set property",
        "rules": [
            {
                "t": "set",
                "p": "hint",
                "pt": "msg",
                "to": "payload",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 1010,
        "y": 260,
        "wires": [
            [
                "2880848b574b3396"
            ]
        ]
    },
    {
        "id": "621ccdea4936d754",
        "type": "server",
        "name": "Home Assistant",
        "version": 5,
        "addon": false,
        "rejectUnauthorizedCerts": false,
        "ha_boolean": "y|yes|true|on|home|open",
        "connectionDelay": true,
        "cacheJson": false,
        "heartbeat": true,
        "heartbeatInterval": "30",
        "areaSelector": "id",
        "deviceSelector": "id",
        "entitySelector": "id",
        "statusSeparator": ": ",
        "statusYear": "hidden",
        "statusMonth": "short",
        "statusDay": "numeric",
        "statusHourCycle": "default",
        "statusTimeFormat": "h:m",
        "enableGlobalContextStore": true
    }
]
 
Posted : 23/07/2024 8:24 pm
Share: