You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+45-1Lines changed: 45 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,7 +12,8 @@ This package makes it easy to send Telegram notification using [Telegram Bot API
12
12
## Contents
13
13
14
14
-[Installation](#installation)
15
-
-[Setting up your Telegram bot](#setting-up-your-telegram-bot)
15
+
-[Setting up your Telegram Bot](#setting-up-your-telegram-bot)
16
+
-[Retrieving Chat ID](#retrieving-chat-id)
16
17
-[Using in Lumen](#using-in-lumen)
17
18
-[Proxy or Bridge Support](#proxy-or-bridge-support)
18
19
-[Usage](#usage)
@@ -66,6 +67,47 @@ Then, configure your Telegram Bot API Token:
66
67
],
67
68
```
68
69
70
+
## Retrieving Chat ID
71
+
72
+
In order for us to send notifications to your Telegram Bot user/channel or group, we need to know their Chat ID.
73
+
74
+
This can be done by fetching the [updates][link-telegram-docs-update] for your Bot using the `getUpdates` method as per Telegram Bot API [docs][link-telegram-docs-getupdates].
75
+
76
+
An [update][link-telegram-docs-update] is an object containing relevant fields based on the type of update it represents, some examples of an update object are `message`, `callback_query`, and `poll`. For a complete list of fields, see [Telegram Bot API docs][link-telegram-docs-update].
77
+
78
+
To make things easier, the library comes with a handy method which can be used to get the updates from which you can parse the relevant Chat ID.
79
+
80
+
Please keep in mind the user has to first interact with your bot for you to be able to obtain their Chat ID which you can then store in your database for future interactions or notifications.
81
+
82
+
Here's an example of fetching an update:
83
+
84
+
```php
85
+
use NotificationChannels\Telegram\TelegramUpdates;
86
+
87
+
// Response is an array of updates.
88
+
$updates = TelegramUpdates::create()
89
+
// (Optional). Get's the latest update. NOTE: All previous updates will be forgotten using this method.
90
+
// ->latest()
91
+
92
+
// (Optional). Limit to 2 updates (By default, updates starting with the earliest unconfirmed update are returned).
0 commit comments