Actions12
Overview
The node provides integration with the Telegram Client API, enabling various messaging and chat management operations within Telegram. Specifically, the Search Messages operation allows users to search for messages containing specific text within a given chat or channel.
This node is beneficial in scenarios where you need to programmatically retrieve messages matching certain criteria from Telegram chats, such as monitoring conversations for keywords, extracting relevant information, or automating responses based on message content.
Practical example:
You want to find all messages mentioning "urgent" in a support channel to prioritize customer issues. Using this node's Search Messages operation, you specify the chat ID and the query "urgent" to fetch those messages automatically.
Properties
| Name | Meaning |
|---|---|
| Chat ID | The identifier of the chat or channel to search in. Can be a numeric ID (e.g., -100xxxx) or username (e.g., @username). |
| Search Query | The text string to search for within the messages of the specified chat. |
| Options | Additional optional parameters: • Silent: Send messages silently without notification (not applicable for search). • Caption: Caption for media messages (not applicable for search). • Parse Mode: How to parse message text (none, markdown, html) (not applicable for search). • Limit: Maximum number of messages to return (default 100). |
Note: For the Search Messages operation, only Chat ID, Search Query, and the Limit option are relevant.
Output
The output JSON contains:
success: Boolean indicating if the search was successful.messages: An array of message objects matching the search query. Each message object includes details such as message ID, date, sender info, and message content.
Example output snippet:
{
"success": true,
"messages": [
{
"id": 12345,
"date": "2024-06-01T12:34:56Z",
"message": "Sample message containing the search query",
...
},
...
]
}
No binary data is output by this operation.
Dependencies
- Requires an active Telegram client session authenticated via API credentials (API ID and API Hash).
- Needs a valid API key credential configured in n8n for authentication.
- Uses the Telegram Client API through a library bundled as
TelegramClient. - Network access to Telegram servers is required.
Troubleshooting
Common issues:
- Missing or invalid API credentials will cause authentication failure.
- Incorrect chat ID or username may result in no messages found or errors.
- Exceeding Telegram API limits might cause rate limiting or temporary failures.
- Network connectivity problems can prevent connection to Telegram servers.
Error messages:
"No credentials provided": Ensure that the API credentials are properly set up in n8n."Operation "searchMessages" is not supported": Verify that the operation name is correctly specified.- Authentication failures typically indicate invalid API ID/Hash or expired sessions.
- Errors during message retrieval often relate to invalid chat IDs or insufficient permissions.
Resolution tips:
- Double-check API credentials and refresh them if necessary.
- Confirm the chat ID or username is correct and accessible by the authenticated user.
- Use smaller limits to avoid hitting API rate limits.
- Enable "Continue On Fail" in n8n to handle individual item errors gracefully.