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.
|
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:
|
In the n8n web interface:
|
||||||
|
|
||||||
**Telegram API credential:**
|
|
||||||
|
|
||||||
1. Go to Settings > Credentials > Add Credential
|
1. Go to Settings > Credentials > Add Credential
|
||||||
2. Search for "Telegram API"
|
2. Search for "Telegram API"
|
||||||
3. Name: `Telegram API`
|
3. Name: `Telegram API`
|
||||||
4. Access Token: paste your bot token from @BotFather
|
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
|
### 3. Import Workflow
|
||||||
|
|
||||||
1. Download `n8n-workflow.json` from this repository
|
1. Download `n8n-workflow.json` from this repository
|
||||||
2. In n8n: Workflows > Import from File
|
2. In n8n: Workflows > Import from File
|
||||||
3. Select `n8n-workflow.json`
|
3. Select `n8n-workflow.json`
|
||||||
4. When prompted, map credentials:
|
4. When prompted, map the `Telegram API` credential
|
||||||
- `Telegram API` -> your Telegram API credential
|
|
||||||
- `Telegram Auth` -> your Telegram Auth credential
|
|
||||||
|
|
||||||
### 4. Activate Workflow
|
### 4. Configure Your User ID
|
||||||
|
|
||||||
1. Open the imported workflow in n8n
|
The workflow only responds to your Telegram user ID. To set it:
|
||||||
2. Click the "Active" toggle in the top-right corner
|
|
||||||
3. Test by sending "status" to your bot in Telegram
|
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
|
## Usage
|
||||||
|
|
||||||
@@ -88,7 +86,7 @@ Send `/start` or any unrecognized text to display the persistent keyboard with q
|
|||||||
|
|
||||||
## Security
|
## 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
|
## License
|
||||||
|
|
||||||
|
|||||||
+4
-16
@@ -100,7 +100,7 @@
|
|||||||
{
|
{
|
||||||
"id": "user-auth-condition",
|
"id": "user-auth-condition",
|
||||||
"leftValue": "={{ $json.message.from.id.toString() }}",
|
"leftValue": "={{ $json.message.from.id.toString() }}",
|
||||||
"rightValue": "={{ $credentials.telegramAuth.userId }}",
|
"rightValue": "563878771",
|
||||||
"operator": {
|
"operator": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"operation": "equals"
|
"operation": "equals"
|
||||||
@@ -118,13 +118,7 @@
|
|||||||
"position": [
|
"position": [
|
||||||
680,
|
680,
|
||||||
200
|
200
|
||||||
],
|
]
|
||||||
"credentials": {
|
|
||||||
"telegramAuth": {
|
|
||||||
"id": "telegram-auth-credential",
|
|
||||||
"name": "Telegram Auth"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"parameters": {
|
"parameters": {
|
||||||
@@ -138,7 +132,7 @@
|
|||||||
{
|
{
|
||||||
"id": "callback-auth-condition",
|
"id": "callback-auth-condition",
|
||||||
"leftValue": "={{ $json.callback_query.from.id.toString() }}",
|
"leftValue": "={{ $json.callback_query.from.id.toString() }}",
|
||||||
"rightValue": "={{ $credentials.telegramAuth.userId }}",
|
"rightValue": "563878771",
|
||||||
"operator": {
|
"operator": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"operation": "equals"
|
"operation": "equals"
|
||||||
@@ -156,13 +150,7 @@
|
|||||||
"position": [
|
"position": [
|
||||||
680,
|
680,
|
||||||
500
|
500
|
||||||
],
|
]
|
||||||
"credentials": {
|
|
||||||
"telegramAuth": {
|
|
||||||
"id": "telegram-auth-credential",
|
|
||||||
"name": "Telegram Auth"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"parameters": {
|
"parameters": {
|
||||||
|
|||||||
Reference in New Issue
Block a user