# Can the properties of a node be changed programatically?

**URL:** <https://discourse.nodered.org/t/can-the-properties-of-a-node-be-changed-programatically/50569>\
**Category:** General\
**Tags:** telegram\
**Created:** [3 September 2021 07:44 UTC](https://discourse.nodered.org/t/can-the-properties-of-a-node-be-changed-programatically/50569 "2021-09-03T07:44:19Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![noBody](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nobody/32/33322_2.png) [@noBody](https://discourse.nodered.org/u/noBody)\
**Post date:** [3 September 2021 07:44 UTC](https://discourse.nodered.org/t/can-the-properties-of-a-node-be-changed-programatically/50569/1 "2021-09-03T07:44:19Z")

</div>

I am trying to send notifications using node-red-contrib-telegrambot. This module requires setting bot name, token, user ID, and name (optional) beforehand.

I understand that the bot can get the user ID and name from the message sent to it. But, is there a way to set bot name, token, and User ID programmatically. Say, from input text boxes on the UI?

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [3 September 2021 08:02 UTC](https://discourse.nodered.org/t/can-the-properties-of-a-node-be-changed-programatically/50569/2 "2021-09-03T08:02:16Z")

</div>

Not at runtime unless the developer added such capabilities.

However, you can use env vars to set the value of a text field.

---

<div class="post-metadata">

**Author:** ![noBody](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nobody/32/33322_2.png) [@noBody](https://discourse.nodered.org/u/noBody)\
**Post date:** [3 September 2021 08:16 UTC](https://discourse.nodered.org/t/can-the-properties-of-a-node-be-changed-programatically/50569/3 "2021-09-03T08:16:39Z")

</div>

Thank you.

If not at runtime, setting and restarting the flow should also be fine as long as it is from UI, not from the editor.

Can you give an example of how I can use env vars to set properties from text field?

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [3 September 2021 08:25 UTC](https://discourse.nodered.org/t/can-the-properties-of-a-node-be-changed-programatically/50569/4 "2021-09-03T08:25:04Z")

</div>

see docs - [Using environment variables : Node-RED](https://nodered.org/docs/user-guide/environment-variables)

---

<div class="post-metadata">

**Author:** ![noBody](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nobody/32/33322_2.png) [@noBody](https://discourse.nodered.org/u/noBody)\
**Post date:** [3 September 2021 10:35 UTC](https://discourse.nodered.org/t/can-the-properties-of-a-node-be-changed-programatically/50569/5 "2021-09-03T10:35:07Z")

</div>

I tried:  
`export some_var=123` in terminal

and tried to read it as explained in the docs. But it returns empty. Also, I tried `export some_var=123` inside exec node just in case if nodered was on different environment. It still results empty.

```auto
[
    {
        "id": "d17299e5.9ff148",
        "type": "tab",
        "label": "Flow 5",
        "disabled": false,
        "info": ""
    },
    {
        "id": "d66f687a.d01248",
        "type": "change",
        "z": "d17299e5.9ff148",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "some_var",
                "tot": "env"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 380,
        "y": 140,
        "wires": [
            [
                "67cb1bc6.0b3724"
            ]
        ]
    },
    {
        "id": "578fe08e.8f056",
        "type": "inject",
        "z": "d17299e5.9ff148",
        "name": "",
        "props": [
            {
                "p": "payload",
                "v": "",
                "vt": "date"
            },
            {
                "p": "topic",
                "v": "",
                "vt": "string"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 160,
        "y": 140,
        "wires": [
            [
                "d66f687a.d01248"
            ]
        ]
    },
    {
        "id": "67cb1bc6.0b3724",
        "type": "debug",
        "z": "d17299e5.9ff148",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 580,
        "y": 140,
        "wires": []
    },
    {
        "id": "0a79e7b4cbf4e1cb",
        "type": "exec",
        "z": "d17299e5.9ff148",
        "command": "export some_var=123",
        "addpay": "",
        "append": "",
        "useSpawn": "false",
        "timer": "",
        "winHide": false,
        "oldrc": false,
        "name": "",
        "x": 400,
        "y": 80,
        "wires": [
            [
                "a67d205f48f957c7"
            ],
            [],
            []
        ]
    },
    {
        "id": "48b8a588201d86de",
        "type": "inject",
        "z": "d17299e5.9ff148",
        "name": "",
        "props": [
            {
                "p": "payload",
                "v": "",
                "vt": "date"
            },
            {
                "p": "topic",
                "v": "",
                "vt": "string"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 160,
        "y": 80,
        "wires": [
            [
                "0a79e7b4cbf4e1cb"
            ]
        ]
    },
    {
        "id": "a67d205f48f957c7",
        "type": "debug",
        "z": "d17299e5.9ff148",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 590,
        "y": 80,
        "wires": []
    }
]

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [2 November 2021 10:35 UTC](https://discourse.nodered.org/t/can-the-properties-of-a-node-be-changed-programatically/50569/6 "2021-11-02T10:35:50Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
