windkh / node-red-contrib-telegrambot

Telegram bot nodes for node-red.
Other
259 stars 116 forks source link

Cannot find event that catches Telegram.WebApp.sendData #264

Closed oldmh closed 1 year ago

oldmh commented 1 year ago

Hello, cannot find any event that catches Telegram.WebApp.sendData.

Node-RED Version: 2.2.0
node-red-contrib-telegrambot Version: 12.0.0
image

I was developing a webpage to include it into my bot using webapp feature. I had a button, that sends data onclick to bot.

image

After click on the button telegram sends a message that I have passed data to bot

image

So, I am not sure that this feature is already implemented, but I saw that you have added a support for API 6.0.0 version that contains WebApp support.

So, if I have missed something or this feature is not implemeted, please answer me in the issue.

Thank you for your library. Have a nice day.

windkh commented 1 year ago

WebApp features are not supported yet. I added only few API 6.0 features that people requested a while ago.

windkh commented 1 year ago

@MykhailKacha I would like to implement this for you. But how can I call Telegram.WebApp.sendData? I never did a WebApp and would need your help to be able to reproduce/test it.

In my theory the bot will receive a message of a new type like SentWebAppMessage.

ShotokanZH commented 1 year ago

I am interested in this feature too. Note: a catch-all-the-updates node would be amazing to configure new features without waiting for them to be implemented here :)

By the way: 1- create a web app that sends a message back:

<script src="https://telegram.org/js/telegram-web-app.js"></script>                                                                                                                                   
<script>                                                                                                                                                                                              
window.Telegram.WebApp.sendData("SNADO");                                                                                                                                                             
</script>

2- upload it to a public web server ( https://example.com/test.html ) 3- send a message to the user showing a custom inline keyboard:

    msg.payload={
        reply_to_message_id: msg.payload.messageId,
        type: "message",
        content: "Managing stuff..",
        chatId: 1234567890,
        options: {
            reply_markup: JSON.stringify({
                keyboard:[
                    [
                        {
                            "text": "Managing stuff..",
                            "web_app": {
                                "url":"https://example.com/test.html?"+Math.random()
                            }
                        }
                    ]
                ]
            })
        }
    };

4- Just press on the gigantic "Managing stuff.." button 5- The bot will receive a Message object ( https://core.telegram.org/bots/api#message ) containing the WebAppData optional object populated ( https://core.telegram.org/bots/api#webappdata ) 6- Enjoy ?

windkh commented 1 year ago

@ShotokanZH thanks alot... exactly what I was looking for

windkh commented 1 year ago

please try 14.1.0 the message type is web_app_data and can be received using the receiver node

windkh commented 1 year ago

image

ShotokanZH commented 1 year ago

Amazing work man!