How to create a button on telegram

Hi Community,

My request is when node-red send a alert message to telegram and the user can pressed the Acknowledge button then will send back message to node-red.

And 1 more request was is it able to let the telegram user acknowledge at the same time need the user to type in their information. Eg. Name, contact or time.

Below my flow is already create a button but when i pressed the button there was not a respond from the button can help me on this part.

[{"id":"0f57a3adebcf82ee","type":"tab","label":"Telegram Acknowledgment Flow","disabled":false,"info":""},{"id":"4936bb5e36436a5b","type":"telegram receiver","z":"0f57a3adebcf82ee","name":"Receive Messages","bot":"","saveDataDir":"","filterCommands":false,"x":570,"y":340,"wires":[["752d7640637b2a0c"],[]]},{"id":"752d7640637b2a0c","type":"function","z":"0f57a3adebcf82ee","name":"Process Messages","func":"if (msg.payload && msg.payload.text) {\n    // Process the received message\n    const chatId = msg.payload.chat.id;\n    const userMessage = msg.payload.text.toLowerCase();\n    let response = '';\n\n    // Check for specific commands or keywords\n    if (userMessage.includes('hello')) {\n        response = 'Hello there!';\n    } else if (userMessage.includes('goodbye')) {\n        response = 'Goodbye!';\n    } else {\n        response = 'I didn\\'t understand that. Type hello or goodbye.';\n    }\n\n    // Add acknowledgment button\n    const keyboard = {\n        inline_keyboard: [\n            [{ text: 'Acknowledge', callback_data: 'acknowledge' }]\n        ]\n    };\n\n    // Prepare the response message with acknowledgment button\n    msg.payload = {\n        chatId: chatId,\n        type: 'message',\n        content: response,\n        options: { reply_markup: keyboard }\n    };\n\n    return msg;\n}\nreturn null;","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":850,"y":340,"wires":[["c8524ab6e148c834"]]},{"id":"c8524ab6e148c834","type":"telegram sender","z":"0f57a3adebcf82ee","name":"Send Response","bot":"","haserroroutput":false,"outputs":1,"x":1120,"y":340,"wires":[["9da706ff063db993"]]},{"id":"da7827f60f7f9697","type":"inject","z":"0f57a3adebcf82ee","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"chatId\":5407037072,\"type\":\"message\",\"content\":\"Hello, click the button!\",\"options\":{\"reply_markup\":{\"inline_keyboard\":[[{\"text\":\"Acknowledge\",\"callback_data\":\"acknowledge\"}]]}}}","payloadType":"json","x":570,"y":160,"wires":[["d9f3badf3c5cddf4"]]},{"id":"d9f3badf3c5cddf4","type":"telegram sender","z":"0f57a3adebcf82ee","name":"Send Message","bot":"","haserroroutput":false,"outputs":1,"x":820,"y":160,"wires":[["948f42fcb46e9620"]]},{"id":"948f42fcb46e9620","type":"debug","z":"0f57a3adebcf82ee","name":"debug 8","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1060,"y":160,"wires":[]},{"id":"9da706ff063db993","type":"debug","z":"0f57a3adebcf82ee","name":"debug 9","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1320,"y":340,"wires":[]}]

thanks

The inline keyboard is received with the callback query node.
The keyboard is received by the receiver node.
Have a look at the examples import > examples > telegrambot.

I don't remember all the options but I use this:

const keyboard = [
  ["Enable", "Disable"]
];
const opts = {
    "reply_markup": JSON.stringify({
        "keyboard": keyboard,
        "resize_keyboard": true,
        "one_time_keyboard": true
    }),
    "disable_web_page_preview": true,
    "parse_mode": "Markdown",
    chatId: XXXXXXX,
    type: "message",
};
return { payload: { content: "Bla bla bla", options: opts } };

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