Forge
markdown1a59f514
1# Detailed Guide for Configuring appsettings.json
2
3## Overview
4
5Your application uses **WTelegramClient** to work with Telegram API, which means it operates as a regular Telegram application, not as a bot. This requires obtaining API keys from Telegram for developers.
6
7## appsettings.json Structure
8
9Your `appsettings.json` file should contain the following settings:
10
11```json
12{
13 "TelegramSettings": {
14 "API_ID": "your_api_id",
15 "API_HASH": "your_api_hash",
16 "AccountPhone": "+7XXXXXXXXXX",
17 "SessionPathName": "session.session",
18 "LogFileName": "telegram.log"
19 }
20}
21```
22
23## Step-by-Step Guide to Get API Keys
24
25### Step 1: Register on my.telegram.org
26
271. Open your browser and go to [https://my.telegram.org](https://my.telegram.org)
282. Log in to your Telegram account using your phone number and verification code
293. If you don't have a Telegram account, first register in the Telegram app
30
31### Step 2: Create an Application
32
331. After logging into my.telegram.org, click on **"API development tools"**
342. Click **"Create new application"**
353. Fill out the form:
36 - **App title**: Your application name (e.g., "TelegramNotifier")
37 - **Short name**: Short name (e.g., "tnotifier")
38 - **Platform**: Select "Desktop"
39 - **Description**: Application description (e.g., "Telegram notifications")
40 - **URL**: You can leave empty or specify your project URL
414. Click **"Create application"**
42
43### Step 3: Get API Keys
44
45After creating the application, you will receive:
46- **API ID** - numeric identifier (e.g., 12345678)
47- **API Hash** - 32-character string (e.g., "abcdef1234567890abcdef1234567890")
48
49### Step 4: Configure appsettings.json
50
51Replace the values in your `appsettings.json` file:
52
53```json
54{
55 "TelegramSettings": {
56 "API_ID": "12345678",
57 "API_HASH": "abcdef1234567890abcdef1234567890",
58 "AccountPhone": "+79123456789",
59 "SessionPathName": "session.session",
60 "LogFileName": "telegram.log"
61 }
62}
63```
64
65## Parameter Description
66
67| Parameter | Description | Example |
68|-----------|-------------|---------|
69| `API_ID` | Your application ID from my.telegram.org | `12345678` |
70| `API_HASH` | Your application hash from my.telegram.org | `abcdef1234567890abcdef1234567890` |
71| `AccountPhone` | Telegram account phone number in international format | `+79123456789` |
72| `SessionPathName` | Session file name for saving (created automatically) | `session.session` |
73| `LogFileName` | Log file name | `telegram.log` |
74
75## Important Notes
76
77### Security
78- **DO NOT SHARE** API_ID and API_HASH with others
79- **DO NOT PUBLISH** this data publicly
80- Add `appsettings.json` to `.gitignore` if you plan to use Git
81
82### First Run
83On the first application run:
841. You will receive a verification code in Telegram
852. Enter this code in the console
863. If two-factor authentication is enabled, enter the password
874. Session will be saved to `session.session` file
88
89### Session File
90- The `session.session` file contains authorization data
91- **DO NOT DELETE** this file, otherwise you'll need to re-authorize
92- This file is tied to a specific account and device
93
94## Example of Complete appsettings.json
95
96```json
97{
98 "TelegramSettings": {
99 "API_ID": "12345678",
100 "API_HASH": "abcdef1234567890abcdef1234567890",
101 "AccountPhone": "+79123456789",
102 "SessionPathName": "session.session",
103 "LogFileName": "telegram.log"
104 }
105}
106```
107
108## Configuration Verification
109
110After configuration, run the application without parameters to verify:
111
112```bash
113./TelegramNotifier.exe
114```
115
116If the settings are correct, you will see the application usage instructions.
117
118## Troubleshooting
119
120### Error "PHONE_NUMBER_INVALID"
121- Check phone number format (should include country code, e.g., +7)
122- Ensure the number is registered in Telegram
123
124### Error "API_ID_INVALID" or "API_HASH_INVALID"
125- Check the correctness of copied API_ID and API_HASH
126- Ensure the application was created on my.telegram.org
127
128### Error "SESSION_PASSWORD_NEEDED"
129- Two-factor authentication is enabled
130- Enter your Telegram account password
131
132## Additional Information
133
134- API keys are tied to your Telegram account
135- One account can create multiple applications
136- If you delete the application on my.telegram.org, API keys will become invalid
137- For production, it's recommended to use a separate Telegram account
138
139## Application Usage
140
141After successful configuration, you can use the following commands:
142
143```bash
144# Send message to chat
145./TelegramNotifier.exe send-message-to-chat 840666093 "This is a programmatically sent message"
146
147# Create chat
148./TelegramNotifier.exe create-chat testChat username
149
150# Delete chat
151./TelegramNotifier.exe delete-chat 840666093
152
153# Get messages from chat
154./TelegramNotifier.exe get-messages 840666093
155
156# Delete user from chat
157./TelegramNotifier.exe delete-user-from-chat 979115881 username
158
159# Invite user to chat
160./TelegramNotifier.exe invite-user 979115881 username
161
162# Send message to user
163./TelegramNotifier.exe send-message-to-user username "This is a programmatically sent message"
164```
165
166## Privacy Settings
167
168If user privacy settings ban invites or messages, you'll be notified in the console with appropriate error messages.
169
View only · write via MCP/CIDE