How to Set Up a Telegram Bot for Lead Notifications

Navigating the landscape of customer relationship management can be a complex task, especially when it comes to efficiently handling new leads. In this guide, we’re taking a deep dive into a cutting-edge solution that marries the simplicity of Telegram notifications with the robust capabilities of Zoho CRM. Our focus? To show you exactly how we set up a system to channel New Lead notifications into two separate Telegram channels, each designated for leads based on their geographical region.

This method not only elevates the speed at which you receive lead information but also organizes it in a way that allows for regional specificity in your follow-up strategies. By the end of this guide, you’ll have a clear understanding of how to leverage these tools to ensure that every new lead, whether from the East or the West, is promptly and efficiently managed.

Step by step, we’ll walk you through the entire process – from setting up your Telegram bot to crafting a Zoho CRM workflow that filters and dispatches lead information seamlessly. Get ready to transform the way you interact with your leads and give your response strategy a significant upgrade.

Let’s begin the journey to smarter lead management.

Step 1: Create Your Telegram Bot

Download and Install Telegram: If you haven’t already, download and install the Telegram app on your device from the App Store or Google Play Store.

Start a Chat with BotFather: BotFather is the official bot that helps you create and manage Telegram bots. In the Telegram app, search for ‘@BotFather’ and start a chat with it.

Create a New Bot: Type /newbot and send it to BotFather. You’ll be prompted to name your bot. After that, choose a unique username for your bot, which must end in ‘bot’. For instance, zohoLeadNotifier_bot.

Get the API Token: Once the bot is created, BotFather will provide you with an API token. This token is crucial as it’s used to authorize your requests to the Telegram Bot API. Keep it secure and handy.

Step 2: Configure Your Telegram Bot

Set up Bot Commands (Optional): You can customize your bot by setting up commands. Send /setcommands to BotFather and select your bot. Then, input commands like start – to initiate the bot or getleads – to fetch lead information.

Customize Bot Description and Profile Picture: Personalize your bot by setting a description and profile picture through BotFather using /setdescription and /setuserpic.

Step 3: Test Your Bot

Start Your Bot: In the Telegram app, search for your bot’s username and start a chat. Send a ‘/start’ command to initiate interaction.

Test Basic Functionality: If you’ve set up any custom commands, try them out to ensure they work correctly.

Setting Up a Telegram Channel for Bot Notifications

Step 5: Create and Configure Your Telegram Channel

 

Create a New Telegram Channel:

Open the Telegram app.
Tap on the pencil icon (usually found in the bottom right corner).
Select ‘New Channel’.
Provide a name and description for your channel. This could be something like “Zoho CRM Lead Notifications”.
Set Up Your Channel:

Choose whether your channel will be public or private. A public channel can be found in search and has a short link (like t.me/yourchannelname), while a private channel can only be joined via an invite link.
Add any relevant details or images to make the channel identifiable for your needs.

Add Your Bot to the Channel: As the creator of the channel, you’re automatically made the admin.
Go to your channel’s info (click on the channel name at the top), and select “Administrators”.
Select “Add Administrator”.
Search for your bot by the username you set earlier and add it as an administrator.
Configure Posting Permissions for Your Bot:

Ensure your bot has permissions to post messages. You can customize these settings in the ‘Administrators’ section for your channel.

Step 6: Retrieve Your Channel ID

Post a Test Message: Send a message to your channel. This can be a simple greeting or test message.

Retrieve the Channel ID: You need the channel ID for your Deluge script to direct messages to this channel.
You can find the channel ID by

      • Using API tools or bots designed to reveal this information. It usually starts with -100 followed by a series of numbers.

      • Opening the web version of telegram in an internet browser at https://web.telegram.org (This is probably easiest)

Setting Up ZOHO CRM to Send Notifications to Telegram

Preparing Zoho CRM

Once you’ve configured your Telegram bot and channel, it’s time to integrate Zoho CRM to send new lead notifications to that channel.

Access Automation Settings: In Zoho CRM, click on the settings icon and navigate to “Actions” under the Automation section.

Create a Function: Select “Functions” from the options in the top right

then create a new function and choose “Write your own.”

Naming Your Function: Give your function a descriptive name for easy identification.

Writing the Deluge Script

Paste the following Deluge script into the function:

				
					alead = zoho.crm.getRecordById("Leads",alid);
// Extracting lead data
name = alead.getJSON("Lead_Name");
website = alead.getJSON("Website");
email = alead.getJSON("Email");
phone = alead.getJSON("Phone");
status = alead.getJSON("Status");

// Formatting the notification
leadlink = "Zoho File Link";
newline = hextoText("0A");
notification_text = "New Lead In Zoho:" + newline + newline + "Business Name: " + name + newline + "Website: " + website + newline + "Link: " + leadlink;

// Sending a message to the assigned channel
if(status == "New Lead - West") {
notification = invokeurl
[
url :"https://api.telegram.org/bot[BOT ACCESS TOKEN]/sendMessage?chat_id=[CHAT ID]&text=" + notification_text + "&disable_web_page_preview=True&parse_mode=html"
type :GET
];
info notification + "New Lead W";
}
else if(status == "New Lead - South") {
notification = invokeurl
[
url :"https://api.telegram.org/bot[BOT ACCESS TOKEN]/sendMessage?chat_id=[CHAT ID]&text=" + notification_text + "&disable_web_page_preview=True&parse_mode=html"
type :GET
];
info notification + "New Lead S";
}
else {
info "Nothing to notify";
}
				
			

Customizing the Script

Adding More Information: If you want to include additional lead information, add a line in the format

Variable = alead.getJSON(“API NAME OF THE FIELD”).


Locating API Names: To find the API names in Zoho CRM, go back to the settings, click on APIs under the

developer tab, select “API Names” at the top, and choose the module you’re working with. All API names will be listed here.


Updating Notification Text: If you add new fields, remember to update the notification_text line in the script to include this information.

Testing the Function


Perform Test Runs: Use the ID of an existing lead in your system to test the function.
Troubleshooting: If you encounter issues during testing, it’s essential to troubleshoot them before proceeding further.

Setting Up the Workflow Rule


Access Workflow Rules: From the settings menu in Zoho CRM, select “Workflow Rules” under the Automation section.


Create a New Rule: This rule should trigger when a Lead is created and apply to all leads (you might exclude spam leads if you have a filter set up).
Selecting the Function: For the action, choose “Functions” and select the function you just created.

And there you have it! You’ve successfully navigated the intricacies of setting up a Telegram bot, configuring a dedicated channel, and integrating it with Zoho CRM to receive real-time notifications for new leads. This seamless blend of Telegram’s instant messaging capabilities with Zoho CRM’s robust data management ensures that you’re always in the loop with your lead generation process.

Remember, the key to making the most of this integration lies in customization. Tailor your notifications to include the information that matters most to you and your team. With the flexibility of Deluge scripts and the versatility of Telegram channels, you have the power to create a notification system that fits your unique business needs.

As you embark on this journey of enhanced CRM efficiency, we encourage you to experiment and optimize. And should you encounter any bumps along the way, remember that both the Zoho and Telegram communities are rich with resources and support.

Finally, we’d love to hear about your experiences and successes with this setup. Your feedback not only inspires us but also helps others in their quest for CRM and communication excellence.

Happy automating, and here’s to turning every new lead into a thriving business opportunity!

How to Set Up a Telegram Bot for Lead Notifications