Telegram is an easy to use free chat application that is rapidly winning fans all over the world.
There is a Telegram plugin for WordPress but there is not yet a Telegram module for Drupal.
Step #1. Create a Telegram Account
If you don’t have a Telegram account yet, you’ll have to create one. The process is pretty straightforward. Download the Telegram app to your smartphone and activate an account with your mobile phone number.
- Allow Telegram to receive and make phone calls and send SMS messages.
- Enter your phone number and the code provided by Telegram.
- Allow Telegram to access pictures and contacts and you’re good to go.
- Open your web browser and web.telegram.org in the address bar.
- Choose your country, type your phone number.
- Click Next.
- Click Ok.
- Copy the code you received on your phone.
- Go to https://telegram.me/ReplainBot.
- Click OPEN IN WEB.
- Click Start.
- Follow the instructions.
- Click Menu.
- Click Connect the site ("Connectar el sitio" on my screenshot below).
- Create a name for your chat room, for example, “Customer Support”.
- Enter a description and a welcome message for your “Customers”.
- Choose the default widget language in the site (i.e. English).
- Your chat room is created.
The code has to be inserted into a page before the closing
</body> tag. That means the JS code has to be inserted into the html.html.twig template.
The theme I’m using is the default Bartik. For demonstration purposes, I’m going to use the default core template. However, this is not a best practice.
The right way of doing this is creating a Bartik subtheme, copying the template inside the new theme and modifying it there.
You can read more about creating a subtheme here.
- Locate the core/themes/classy/templates/layout/html.html.twig file.
- As you can see, Classy is the base theme for Bartik.
- Open the file in your text editor and paste the script right before the closing tag.
- Save the file.
- Clear the site cache. You’ll see the Telegram icon at the bottom right corner of your screen.
Good job! We haven’t installed any Drupal module, that’s the reason why you’re seeing the Telegram icon even in your administrative pages. These make use of the html.html.twig template as well.
- Open another browser and test the chat as an anonymous user.
- The system will prompt you to introduce your contact data - this is a Telegram answering template. You can configure your templates in the Telegram web application or in your phone.
- I can read and answer to the message in my cell phone.
Step #4 - Change the Logo of the Chat Window
- In your web/mobile Telegram application click Menu > Customer Support (or whatever you named your channel). You have a bunch of options here. They’re pretty self-explanatory.
- Tap/Click Edit logo.
- Click the Camera icon in order to upload a picture.
- Refresh your Drupal site.
- There’s the logo.
Feel free to explore the different configuration options available.
Telegram has an extensive documentation about how to customize and enhance the functionality of your chats with the help of bots, that perform different tasks.
As you already noticed, this method is useful for any type of site, not just Drupal sites.