guidone/node-red-contrib-chatbot

Solution for Topics (the new Telegram update)

Iciir opened this issue · 0 comments

Iciir commented

The new Telegram update comes with Topics in groups over 200. My bots could not respond in those topics anymore.

(instructions bellow the code ↓)

✅ I came up with this solution which works perfectly:

[
    {
        "id": "20a157cc9f5a8385",
        "type": "subflow",
        "name": "topics fix",
        "info": "",
        "category": "krai",
        "in": [
            {
                "x": 60,
                "y": 60,
                "wires": [
                    {
                        "id": "8b540df0efa0507c"
                    }
                ]
            }
        ],
        "out": [
            {
                "x": 820,
                "y": 60,
                "wires": [
                    {
                        "id": "0c8af44ac078226f",
                        "port": 0
                    }
                ]
            }
        ],
        "env": [],
        "meta": {},
        "color": "#D05AEC",
        "icon": "font-awesome/fa-gears"
    },
    {
        "id": "61457164ab1ed356",
        "type": "switch",
        "z": "20a157cc9f5a8385",
        "name": "",
        "property": "originalMessage.is_topic_message",
        "propertyType": "msg",
        "rules": [
            {
                "t": "true"
            },
            {
                "t": "else"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 315,
        "y": 300,
        "wires": [
            [
                "f4cfaabb93f23b1e"
            ],
            [
                "d65868dddf56a5b8"
            ]
        ],
        "l": false
    },
    {
        "id": "f4cfaabb93f23b1e",
        "type": "switch",
        "z": "20a157cc9f5a8385",
        "name": "",
        "property": "payload.params.replyToMessage",
        "propertyType": "msg",
        "rules": [
            {
                "t": "true"
            },
            {
                "t": "else"
            }
        ],
        "checkall": "false",
        "repair": false,
        "outputs": 2,
        "x": 375,
        "y": 280,
        "wires": [
            [
                "16f68b2acf1be91c"
            ],
            [
                "d0a73bb725a1a7dc"
            ]
        ],
        "l": false
    },
    {
        "id": "d0a73bb725a1a7dc",
        "type": "change",
        "z": "20a157cc9f5a8385",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "payload.messageId",
                "pt": "msg",
                "to": "originalMessage.reply_to_message.message_thread_id",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 435,
        "y": 300,
        "wires": [
            [
                "6a8634c72bd5ede3"
            ]
        ],
        "l": false
    },
    {
        "id": "d65868dddf56a5b8",
        "type": "function",
        "z": "20a157cc9f5a8385",
        "name": "",
        "func": "\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 375,
        "y": 320,
        "wires": [
            [
                "5a7778c8f7f35bdc"
            ]
        ],
        "icon": "font-awesome/fa-braille",
        "l": false
    },
    {
        "id": "5a7778c8f7f35bdc",
        "type": "function",
        "z": "20a157cc9f5a8385",
        "name": "",
        "func": "\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 495,
        "y": 320,
        "wires": [
            [
                "3a867deadcce24b6"
            ]
        ],
        "icon": "font-awesome/fa-braille",
        "l": false
    },
    {
        "id": "16f68b2acf1be91c",
        "type": "function",
        "z": "20a157cc9f5a8385",
        "name": "",
        "func": "\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 435,
        "y": 260,
        "wires": [
            [
                "6a8634c72bd5ede3"
            ]
        ],
        "icon": "font-awesome/fa-braille",
        "l": false
    },
    {
        "id": "3a867deadcce24b6",
        "type": "function",
        "z": "20a157cc9f5a8385",
        "name": "",
        "func": "\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 555,
        "y": 300,
        "wires": [
            [
                "800fdef48bcc59df"
            ]
        ],
        "icon": "font-awesome/fa-braille",
        "l": false
    },
    {
        "id": "8b540df0efa0507c",
        "type": "link out",
        "z": "20a157cc9f5a8385",
        "name": "",
        "mode": "link",
        "links": [
            "5b4ef45218398e91"
        ],
        "x": 135,
        "y": 60,
        "wires": []
    },
    {
        "id": "5b4ef45218398e91",
        "type": "link in",
        "z": "20a157cc9f5a8385",
        "name": "",
        "links": [
            "8b540df0efa0507c"
        ],
        "x": 235,
        "y": 300,
        "wires": [
            [
                "61457164ab1ed356"
            ]
        ]
    },
    {
        "id": "800fdef48bcc59df",
        "type": "link out",
        "z": "20a157cc9f5a8385",
        "name": "",
        "mode": "link",
        "links": [
            "0c8af44ac078226f"
        ],
        "x": 635,
        "y": 300,
        "wires": []
    },
    {
        "id": "0c8af44ac078226f",
        "type": "link in",
        "z": "20a157cc9f5a8385",
        "name": "",
        "links": [
            "800fdef48bcc59df"
        ],
        "x": 745,
        "y": 60,
        "wires": [
            []
        ]
    },
    {
        "id": "6a8634c72bd5ede3",
        "type": "function",
        "z": "20a157cc9f5a8385",
        "name": "",
        "func": "\nif ( !msg.payload ) msg.payload = {}\n\nif ( !msg.payload.params ) msg.payload.params = {}\n\nmsg.payload.params.replyToMessage = true\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 495,
        "y": 280,
        "wires": [
            [
                "3a867deadcce24b6"
            ]
        ],
        "icon": "node-red-contrib-chatbot/chatbot-params.png",
        "l": false
    },
    {
        "id": "4f780f387428381d",
        "type": "comment",
        "z": "20a157cc9f5a8385",
        "name": "BuyMeACoffee.com/krai",
        "info": "\n\n[Thank you if you're considering it! :)](https://buymeacoffee.com/krai)\n\n\n❤️",
        "x": 330,
        "y": 520,
        "wires": []
    },
    {
        "id": "551910dd222f0b23",
        "type": "subflow:20a157cc9f5a8385",
        "z": "e1a4078717fee5a6",
        "name": "",
        "x": 495,
        "y": 2120,
        "wires": [
            [
                "dcd45e9546968c99"
            ]
        ],
        "l": false
    }
]

Instructions

Copy the code ↑ above.

Press Ctrl+I to import the node (& subflow).

Place the [topics fix] node before your [Telegram Out] nodes.

Maybe change the subflow name to better suit your style.

Have a good day! ⭐️