Carlos F
Carlos F

Reputation: 923

Transfer control with inline buttons in telegram (bots)

If you have a bot-generated in-line button in a chat, that inline button can be used to take you to a bot.

My question is - is the reverse possible?

Can the bot have an inline button (when directly communicating with it) and it can transfer control to a group where the user and bot are both present

Consider this scenario: I have a bot that track country names. When added to a group it detects a country name and says “see information about the country”.

When you click the button, the bot takes you to a chat with it (changes wondows and moves you out) and then the bot displays information about the country.

The bot then has a “go back or cancel” inline button.

If you click that button, it should take you BACK to the originating group you came from. Is that possible?

Variation:

Can it move you back to the originating group automatically (without an inline button) but say based on some text you type?

Upvotes: 1

Views: 1919

Answers (1)

UnrivaledIr
UnrivaledIr

Reputation: 2106

All I got is you wanna to take back your users to their refer place right?

For example you have "Back" button in your channel. If user came from Channel A you want to detect that when it clicks on Back button you want to take it back to Channel A. No it's not possible. Telegram bots can't track user activity like this. But Telegram do itself. For example if you visit some channels like this:

Channel A => First Post => Go to another channel (Channel B) => Then go to admin profile

If you click Back button triple time you will go to first step which in this case is Channel A

Bot if your bot is in one private group or private channel you can get the link of every message because Telegram added this feature here :

you can now copy links to messages in private groups and channels – just like you could with public messages.

So if user mention your bot's username on any message in private group/channel you can get the link of that message. Here is some example :

 {
   "ok": true,
   "result": [{
     "update_id": 954197936,
     "message": {
       "message_id": 188,
       "from": {
         "id": 223110107,
         "is_bot": false,
         "first_name": "Ğąme ",
         "last_name": "Ǿver!",
         "username": "GameO7er",
         "language_code": "en"
       },
       "chat": {
         "id": -1001241538300,
         "title": "Game Over Test Group",
         "type": "supergroup"
       },
       "date": 1576312634,
       "reply_to_message": {
         "message_id": 130,
         "from": {
           "id": 156878147,
           "is_bot": false,
           "first_name": "Carlos F",
           "username": "@Carlos****",
           "language_code": "en"
         },
         "chat": {
           "id": -1001241538300,
           "title": "Game Over Test Group",
           "type": "supergroup"
         },
         "date": 1554783715,
         "text": "Hello Game Over!"
       },
       "text": "@Go***bot",
       "entities": [{
         "offset": 0,
         "length": 10,
         "type": "mention"
       }]
     }
   }]
 }

The link of this message is:

https://t.me/c/1241538300/130

As you can see it will be generate from chat id

 "chat": {
         "id": -1001241538300,
         "title": "Game Over Test Group",
         "type": "supergroup"
       },

remove -100 from -1001241538300 then you have 1241538300 and contact /c/message_id to end of it.

"date": 1576312634,
       "reply_to_message": {
         "message_id": 130,
         "from": {
           "id": 156878147,
           "is_bot": false,
           "first_name": "Carlos F",
           "username": "@Carlos****",
           "language_code": "en"
         },

and you will have :

https://t.me/c/1241538300/130

Upvotes: 3

Related Questions