Build a Telegram Chatbot in Python

Jeongsoo Park
Aug 2, 2017 · 2 min read

Nowadays there are many articles like ‘build a chatbot without any code’. But somebody still feels comfortable with codes. I’ll tell you here about to build a chatbot rapidly with BotHub.Studio.

Image for post
Image for post

Creating a Telegram Bot

Search @BotFather in telegram search box. Or use https://t.me/BotFather directly.

Image for post
Image for post
I’m the BotFather

Create a new bot by telling him command.

Image for post
Image for post

should not be duplicated. Give it a creative and unique name. Keep the access token BotFather gave you to use later.

Connect to Chatbot

First, create an account on BotHub.Studio which is a chatbot hosting service, and install CLI tool using the command below:

Run next:

Create a project directory:

A template code will be generated after finished:

Primary template code, specifically contains an echo bot code which mimics a user message.

Now we use the telegram access token BotFather gave:

And deploy the project to server:

Send a message to your chatbot and see it works well.

You can find your chatbot by searching @username in telegram search box or html link to https://t.me/<username>.

BotHub.Studio

News, tutorials about BotHub.Studio chatbot hosting service

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store