And amid the growing popularity of the messenger, it’s even strange that Telegram comment widgets are not yet often found on websites. Actually, I have never met, so that on a random site from the search to see the opportunity to leave comments via Telegram - I have not met.
Speaking of comments on the site via Telegram, it is worth dividing and clearly defining what exactly we mean.
1. It is possible for the site to organize user authorization on the site via Telegram. Login to the site and can do various things with this account that are available to a registered user of the site - access private sections, send private messages, etc. The Telegram account is actually used for simplified registration on the site. This is one story. And now we will not talk about her.
2. Another story. The site has a comment widget from Telegram, which allows the user of Telegram to leave comments, comments are visible on the page of the site where the widget is placed, while the user uses only his account in Telegram to add a comment, he does not register on the site in any way and does not pass any authorization On him. If the widget with comments is removed from the site page, there will be no trace of users who commented on the site, while the comments themselves may still be present somewhere in the Telegram databases.
In this review, we will consider adding widgets with comments from Telegram described in the second case above.
And here again there is a division into two directions.
1. First option.
It is intended for sites that have their own Telegram channel and send links with their new articles (via a bot or manually) to their channel. If comments are enabled in the Telegram channel settings (there is an attached channel chat), the site administrator can organize the display of these comments under the article on the site.The scheme is as follows: We posted an article on the site, automatically shared it on our channel - channel subscribers got acquainted with the content and comment on the post in the comments on the channel - comments are displayed on the channel in the messenger, where they were added, and comments are displayed on the corresponding page of the site. Through the site, you can also add a comment to this thread, it will appear both on the site and on the channel, but here is an interesting feature. During my tests of this widget, I noticed that from the site I can only add comments on behalf of Telegram channels where I am an admin, but I cannot add a comment on behalf of my personal account.
To add such comments to the site, open the page https://core.telegram.org/widgets/discussion and copy the widget code here.
In the widget code, we change the channel name to the name of our channel and DO NOT specify the post number, the link should lead to the channel, but not to a specific post. If you specify a link to a specific post, it will display comments on the site only to the specified post in Telegram. We need the widget to display comments under telegram posts on each page of the site that contain a link to this particular page. Therefore, in the widget settings, we specify only the name of the channel.
And now, in order for the magic to work and the widget configured for a specific channel, to be able to understand which comments on the channel are associated with this page of the site, one more thing needs to be done.
You need to add a tag in the <head></head> section of the site, where meta tags are displayed
<link rel="canonical" href="page address"/>
In the href="" parameter, specify the address of the current page. How to do this largely depends on what the site is built on. If the site consists of static html pages, you will have to manually add the desired canonical (canonical) address in the source code of each page, if the site is built on a CMS, there may already be some option for displaying the canonical address of the page, and in this case, just add a widget pages.
So, in the widget settings, the address of the channel is indicated, in the page header in the canonical line - the address of the current page is indicated. The widget searches the specified Telegram channel for a post that contains a link to the current page and displays comments on this post in the widget.
If the widget is displayed on a page that is not represented by a link on the specified telegram channel, instead of the form for adding comments, this widget will display a message stating that the discussion on this page is not yet available and the admin will also see a suggestion to place a link to this page on the channel to activate comments.
Demo: Perhaps under this post at the bottom of the page you can find an example of such an implementation, you can scroll and check, if not, then for some reason I changed my mind and removed it. Or you can look at the picture presented as the main poster for this publication. In the picture on the left is the website, on the right is the channel in the telegram. A comment added to telegram is visible on the website on the corresponding page.
During tests of this option, an interesting feature was discovered. If the link to the page was placed on the telegram channel and then removed from there, when you re-add the link to the tg channel (by any means), the comments widget on the page where the link leads does not work. It is enabled only when you first add a link to the tg-channel and is deactivated when removed from the channel without the possibility of recovery. Maybe in the future it will be fixed, but for now it is.
2. The second option.
You can add a Telegram comments widget to the site that will not be associated with publications on the Telegram channel. For this comment widget to work, you do not need to place a link to the page on the telegram channel.To connect the widget, you need to go here: https://comments.app/ and connect your site.
If this is your first time using the Telegram comments web interface, you will need to log in to it (you will receive a notification through the application). Then we go to the site settings and take the widget code.
Before copying the widget code, you should fill in the PAGE ID field - you can enter any characters there so that the PAGE ID parameter simply appears in the widget code.
If there are many pages on the site and add a widget with the same PAGE ID to all or not add it at all, then all pages of the site will have a widget with the same comment thread.
If we want to have a separate discussion under each article on the site, we need to make sure that on each page of the site the widget has a unique value for the PAGE ID parameter.
How exactly to achieve this depends on the site. If the site is on pure html, change the PAGE ID for each page (any set of Latin letters and numbers without spaces). For example, the pages of your site are generated by software, in php you can do this:
$upid = md5($_SERVER['REQUEST_URI']);
data-page-id="<?php echo $upid; ?>"
i.e. like this:
<?php $upid = md5($_SERVER['REQUEST_URI']); ?>
<script async src="https://comments.app/js/widget.js?3" data-comments-app-website="3rp_kS4a" data-limit="5" data-page-id="<?php echo $upid; ?>"></script>
*data-comments-app-website= - here you should have another meaning not
In this case, we pass the md5 hash obtained from the address of the current page without a domain to the PAGE id parameter. I used md5 encryption to avoid the possibility of getting into the PAGE ID some unwanted characters that may be contained in the page address and are not suitable for the PAGE ID. The characters that md5() gives out are exactly right and the id will be unique for each page - how unique within the site is its address.
After that, on the pages of the site where such a widget is added, a comment form from Telegram appears.
How to add a comment on a website using a Telegram account
So, if the site has a Telegram comments widget, a site visitor with an account in the messenger can add comments without registering on the site.If a Telegram user uses this feature for the first time through this browser, he will be prompted to log in to the https://comments.app/ system from Telegram - this does not mean registration or authorization on the site where the widget is placed, no sensitive information about the user is transmitted to the site . At the same time, the comment will be public, the username in Telegram will be visible, and anyone will be able to open the commentator's profile in Telegram by clicking on his profile picture.
If the user is already authorized in comments.app Telegram, he can add a comment through the widget without registering on the site and, if such an option is left in the widget settings, upload an image.
If another participant in the discussion in this thread contacts the user, responds to his comment, the user will receive a notification through the bot in the Telegram application itself and will be able to return to the website page to respond.
Widget site administrator can moderate comments, remove unwanted comments, delete all comments of a certain user and ban users, the main widget site admin can appoint other moderators to moderate comments on this site.
Publications on the topic "development, webmaster's workshop" are not the main and even predominant on this site. Therefore, perhaps the next time will not be very soon. But, if and when there is a mood to write in this direction, I think it will be a series of tips on creating a Telegram bot for the site and on the topic of creating PWA applications for the site.