Directory / plugin

Message Bridge for Contact Form 7 and Telegram

v1.2.2 · by iTRON

Deliver Contact Form 7 submissions to Telegram instantly via a bot.

View on WordPress.org

About this plugin

This plugin lets you send Contact Form 7 messages to Telegram chats via a bot. Setup takes just a few steps:

  1. Create a Telegram bot (how to).
  2. Create a bot in the plugin UI.
  3. Paste the bot token into the bot form (PHP constants also available).
  4. Create a bridge in the plugin UI. A bridge links Contact Form 7 forms, a Telegram bot, and one or more Telegram recipients.
  5. Keep the Contact Form 7 CF7 Telegram settings page open while sending the bot’s displayed /cf7tg_start@BotName command as a new standalone message. The page checks Telegram for new recipients. To add a group, first add the bot to the group, then send the command there. To add a forum topic, send it inside that topic. The @BotName suffix addresses the correct bot when Telegram group privacy mode is enabled. The short /cf7tg_start command is still supported when Telegram delivers it to the bot; editing an existing message does not register a recipient.
  6. Approve or decline the subscription requests that appear on the settings page.
  7. Configure the bridge: choose which forms it handles and which Telegram recipients should receive those messages. After approving a topic, select it in each desired bridge; approving it alone does not assign it to bridges. Create at least one bridge to run the integration, and add more when different forms should send messages to different sets of Telegram recipients.

The integration is configured correctly when the bot panel is highlighted in blue and the bridge panel is highlighted in green.

Hooks and constants

Filter wpcf7tg_skip_tg
Use it to skip sending a Telegram message.

Filter wpcf7tg_markdown
Use it to customize the allowed Markdown tags.

Filter wpcf7tg_sendMessage( $args, $chat_id, $mode )
Use it to customize Telegram sendMessage arguments for each recipient and message chunk.

Action wpcf7tg_message_sent( $args, $submission )
Runs after each Telegram delivery attempt. A Telegram failure does not abort the Contact Form 7 submission.

Action wpcf7tg_messages_sent( $list, $output, $mode, $submission )
Runs after all configured recipients have been attempted.

Constant WPCF7TG_LOG_RETENTION_DAYS and filter cf7tg/logRetentionDays
Set the log retention period in days. The default is 30; set it to 0 to disable age-based pruning.

Constant WPCF7TG_LOG_MAX_ROWS and filter cf7tg/logMaxRows
Set the maximum number of newest log rows to retain. The default is 10000.

Constants WPCF7TG_PING_INTERVAL and WPCF7TG_UPDATES_INTERVAL
Set the offline bot status retry interval and the online Telegram update polling interval in milliseconds. The defaults are 5000 and 12000 respectively.

This plugin uses API Telegram and sends remote HTTP requests to Telegram servers to deliver notifications.

Plugin tags