Skip to content

Developer's Guide

Alexander Menshikov edited this page Dec 7, 2017 · 1 revision

How to run CodeX Bot Core

This article is about building CodeX Bot core for applications 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.

Install necessary tools

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

Docker support

You can skip this paragraph if you do not need to run MongoDB or RabbitMQ in Docker.

  1. Create working directory mkdir mongo
  2. Run docker run -v mongo:/data/db -p 27017:27017 -d mongo
  3. Run docker run -d --hostname my-rabbit --name some-rabbit -p 5672:5672 -p 5671:5671 -p 8080:15672 rabbitmq:3

Prepare sources

  1. Copy our CodeX Bot core with git clone https://github.com/codex-team/codex.bot.git core
  2. cd core
  3. Activate virtual environment source ../venv/bin/activate
  4. Install necessary packages pip install -r requirements.txt
  5. If you don't have public IP address, you can use reverse-proxy. Download Ngrok (https://ngrok.com/download)
  6. In separate terminal: ./ngrok http 1337

Configuration

  1. Move configuration sample file to a new config cp core/codexbot/globalcfg.py.sample core/codexbot/globalcfg.py
  2. Change default URL in core/codexbot/globalcfg.py to that from ngrok's HTTPS section. Don't forget to add https:// before.
  3. Create your own bot with https://telegram.me/BotFather (https://core.telegram.org/bots#6-botfather)
  4. Move Telegram configuration sample file to a new config cp core/codexbot/services/telegram/config.py.sample core/codexbot/services/telegram/config.py
  5. Input API TOKEN from BotFather to the telegram/config.py
  6. Run python main.py

Now, if you did all right, the CodeX Bot core will be running. Now, it's time to make your first CodeX Bot Application.

Learn how to setup up an environment for developing an application that will be available in Slack and Telegram both

Clone this wiki locally