Telegram
Pro PlusEvents Manager ConnectConnect is an add-on included in the Pro Plus plan, with its own license. A Telegram bot is free to create and Telegram doesn't charge for the messages it sends.
With Telegram, your site talks to customers through a bot: an account you create that sends booking notifications and answers when customers tap its buttons. There are no templates to approve, and you write the messages in Connect.
The difference from SMS and WhatsApp is that a bot can't write to someone first. Each customer has to open your bot and share their phone number once. From then on they receive notifications and can manage their bookings in the chat.
- Your site must use HTTPS. Telegram only delivers to HTTPS webhooks, and Connect won't show or save the bot's token on a page loaded over plain HTTP.
- Turn on international phone numbers. Customers are matched to their bookings by phone number when they link. See Phone numbers and consent.
Create a bot with BotFather
BotFather is Telegram's own bot for creating bots.
-
In Telegram, search for
@BotFatherand open the chat. Check for the verified mark. -
Send
/newbot. -
Send a display name for the bot when asked, for example
Maple Bay Events. -
Send a username for the bot. It must be unique and end in
bot, for examplemaplebayevents_bot. -
BotFather replies with the bot's link and its API token, a long string with a colon in it. Keep the token private: anyone who has it can control the bot.
You can set the bot's picture and description later with BotFather's /setuserpic and /setdescription commands. Telegram's BotFather documentation lists everything it can do.
Enter the bot's details in Connect
-
Go to Events then Settings then Connect and open the Telegram box under Connection Settings.
-
Tick Enable Telegram.
-
Enter the bot's username in Bot Name, including the
@, for example@maplebayevents_bot. -
Paste the token from BotFather into Bot API Token.
-
Make up a Webhook Secret Token: a random string of 20 or more letters and digits. Telegram allows letters, digits, underscores and hyphens. You will give the same string to Telegram in the next section.
-
Click Save Changes (All).
The Telegram box. On a site without HTTPS the two token fields are locked, as shown here on the demo site.
| Field | What to enter |
|---|---|
| Enable Telegram | Turns the Telegram transport on. Without it the webhook address doesn't exist and the bot can't answer. |
| Bot Name | The bot's username with the @. Kept for reference. |
| Bot API Token | The token BotFather gave you. Connect uses it for every message it sends. |
| Webhook Secret Token | A secret of your own choosing. Telegram sends it back with each update, and Connect ignores any request that doesn't carry it. A webhook with no secret set is refused. |
| Test Messages | A Telegram User ID field and the Send Test Message button. |
If the token fields are grayed out with the message For your safety we are not displaying sensitive data over an insecure connection, you are viewing wp-admin over HTTP. Switch the site to HTTPS before continuing. Saving the tab in that state stores no token.
Register the webhook with Telegram
Telegram needs to be told where to send your customers' messages. Connect prints the address at the top of the Telegram box:
Your webhook URL to receive responses is https://example.com/wp-json/events-manager/v1/connect/telegram/webhook
Connect 1.0.2 doesn't pass this address to Telegram when you save, so register it yourself. It takes one request to Telegram's API, which you can make from your browser.
-
Build this address in a text editor, replacing the three parts in capitals with your bot token, the webhook URL from your settings screen, and your Webhook Secret Token:
https://api.telegram.org/botYOUR_BOT_TOKEN/setWebhook?url=YOUR_WEBHOOK_URL&secret_token=YOUR_SECRET -
Paste it into your browser's address bar and press Enter. Telegram answers with a short piece of text containing
"ok":trueandWebhook was set. -
To check it at any time, open this address. The answer shows the registered URL and the most recent delivery error, if there was one:
https://api.telegram.org/botYOUR_BOT_TOKEN/getWebhookInfo
Repeat step 1 whenever you change the secret token or move the site to another address. The request is described in Telegram's setWebhook reference.
The address in step 1 contains your bot token. Don't paste it into chats, tickets or screenshots, and clear it from your browser history on a shared computer.
How customers link their account
Give customers your bot's link, https://t.me/ followed by the bot's username without the @. Good places are the booking confirmation email, the booking form's success message, and your event pages.
What the customer sees the first time:
- They open the bot and tap Start.
- The bot answers Hello! This is the Events Management service for and your site address, followed by To begin with, please provide me with your phone number by clicking the button under the reply box below. A Send Phone Number button appears under the message box.
- They tap it and confirm that Telegram may share their number.
- The bot replies Thanks for supplying your phone number, now checking your bookings... and looks for a user account or a guest booking with that phone number.
- If it finds one, the Telegram account is linked, and the bot shows how many upcoming bookings they have with the main menu: View Bookings, Check Again, and Disable Notifications if opting out is allowed.
If no account or booking has that number, the bot answers We cannot find any accounts or bookings registered to this contact method. Nothing is linked. The customer can come back and share their number again after making a booking.
What makes linking work:
- The number in the customer's Telegram account must be the number on their booking or profile, stored in international format.
- The customer needs a Telegram username. Connect recognizes returning customers by username, so someone without one should set one in Telegram's settings before linking.
- Only private chats with real people are answered. In a group, or to another bot, the bot replies that it can only talk to people directly.
Once linked, the customer's username and chat ID are saved with their user account, or with their bookings if they booked as a guest. Notifications and reminders reach linked customers only. A booking made by someone who has never opened the bot produces no Telegram message.
Write the messages
Telegram messages are written in the Telegram boxes under Booking Status Notifications and Booking Reminders. Each status has a Message and a set of Buttons to attach. See Notifications and Reminders for the fields.
Messages can use these HTML tags for formatting, which Telegram supports: <b>, <i>, <u>, <s>, <a href="..."> and <code>. Web page previews are switched off.
The texts the bot uses in conversation, such as the greeting and the button labels, are in the lower part of the Telegram box under Reply Texts, Bookings and Buttons. They are covered in Customer commands.
Test your setup
The Send Test Message button in the Telegram box ends with There was an error, see message console for more info. in Connect 1.0.2 and sends nothing. Test by talking to the bot instead.
- Put your own mobile number on your WordPress user profile, in the Phone (Events Manager) field, in international format. Use the number your Telegram account is registered with.
- Open your bot in Telegram and tap Start.
- Share your number when asked.
- You should see the main menu and a count of your upcoming bookings.
If the bot doesn't answer at all, the webhook isn't reaching your site: open the getWebhookInfo address above and read the error it reports. If it asks for your number but then can't find you, compare the number on your profile with the one in Telegram.
To test a notification, enable a Confirmed message under Booking Status Notifications, then make a booking while logged in as the linked user.