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 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. |
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 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 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. |