• Features
  • API Docs
  • Help Center
  • Log in
  • Sign Up
  • Features
  • API Docs
  • Help Center
  • Log in
  • Sign Up

Telegram Bot Subscription with JS API

462 views September 16, 2020 0

To generate а Telegram bot one-click subscription link on your website, you need to properly identify your user and fire an event on your web page.

IMPORTANT Include those snippets on every page in your app, immediately before the closing </body> tag to initialize JS API and identify your user.

Connecting the library:

<script type="text/javascript" src="//js.smartsender.io/js/v1/JS_SCRIPT_ID.js>

</script>

Contact identificator:

<script type="text/javascript">

    var contact = new_smartSenderContact('{{identifier}}');

</script>
Parameters
new_smartSenderContact();
'required'
Call Web Push Notification One-click Subscription Prompt on any page or by user action.
contact
'required'
Minimum one unique user identificator (userId | email | phoneNumber) is required to identify and match the user in Contact List.

Step-by-step instructions:

  • Install JS API
  • Get your Telegram Bot ID
  • Add a subscription link to the button. Your button should have a specific element id <a id="some-url-id">Click here to Subscribe to Telegram </a>, where you need to generate a Telegram Bot subscription link.
  • Call the “Generate telegram subscription link” API method
<script type="text/javascript" src="//js.smartsender.io/js/v1/JS_SCRIPT_ID.js></script>
<script>var contact = new_smartSenderContact('user@example.com');></script>
<script type="text/javascript"> 
    contact.CreateTelegramSubscriptionLink(
        '{{domElementId}}', 
        '{{telegramBotId}}'
    );
</script>
Parameters
CreateTelegramSubscriptionLink();
'required'
Call Web Push Notification One-click Subscription Prompt on any page or by user action.
domElementId;
'required'
HTML element id where the unique Telegram Bot subscription link should be generated.
telegramBotId;
'required'
Telegram Bot ID which you can get from SmartSender Telegram integration page.
IMPORTANT The function returns a Promise object and runs asynchronously
Your button should have specific element id <a id="some-url-id">Click here to Subscribe to Telegram</a>, where you need to generate a Telegram Bot subscription link. Learn more by link.
Similar posting
  • Integration with Mailchimp
  • Zapier Integration
  • JS API methods
  • How to set an avatar for a Telegram bot
  • Add contact manually
  • Web Push Prompt Settings in JS
Company
  • About us
  • Team
Legal
  • Terms of Use
  • Privacy Policy
  • Anti-Spam Policy
  • Cookie Statement
Resources
  • Api Documentation
  • FAQ
  • Knowledge Base
  • SmartSender Blog
  • Marketplace

We use cookies to make SmartSender’s website a better place. Cookies help to provide a more personalized experience for you, and web analytics for us. To learn more, and to see a full list of cookies we use, check out our Cookie Policy (baked goods not included).

got it