Overview
This node validates third-party initialization data received from a Telegram Web App. It is designed to verify the authenticity and integrity of the initData string that Telegram provides when launching a web app inside its platform. This validation ensures that the data has not been tampered with and originates from the specified Telegram Bot.
Common scenarios where this node is beneficial include:
- Verifying user identity and session data passed from Telegram Web Apps.
- Ensuring secure communication between a Telegram bot and a web application.
- Preventing spoofing or manipulation of Telegram Web App initialization parameters.
For example, a developer building a Telegram Web App can use this node to validate the initData string before processing user information or granting access to protected resources.
Properties
| Name | Meaning |
|---|---|
| Init Data | The raw initialization data string from window.Telegram.WebApp.initData to be validated. |
| Bot ID | Numeric identifier of the Telegram Bot associated with the init data for validation purposes. |
| Is Test Environment | Boolean flag indicating if the init data was received in Telegram's test environment (true/false). |
Output
The node outputs an array with one item per input item. Each output item contains a JSON object with the following structure:
isValid: A boolean indicating whether the provided init data is valid (true) or not.- In case of failure (if "Continue On Fail" is enabled), the output includes an
errorfield with the error message describing why validation failed.
No binary data is produced by this node.
Example successful output JSON:
{
"isValid": true
}
Example error output JSON (when continuing on fail):
{
"error": "Validation failed: invalid signature"
}
Dependencies
- This node depends on an external library specialized in validating Telegram Web App init data.
- Requires the Telegram Bot numeric ID to perform validation.
- No direct API keys or credentials are handled by the node itself, but the Telegram Bot ID must correspond to a valid bot.
- No additional n8n environment variables are required.
Troubleshooting
Common issues:
- Providing malformed or incomplete
initDatastring will cause validation to fail. - Incorrect or missing Bot ID will result in validation errors.
- Using production init data while setting the "Is Test Environment" flag to true (or vice versa) may cause false negatives.
- Providing malformed or incomplete
Error messages:
- Errors typically indicate invalid signatures or corrupted data.
- If the node throws an error, check that the
initDatastring matches exactly what Telegram Web App provides. - Verify that the Bot ID is correct and corresponds to the bot that generated the init data.
- Ensure the "Is Test Environment" flag matches the environment where the init data was obtained.
To handle errors gracefully, enable "Continue On Fail" in the node settings to capture error details in the output without stopping the workflow.