September 16, 2020

Telegram Bot Subscription with JS API

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.wooxy.com/js/v2/JS_SCRIPT_ID.js" charset="UTF-8">

</script>
            

Contact identificator:

                <script type="text/javascript">

    let contact = new _wooxyContact('{{identifier}}');

</script>
            
Parameters
new_smartSenderContact();
'required'
Call Telegram bot 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.
Telegram bot integration

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.wooxy.com/js/v1/JS_SCRIPT_ID.js></script>

let contact = new _wooxyContact('{{identifier}}');</script>

<script type="text/javascript">

     contact.CreateTelegramSubscriptionLink(

         '{{domElementId}}',

         '{{telegramBotId}}'

     );

</script>
            
Parameters
CreateTelegramSubscriptionLink();  
'required'
Call Telegram bot 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 Wooxy 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.