dialogic


Namedialogic JSON
Version 0.3.10 PyPI version JSON
download
home_pagehttps://github.com/avidale/dialogic
SummaryYet another common wrapper for Alice/Salut skills and Facebook/Telegram/VK bots
upload_time2021-04-09 10:25:20
maintainer
docs_urlNone
authorDavid Dale
requires_python
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # dialogic
[![PyPI version](https://badge.fury.io/py/dialogic.svg)](https://badge.fury.io/py/dialogic)

This is yet another common Python wrapper for 
[Alice](https://yandex.ru/dev/dialogs/alice/doc/about.html) and 
[Sber Salut](https://salute.sber.ru/smartmarket/dev/) skills 
and bots in Telegram<sup>[*](#footnote1)</sup>, VK, 
and Facebook Messenger.

Currently, it provides:
- An (almost) unified interface between your bot 
  and Alice/SalutTelegram/Facebook/VK: `DialogConnector`,
  for which you can create or customize adapters.
- A number of simple dialogue constructors: `BaseDialogManager` and its flavors, including:
    - a simple FAQ dialog manager
    - a simple form-filling dialog manager
    - a flexible finite state automaton dialog manager
    - an even more flexible turn-based dialog manager
- A wrapper for storing dialogue state: `BaseStorage` and its flavors (specifially, `MongoBasedStorage`)
- Yet another wrapper for serving your bot as a Flask application

This [package](https://pypi.org/project/dialogic/) may be installed with `pip install dialogic`.

### A brief how-to

To create your own bot, you need either to write a config for an existing dialog manager, 
or to inherit your own dialog manager from `BaseDialogManager`. 

The components of `dialogic` may be combined into a working app as follows:

```python
import dialogic

class EchoDialogManager(dialogic.dialog_manager.BaseDialogManager):
    def respond(self, ctx: dialogic.dialog.Context):
        return dialogic.dialog.Response(text=ctx.message_text)

connector = dialogic.dialog_connector.DialogConnector(
    dialog_manager=EchoDialogManager(), 
    storage=dialogic.session_storage.BaseStorage()
)
server = dialogic.flask_server.FlaskServer(connector=connector)

if __name__ == '__main__':
    server.parse_args_and_run()
```
Now, if your app is hosted on address `{BASE_URL}`, 
then webhooks for Alice, Salut and Facebook will be available, 
respectively, at `{BASE_URL}/alice/`, `{BASE_URL}/salut/`, and `{BASE_URL}/fb/` (and you can reconfigure it, if you want). 
The webhook for Telegram will be set automatically, if you set the `TOKEN` environment variable to the token 
given to you by the [@BotFather](https://t.me/BotFather).

If you want to test your app locally, you can run it with command line args:
* `--cli` - to read and type messages in command line, completely offline
* `--poll` - to run a Telegram bot locally, in long polling mode (in some countries, you need a VPN to do this)
* `--ngrok` - to run the bot locally, using the [ngrok](https://ngrok.com/) tool<sup>[**](#footnote2)</sup> 
to create a tunnel from your machine into the internet. This is probably the simplest way to test Alice skills 
without deploying them anywhere .

The [examples](https://github.com/avidale/dialogic/tree/master/examples) directory contains more detailed examples 
of how to create dialogs and serve the bot. 

If you have questions, you can ask them in the Telegram chat 
[Dialogic.Digital support](https://t.me/joinchat/WOb48KC6I192zKZu).

<a id="footnote1">*</a> The Telegram wrapper is based on the 
[pyTelegramBotAPI](https://github.com/eternnoir/pyTelegramBotAPI) package.

<a id="footnote2">**</a> The ngrok connector was taken from the
[flask-ngrok](https://github.com/gstaff/flask-ngrok) library. It will be refactored to a dependency, 
as soon as the library is updated on PyPI.
            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/avidale/dialogic",
    "name": "dialogic",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "",
    "author": "David Dale",
    "author_email": "dale.david@mail.ru",
    "download_url": "https://files.pythonhosted.org/packages/b5/a7/8c2358d7a80abc646a4ef2a106ca04f5a14bbea03158ea1661ecdc2644ab/dialogic-0.3.10.tar.gz",
    "platform": "",
    "description": "# dialogic\n[![PyPI version](https://badge.fury.io/py/dialogic.svg)](https://badge.fury.io/py/dialogic)\n\nThis is yet another common Python wrapper for \n[Alice](https://yandex.ru/dev/dialogs/alice/doc/about.html) and \n[Sber Salut](https://salute.sber.ru/smartmarket/dev/) skills \nand bots in Telegram<sup>[*](#footnote1)</sup>, VK, \nand Facebook Messenger.\n\nCurrently, it provides:\n- An (almost) unified interface between your bot \n  and Alice/SalutTelegram/Facebook/VK: `DialogConnector`,\n  for which you can create or customize adapters.\n- A number of simple dialogue constructors: `BaseDialogManager` and its flavors, including:\n    - a simple FAQ dialog manager\n    - a simple form-filling dialog manager\n    - a flexible finite state automaton dialog manager\n    - an even more flexible turn-based dialog manager\n- A wrapper for storing dialogue state: `BaseStorage` and its flavors (specifially, `MongoBasedStorage`)\n- Yet another wrapper for serving your bot as a Flask application\n\nThis [package](https://pypi.org/project/dialogic/) may be installed with `pip install dialogic`.\n\n### A brief how-to\n\nTo create your own bot, you need either to write a config for an existing dialog manager, \nor to inherit your own dialog manager from `BaseDialogManager`. \n\nThe components of `dialogic` may be combined into a working app as follows:\n\n```python\nimport dialogic\n\nclass EchoDialogManager(dialogic.dialog_manager.BaseDialogManager):\n    def respond(self, ctx: dialogic.dialog.Context):\n        return dialogic.dialog.Response(text=ctx.message_text)\n\nconnector = dialogic.dialog_connector.DialogConnector(\n    dialog_manager=EchoDialogManager(), \n    storage=dialogic.session_storage.BaseStorage()\n)\nserver = dialogic.flask_server.FlaskServer(connector=connector)\n\nif __name__ == '__main__':\n    server.parse_args_and_run()\n```\nNow, if your app is hosted on address `{BASE_URL}`, \nthen webhooks for Alice, Salut and Facebook will be available, \nrespectively, at `{BASE_URL}/alice/`, `{BASE_URL}/salut/`, and `{BASE_URL}/fb/` (and you can reconfigure it, if you want). \nThe webhook for Telegram will be set automatically, if you set the `TOKEN` environment variable to the token \ngiven to you by the [@BotFather](https://t.me/BotFather).\n\nIf you want to test your app locally, you can run it with command line args:\n* `--cli` - to read and type messages in command line, completely offline\n* `--poll` - to run a Telegram bot locally, in long polling mode (in some countries, you need a VPN to do this)\n* `--ngrok` - to run the bot locally, using the [ngrok](https://ngrok.com/) tool<sup>[**](#footnote2)</sup> \nto create a tunnel from your machine into the internet. This is probably the simplest way to test Alice skills \nwithout deploying them anywhere .\n\nThe [examples](https://github.com/avidale/dialogic/tree/master/examples) directory contains more detailed examples \nof how to create dialogs and serve the bot. \n\nIf you have questions, you can ask them in the Telegram chat \n[Dialogic.Digital support](https://t.me/joinchat/WOb48KC6I192zKZu).\n\n<a id=\"footnote1\">*</a> The Telegram wrapper is based on the \n[pyTelegramBotAPI](https://github.com/eternnoir/pyTelegramBotAPI) package.\n\n<a id=\"footnote2\">**</a> The ngrok connector was taken from the\n[flask-ngrok](https://github.com/gstaff/flask-ngrok) library. It will be refactored to a dependency, \nas soon as the library is updated on PyPI.",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Yet another common wrapper for Alice/Salut skills and Facebook/Telegram/VK bots",
    "version": "0.3.10",
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "5bf73598b7b205eb10d1962444ab4349",
                "sha256": "57a3fef451273f9a712dcb50b78971544944773ee39c89c7bd281036098518cd"
            },
            "downloads": -1,
            "filename": "dialogic-0.3.10.tar.gz",
            "has_sig": false,
            "md5_digest": "5bf73598b7b205eb10d1962444ab4349",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 60302,
            "upload_time": "2021-04-09T10:25:20",
            "upload_time_iso_8601": "2021-04-09T10:25:20.761409Z",
            "url": "https://files.pythonhosted.org/packages/b5/a7/8c2358d7a80abc646a4ef2a106ca04f5a14bbea03158ea1661ecdc2644ab/dialogic-0.3.10.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2021-04-09 10:25:20",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": null,
    "github_project": "avidale",
    "error": "Could not fetch GitHub repository",
    "lcname": "dialogic"
}
        
Elapsed time: 0.28411s