Skip to content

p92camcj/Tutorial-telegram-bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

How to create a Telegram Bot using only a Chromebook.

By Julio Camacho @p92camcj

14 August, 2015


How to create a Telegram Bot using only a Chromebook.

This tutorial helps you to create a new Telegram1 bot2 using only a Chromebook PC3 or a web browser (Google Chrome). We are going to use the tool Codenvy4, Google App Engine5 and a Python Telegram Bot

I have to thank Leandro Toledo for having helped me in this process.

Thanks to Yukuku for doing the tutorial that I followed and which I have used to do this one.

Thanks to Soo Y. Hwang for let me use her code base.


Now, knowing which will be our tools, go on!

  1. Message @botfather https://telegram.me/botfather with the following text: /newbot If you don't know how to message by username, click the search field on your Telegram app and type @botfather. You should be able to initiate a conversation. Be careful not to send it to the wrong contact, because some users has similar usernames to botfather.

    botfather initial conversation

  2. @botfather replies with Alright, a new bot. How are we going to call it? Please choose a name for your bot.

  3. Type whatever name you want for your bot.

  4. @botfather replies with Good. Now let's choose a username for your bot. It must end in bot. Like this, for example: TetrisBot or tetris_bot.

  5. Type whatever username you want for your bot, minimum 5 characters, and must end with bot. For example: whateversamplebot

  6. @botfather replies with:

    Done! Congratulations on your new bot. You will find it at telegram.me/whateversamplebot. You can now add a description, about section and profile picture for your bot, see /help for a list of commands.

    Use this token to access the HTTP API: 123456789:AAG90e14-0f8-40183D-18491dDE

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

  7. Note down the 'token' mentioned above.

  8. Type /setprivacy to @botfather.

    botfather later conversation

  9. @botfather replies with Choose a bot to change group messages settings.

  10. Type @whateversamplebot (change to the username you set at step 5 above, but start it with @)

  11. @botfather replies with

    'Enable' - your bot will only receive messages that either start with the '/' symbol or mention the bot by username. 'Disable' - your bot will receive all messages that people send to groups. Current status is: ENABLED

  12. Type Disable to let your bot receive all messages sent to a group. This step is up to you actually.

  13. @botfather replies with Success! The new status is: DISABLED. /help

  14. Go to https://console.developers.google.com/project

  15. Click Create Project

  16. Type whatever name you want for the project. For example: tutorial telegram bot p92camcj. Make sure the Project ID is also the same and note down it, this is YOUR GOOGLE APP ENGINE PROJECT ID. For exampl, my Google App Project ID is tutorial-telegram-bot-p92camcjCreation Tutorial Telegram Bot p92camcj

  17. Create an account in Codenvy.com

  18. Create a new project. Using blank option, type the name and description of your project and press next.Create new Codenvy Project

  19. This step is very important. In the Select Runner environment you have to choose Python/web/python27_gae1914_ext_libs. Then press Create.Select Runner environment

  20. Now you have to import a test bot. I have created one to do this tutorial. You can use it.

  21. So go to menu/file/Import Project/Import From Location... like it appears in this image:Import folder from location

  22. You have to choose in Source Control option GitHub and then paste this link on URL field like it appears in this image: Import from GitHub

  23. Edit the first line of app.yaml file and type YOUR GOOGLE APP ENGINE PROJECT ID (step 16). Modify app.yaml

  24. After that, you have to modify bot_gae.py file, in lines 13 and 32. Modify bot_gae.py

  • Line 13 should be edited to include your token bot (BotFather gave you in step 1)
    bot = telegram.Bot(token='114313687:AAFbt4jveB_hhT-UhMBO1vnjZNruS0Mg1Z4')
  • Line 32 should be edited to include YOUR GOOGLE APP ENGINE PROJECT ID s = bot.setWebhook('https://tutorial-telegram-bot-p92camcj.appspot.com/HOOK')
  1. Now everything is ready to work, so Run your project using the menu and submenu option. Run Project
  2. You must see a runner panel below, you have to wait until the whole proccess have finished, and then open the terminal tab (near console active tab) Console tab in runner panel
  3. Finally, you have to deploy it typing next command line on the terminal: google_appengine/appcfg.py update /home/user/application/. It will ask for your Google Account credential (email and pass), so you have to ingress them.
  4. If you have had some problems with the previous step and Google sends you an email about your security account, try the next method. Type the next command line on the terminal: google_appengine/appcfg.py update /home/user/application --oauth2 --noauth_local_webserver. It will print a link. Copy the code and return to terminal codenvy. Right-click on the terminal, select Paste from Browser and paste the code. Be happy :) Problems Google?
  5. Now, try to navegate to https://tutorial-telegram-bot-p92camcj.appspot.com/set_webhook and if all is correct, you must read "webhook setup ok"
  6. Now you speak to your bot in telegram, and if it repeats like a parrot everything you write, you will have successfully completed this tutorial.

Like a Parrot


1: Telegram is a cloud-based mobile and desktop messaging app with a focus on security and speed. More info: telegram.org.

2: Bots are simply Telegram accounts operated by software – not people – and they'll often have AI features. They can do anything – teach, play, search, broadcast, remind, connect, integrate with other services, or even pass commands to the Internet of Things. More info in his blog.

3: A Chromebook is a laptop running Chrome OS as its operating system. The devices are designed to be used primarily while connected to the Internet, with most applications and data residing "in the cloud". A Chromebook is an example of a thin client. More info: google.com/chromebook

4: Codenvy provides a container-based development environment whose goal is to remove the need for developers to configure or maintain local or VM-based developer environments for their projects. More info: codenvy.com

5: Google App Engine (often referred to as GAE or simply App Engine) is a platform as a service (PaaS) cloud computing platform for developing and hosting web applications in Google-managed data centers. More info: appengine.google.com

About

How to create a Telegram Bot using only a Chromebook

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages