Git Product home page Git Product logo

support_bot's Introduction

Game of Verbs support bot

Support bot for Game of Verbs with DialogueFlow at its core

See for yourself:

How to install

Python should already be installed. This project is tested on Python 3.11. You may use other versions as you will, but YMMV.

Clone the repo / download code

Using virtual environment virtualenv/venv is recommended for project isolation.

Install requirements:

pip install -r requirements.txt

Set up environmental variables.
Create .env file in root folder and write down the following variables:

  • TELEGRAM_BOT_TOKEN - Access token of your bot. You get one from BotFather Telegram bot when you create a bot.
  • TELEGRAM_LOGGING_BOT_TOKEN - same as above, but used for sending logs. Can be the same bot or separate as the main one.
  • VK_GROUP_TOKEN - Access token of your VK group. Get it from the group's settings.
  • PROJECT_ID - Google Cloud project's ID
  • GOOGLE_APPLICATION_CREDENTIALS - Filepath to credentials.json of your Google Cloud project. See below how to get it.
  • DIALOG_FLOW_API_KEY - DialogueFlow's access token. See below how to get it.
  • LOGGING_LEVEL - Desired logging level
  • TELEGRAM_USER_ID - Your numeric Telegram ID. Can be checked by writing to special user info bot. Used to recieve logs.

Setting up Google Project

Main article here

To work with DialogueFlow, you'll need a Google Cloud project and a DialogueFlow project. Follow the article above to set everything up, but the main points are:

  • Make a Google Cloud project (or select an existing one)
  • Make sure DialogFlow's API is enabled
  • Make a DialogueFlow project, write your Google Cloud's project ID into appropriate field in DF's settings
  • Use Google Cloud CLI to authenticate and create credentials.json file
  • Create DialogueFlow API key, using instructions

Creating DialogueFlow API key

To create API key use a helper script create_api_key.py

python create_api_key.py your_key_name

For details and options see the official instructions

Teaching DialogueFlow

For DialogueFlow to be able to respond to users' messages it must be taught intents. While it can be done manually in DF project's dashboard, you can use create_intent.py script if you have a JSON file with training phrases JSON file's structure should like this:

{
    "Name of the intent": {
        "questions": [
            "User expression 1",
            "User expression 2",
            "User expression 3",
            "..."
        ],
        "answer": "Text of the answer"
    }
}

In this case run the script create_intent.py:

python create_intent.py filepath/to/phrases/file.json

How to use

Telegram and VK bots are separate and should be launched by executing telegram_bot.py and vk_bot.py

python telegram_bot.py  # launches Telegram bot
python vk_bot.py  # launches VK bot

For Telegram bot to be able to send messages, send it a /start command

Telegram bot example:
Telegram example

Vkontakte bot example:
VK example

Project Goals

The code is written for educational purposes on online-course for web-developers dvmn.org.

support_bot's People

Contributors

mrdave avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.