Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

How to create a new application for @codex_bot platform

This article is about new @codex_bot application development. Throughout this guide we build an application that can provide weather forecast for different periods of time.

For simplicity we use our modern SDK for Python. We also provide instructions how to run your own production-ready @codex_bot server.

Before start you need to run @codex_bot Core (read Developer's Guide) or use our @codex_bot

If you are wondering, we have a lot of other useful @codex_bot applications to play with. Check our landing for the further information.

Install necessary tools

  1. Python v.3.5.3 can be downloaded by the link ( Just follow installation instructions. You can use newer versions if you need.
  2. MongoDB ( Useful hint – you can run Mongo with the Docker. Just follow the instructions in the next section.
  3. Install a virtual environment for Python apt-get install virtualenv или pip install virtualenv
  4. Initialize a virtual environment with virtualenv venv -p python3.

Docker support

You can skip this step if you don't need to run MongoDB in a Docker.

  1. Create working directory mkdir mongo
  2. Run docker run -v mongo:/data/db -p 27017:27017 -d mongo

Prepare sources

The sources of our example application could be found in repository.

  1. You can get them with git clone weather
  2. Activate virtual environment source ../venv/bin/activate
  3. cd weather
  4. Install necessary packages pip install -r requirements.txt
  5. cd weather
  6. Copy sample config to the work config cp


  1. Invent a new unique application name and fill corresponding parameter APPLICATION_NAME
  2. Write to your bot (if you are running @codex_bot Core by yourself) or to the @codex_bot the following command: /newapp {unique name of app} {your host}. You will get a token back. Copy this token to corresponding parameter APPLICATION_TOKEN in your

Try to run

Now, you can run weather application with python command. If everything is all right, you will get back several debug messages from Core with the prefix Received

How it works

In there is an SDK initialization with values from the configuration file. self.sdk = CodexBot(APPLICATION_NAME, SERVER['host'], SERVER['port'], db_config=DB, token=APPLICATION_TOKEN)

After that, method register_commands tells Core which commands should be redirected to your application (note: this commands might be unique!).

    ('weather_help', 'help', CommandHelp(self.sdk)),
    ('weather', 'weather', CommandWeather(self.sdk)),
    ('cities', 'cities', CommandCities(self.sdk)),
    ('city', 'city', CommandCity(self.sdk)),
    ('rain3', 'rain3', CommandWeather(self.sdk)),
    ('rain10', 'rain10', CommandWeather(self.sdk))

Handlers for each command are defined in commands directory. You can find imports in the beginning of the script:

from import CommandHelp
from commands.cities import CommandCities
from import CommandCity
from import CommandWeather

Our SDK invokes init method with payload parameter. Watch an example in the commangs/ file:

class CommandCities(CommandBase):
    async def __call__(self, payload):
        self.sdk.log("/cities handler fired with payload {}".format(payload))
        await self.sdk.send_text_to_chat(
            "...message here..."

When user inputs /cities command in the telegram chat with bot, you'll receive a debug message with the payload into your terminal:          :17                  debug() 	 /cities handler fired with payload {'command': 'cities', 'params': '', 'chat': 'RXRI6S0N', 'user': 'VZXTDQ44'}


  • /city <CITY_ID> — setting up your location
  • /cities — view cities list
  • /weather — get current weather conditions

Issues and improvements

  • Ask a question or report a bug on the create issue page.
  • Know how to improve platform? Fork it and send a pull request.

About CodeX

We are small team of passionate web-developers consisting of IFMO University students and graduates located in St. Petersburg, Russia. Fell free to give us a feedback on


Bot making tutorial







No releases published


No packages published