BaleMessenger icon

BaleMessenger

Interact with Bale Messenger API

Overview

This node integrates with the Bale Messenger API, enabling users to perform a wide range of messaging and chat management operations programmatically within n8n workflows. It supports sending various message types (text, media, contacts, locations), editing messages, managing chats (e.g., banning/unbanning members, getting chat info), handling callback queries, processing payments via invoices, and managing stickers.

Common scenarios include automating customer support conversations, broadcasting messages or notifications, managing group chats, responding to inline keyboard interactions, and facilitating payment requests through chat.

For example:

  • Sending a text message with a custom reply keyboard to guide user responses.
  • Editing an existing message's text based on workflow logic.
  • Answering callback queries triggered by inline keyboard buttons.
  • Sending invoices for product purchases directly in chat.
  • Managing chat members by banning or unbanning users.

Properties

Name Meaning
Reply Keyboard Adds a custom keyboard with reply options. You can define multiple rows, each containing multiple buttons with text labels.
Reply Keyboard Remove Options to remove the custom keyboard from the client interface, including whether to remove it selectively for specific users.

Additional key input properties relevant to the default operation include:

Name Meaning
chatId Unique identifier for the target chat where messages or actions are performed.
text Text content of the message to send or edit.
replyMarkup Additional interface options for messages, such as inline keyboards, reply keyboards, or removing keyboards.
replyToMessageId If replying to a message, the ID of the original message.
binaryData Boolean indicating if the file data should be taken from a binary field in the input data.
binaryPropertyName Name of the binary property containing the data to upload when sending files or stickers.
fileId Identifier of a file already stored on Bale servers to reuse without uploading again.
caption Caption text for media messages (photos, videos, audio, etc.).
phone_number Phone number of a contact to send.
first_name First name of the contact to send.
last_name Last name of the contact to send.
latitude Latitude coordinate for location messages.
longitude Longitude coordinate for location messages.
horizontal_accuracy Accuracy radius for location messages.
action Type of chat action to broadcast (e.g., typing, uploading photo).
messageId Unique identifier of a message to delete, copy, forward, or edit.
fromChatId Chat ID where the original message was sent (for copying or forwarding).
queryId Unique identifier for callback queries to answer.
results JSON-serialized array of results for answering inline queries.
additionalFields Additional optional parameters for certain operations like answering queries or sending media.
prices List of price objects for invoices, each with label and amount.
providerToken Payment provider token for sending invoices.
title Title for invoices or sticker sets.
description Description for invoices.
payload Internal payload string for invoices.
photoUrl URL of product image for invoices.
userId User identifier for sticker set operations or chat member management.
name Name of sticker set.
stickerId Sticker file identifier to send.

Output

The node outputs an array of items corresponding to each input item processed. Each output item contains:

  • json: The main response data from the Bale Messenger API call, which varies depending on the operation. For example:
    • Message send/edit operations return message details.
    • Chat operations return status or chat information.
    • Callback query answers return success status.
    • Invoice sends return invoice details.
  • binary: Usually empty unless the operation involves uploading or downloading files/stickers, in which case binary data may be included.
  • pairedItem: References the index of the input item that generated this output.

If the node handles binary uploads (e.g., sending photos, documents, stickers), it expects the binary data to be provided in the specified binary property of the input item.

Dependencies

  • Requires an API authentication token credential for Bale Messenger API access.
  • Uses the official node-telegram-bot-api library configured to communicate with Bale Messenger endpoints.
  • Uses axios for HTTP requests to Bale Messenger API.
  • Requires proper configuration of credentials in n8n to authenticate API calls.

Troubleshooting

  • Invalid JSON in Inline Query Results: When answering inline queries, the results parameter must be valid JSON. Invalid JSON will cause errors; ensure correct formatting.
  • Missing Required Parameters: Operations require specific parameters (e.g., chatId, messageId). Missing these will cause failures.
  • Binary Data Issues: When sending files or stickers using binary data, ensure the binary property name is correctly set and the input item contains valid binary data.
  • API Errors: Network issues or invalid tokens will result in API call failures. Check API credentials and network connectivity.
  • Error Messages: The node logs detailed error messages from the API response. Review these logs to identify issues such as permission errors or invalid parameters.

Links and References

Discussion