Saturday 25 April 2020

Integrate Salesforce with Telegram to Engage with Customers

11

As a business, it is very important to connect with customers in the way they like. Customer can prefer Email, Phone, or their favorite messaging application.




While there are countless messaging applications in the market, one of the popular messaging application is Telegram. And as a developer, what particularly I like about the app it there easy to use API with minimal configurations needed.

So today, we will be implementing a solution to allow the Sales and Marketing team to push messages to Customers and also how the Salesforce administrator can create Automation to send updates to Customer Inbox.


1. First, we need to set up a Telegram bot, which will be the front face of our business to the customer.
Registering a Bot is way easy then you might think via another bot named “BotFather”. Navigate to the bot using this link https://telegram.me/botfather and create a bot using /newbot command. You will instantly get the Bot URL and API key needed.





2. Now lets setup the Salesforce, so we can connect with customers through the bot. When a customer navigates to our bot and selects /start command, we get a new message event with the Chat ID. We need to capture this ID in Salesforce so we can use it later to send messages just like we store Email/phone.
For this, we need to set up a webhook listener, to capture user events and create/update Contact with the Telegram User ID/ Chat ID (Same in one to one conversion).




This Webhook service will be now updating the contact if found with the User telegram ID or will create a new contact when a new message is received. 
For this to work, we need to register this webhook for our bot. This can be done by a GET request to the below URL.


Now send a message to your bot, (in our case http://t.me/SFNotifiyBot) and a new contact should be created in Salesforce.



Now that, we have Telegram ID of the customers in the Telegram_User_ID__c field on Contact. We can send them messages. But now we need to provide a way to the Sales and Marketing team to send messages and Salesforce administrators to create an automation process to send messages.

Sales and Marketing team solution

For them, we will build a custom Lightning component and place it on the Contact Record page, though this Sales and Marketing team can send messages directly without any efforts.





Salesforce administrator (Automated solution)

Every organization have various automation process to keep the customer updated about the events happening related to the customer, for example, an e-commerce business might have automation to send a notification to customer when their Order is shipped or Banking business might have a notification for Debit/credit transactions. 
For the automation, we will be using the Lightning Process builder with an Invocable method to process and send messages over Telegram.
So let’s first get the Invocable class ready. You can get the code from the GIT repo mentioned at the end of the article.




Now we can proceed to create a Process builder according to the business requirement.
In our case, we will send a message notification to the customer when their Email Address is updated.




Now let’s update the email and test!


Using the Process builder, we can now create various custom notifications on events without any hassle.



Other points:
  1. You need to add Telegram API to Remote Site settings in Salesforce. From Setup, enter Remote Site Settings in the Quick Find box, then select Remote Site Settings and add https://api.telegram.org
  2. You need to create a custom label with API Name Telegram_Bot_API_key with your telegram bot API key.
  3. Create a field Telegram_User_ID__c (Number — 18,0) on Contact.


You can find the code in the git repo below. Please note the code is for demonstration purposes. Error handling is not implemented properly.


For more description of the Bot API, see this page: https://core.telegram.org/bots/api

11 comments:

  1. Great blog.you put Good stuff.All the topics were explained briefly.so quickly understand for me.I am waiting for your next fantastic blog.Thanks for sharing.Any coures related details learn...
    Help Desk app

    ReplyDelete
  2. You have shared a magnificent post about telegram. I think your blog is very useful for us. Thank you for providing such an informative post.Buy Real active Telegram Members

    ReplyDelete
  3. Techforce services is a Salesforce Consulting Services in Australia Specializing in delivering end to end Salesforce solutions ,Consulting, Implementation DevOps partners in Australia We deliver applications and services more rapidly and reliably, but it’s more than a methodology – it cuts to the very core. Salesforce Data Analytics let us help you become a data driven organization and ensure your data is working hard for your business, This includes implemention
    Salesforce consulting companies
    Salesforce top partners
    Staff augmentation companies
    Salesforce DevOps services
    Salesforce integration companies
    Salesforce Implementation services
    Salesforce Health Check
    Salesforce DevOps
    Managed project services

    ReplyDelete
  4. This comment has been removed by the author.

    ReplyDelete
  5. I generally check this kind of article and I found your article which is related to my interest. Genuinely, it is good and instructive information about social media reseller panel. Thanks for sharing an amazing article here.

    ReplyDelete
  6. Took me time to read all the comments, but I really enjoyed the article. It proved to be Very helpful to me and I am sure to all the commenters here! It’s always nice when you can not only be informed, but also entertained! telegram group links

    ReplyDelete
  7. Very good, This information is essential and informative which you have shared here. It is beneficial for beginners to develop their knowledge. buy telegram members with bitcoin It is very gainful information. Thanks for share it.

    ReplyDelete
  8. Excellent you have provided important data for us. It is essential and informative for everyone. smm panel india Keep posting always. I am very thankful to you.

    ReplyDelete
  9. Wow! Such an amazing and helpful post this is. I really really love it. It's so good and so awesome. I am just amazed. I hope that you continue to do your work like this in the future also Smmpanel

    ReplyDelete
  10. You've written a very useful article. This article provided me with some useful knowledge. Thank you for providing this information. Keep up the good work. cheap indian smm panel

    ReplyDelete
  11. Great article, thank you for sharing. When I tried to test the RestResource url, it return errorcode Not Found, could find a match url. I wonder where did I do wrong...

    ReplyDelete