fix(05-02): revert credential reference to hardcoded user ID
n8n IF nodes don't support credentials - $credentials syntax only works in nodes that make external calls. Reverted to direct user ID in the IF conditions and updated README with simpler configuration instructions. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -33,39 +33,37 @@ docker run -d \
|
||||
|
||||
If using Unraid's Community Applications, add these to the "Extra Parameters" and "Path" sections of your n8n container template.
|
||||
|
||||
### 2. Create n8n Credentials
|
||||
### 2. Create Telegram API Credential
|
||||
|
||||
In the n8n web interface, create two credentials:
|
||||
|
||||
**Telegram API credential:**
|
||||
In the n8n web interface:
|
||||
|
||||
1. Go to Settings > Credentials > Add Credential
|
||||
2. Search for "Telegram API"
|
||||
3. Name: `Telegram API`
|
||||
4. Access Token: paste your bot token from @BotFather
|
||||
|
||||
**Telegram Auth credential:**
|
||||
|
||||
1. Go to Settings > Credentials > Add Credential
|
||||
2. Search for "Header Auth"
|
||||
3. Name: `Telegram Auth`
|
||||
4. Header Name: `userId`
|
||||
5. Header Value: your Telegram user ID (numeric, e.g., `123456789`)
|
||||
|
||||
### 3. Import Workflow
|
||||
|
||||
1. Download `n8n-workflow.json` from this repository
|
||||
2. In n8n: Workflows > Import from File
|
||||
3. Select `n8n-workflow.json`
|
||||
4. When prompted, map credentials:
|
||||
- `Telegram API` -> your Telegram API credential
|
||||
- `Telegram Auth` -> your Telegram Auth credential
|
||||
4. When prompted, map the `Telegram API` credential
|
||||
|
||||
### 4. Activate Workflow
|
||||
### 4. Configure Your User ID
|
||||
|
||||
1. Open the imported workflow in n8n
|
||||
2. Click the "Active" toggle in the top-right corner
|
||||
3. Test by sending "status" to your bot in Telegram
|
||||
The workflow only responds to your Telegram user ID. To set it:
|
||||
|
||||
1. Open the imported workflow
|
||||
2. Find the **IF User Authenticated** node
|
||||
3. Click to edit, find the condition with `rightValue`
|
||||
4. Change `563878771` to your Telegram user ID
|
||||
5. Repeat for **IF Callback Authenticated** node
|
||||
6. Save the workflow
|
||||
|
||||
### 5. Activate Workflow
|
||||
|
||||
1. Click the "Active" toggle in the top-right corner
|
||||
2. Test by sending "status" to your bot in Telegram
|
||||
|
||||
## Usage
|
||||
|
||||
@@ -88,7 +86,7 @@ Send `/start` or any unrecognized text to display the persistent keyboard with q
|
||||
|
||||
## Security
|
||||
|
||||
The bot only responds to the Telegram user ID configured in the "Telegram Auth" credential. Messages from other users are silently ignored.
|
||||
The bot only responds to the Telegram user ID configured in the IF nodes. Messages from other users are silently ignored.
|
||||
|
||||
## License
|
||||
|
||||
|
||||
+4
-16
@@ -100,7 +100,7 @@
|
||||
{
|
||||
"id": "user-auth-condition",
|
||||
"leftValue": "={{ $json.message.from.id.toString() }}",
|
||||
"rightValue": "={{ $credentials.telegramAuth.userId }}",
|
||||
"rightValue": "563878771",
|
||||
"operator": {
|
||||
"type": "string",
|
||||
"operation": "equals"
|
||||
@@ -118,13 +118,7 @@
|
||||
"position": [
|
||||
680,
|
||||
200
|
||||
],
|
||||
"credentials": {
|
||||
"telegramAuth": {
|
||||
"id": "telegram-auth-credential",
|
||||
"name": "Telegram Auth"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
@@ -138,7 +132,7 @@
|
||||
{
|
||||
"id": "callback-auth-condition",
|
||||
"leftValue": "={{ $json.callback_query.from.id.toString() }}",
|
||||
"rightValue": "={{ $credentials.telegramAuth.userId }}",
|
||||
"rightValue": "563878771",
|
||||
"operator": {
|
||||
"type": "string",
|
||||
"operation": "equals"
|
||||
@@ -156,13 +150,7 @@
|
||||
"position": [
|
||||
680,
|
||||
500
|
||||
],
|
||||
"credentials": {
|
||||
"telegramAuth": {
|
||||
"id": "telegram-auth-credential",
|
||||
"name": "Telegram Auth"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
|
||||
Reference in New Issue
Block a user