Actions12
Overview
The node implements a Telegram client that interacts with the Telegram API to perform various chat-related operations. 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 or channels. For example, it can be used to:
- Search for customer support queries containing keywords.
- Extract messages related to a particular topic or event.
- Automate monitoring of chat content for compliance or moderation.
Practical example: You want to find all messages mentioning "urgent" in a project management group chat to trigger follow-up actions.
Properties
| Name | Meaning |
|---|---|
| Chat ID | The identifier or username of the chat/channel to search in (e.g., @username or -100xxxx). |
| Search Query | The text string to search for within the messages of the specified chat. |
| Options | Additional optional parameters: - Silent: Send message silently without notification (not relevant for search). - Caption: Caption for media messages (not relevant for search). - Parse Mode: How to parse message text ( none, markdown, html) (not relevant 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 returned by the Telegram API that match the search query within the specified chat.
Each message object includes details such as message ID, date, sender, content, and other metadata as provided by the Telegram API.
No binary data is output by this operation.
Example output snippet:
{
"success": true,
"messages": [
{
"id": 12345,
"date": "2024-06-01T12:34:56Z",
"message": "Sample message containing the search text",
...
},
...
]
}
Dependencies
- Requires an active Telegram API session authenticated via credentials including an API ID, API hash, and a session string.
- Uses the Telegram Client SDK internally to connect and interact with Telegram's API.
- Requires proper n8n credential configuration to provide these authentication details securely.
Troubleshooting
- No credentials provided: The node will throw an error if the required Telegram API credentials are missing. Ensure credentials are configured correctly in n8n.
- Connection issues: Network problems or invalid API credentials may cause connection failures. Verify network access and credential validity.
- Operation not supported: If an unsupported operation name is provided, the node throws an error. Confirm the operation parameter is set to "searchMessages".
- Empty results: If no messages match the search query, the
messagesarray will be empty. Try broadening the search query or increasing the limit. - Rate limits: Excessive requests to Telegram API might lead to rate limiting. Implement retries or reduce request frequency.