Skip to content

Document Bot and Conversations chat IDs #48

@PaulCombal

Description

@PaulCombal

I have a doubt about the way chat IDs are handled in Nutgram, for which I could not find an answer.

I created an inline menu, the running method is polling, here is a snippet of a handler's code:

public function handler(Nutgram $bot) {
...
            echo "==========\n";
            echo "BOT CHAT ID: " . $bot->chatId() . "\n";
            echo "CONV CHAT ID: " . $this->getChatId() . "\n";
            echo "==========\n";
[2024-05-20 17:00:38] DEBUG: ⬇️ Nutgram Response
{"response":{"ok":true,"result":[{"update_id":136638649,"callback_query":{"id":"5185141848770776378","from":{"id":5502227XXX,"is_bot":false,"first_name":"XXX","username":"XXX","language_code":"fr"},"message":{"message_id":161,"from":{"id":6905006184,"is_bot":true,"first_name":"Telebiz_dev_shop_bot","username":"TelebizDevShopBot"},"chat":{"id":5502227XXX,"first_name":"XXX","username":"XXXX","type":"private"},"date":1716224428,"edit_date":1716224432,"text":"produit - 1EUR\ndesc","reply_markup":{"inline_keyboard":[[{"text":"Place order","callback_data":"018f921a-4b16-7119-a9e4-b7110a8d1b39"}],[{"text":"Back to category","callback_data":"018f9219-be39-7662-a952-7a5bf0b9edcf"}]]}},"chat_instance":"-8220016788377822890","data":"018f921a-4b16-7119-a9e4-b7110a8d1b39"}}]},"type":"response"}
===============================
==========
BOT CHAT ID: 5502227XXX
CONV CHAT ID: 
==========

What's the difference between the Bot Chat ID and the Conversation Chat ID?

How come the bot holds the chat ID and the InlineMenu holds NULL?

When does an InlineMenu hold a Chat ID?

Will the bot always be reliable with Chat IDs with multiple concurrent users?

According to this documentation: https://nutgram.dev/docs/usage/conversations#starting-a-conversation-from-server-side , I should be able to retrieve the chat ID from $this since InlineMenu extends Conversation

I am a bit inexperienced with the Telegram API, and this is the kind of moment I wish the documentation would be a bit beefier around these details. Instinctively, it would make more sense to me if the conversation held the chat Id with the user. I need to understand why this was not implemented this way.

Let me know if you need any more details

Thank you for your amazing work

Metadata

Metadata

Assignees

Labels

questionFurther information is requested

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions