Skip to main content

dialogic

PyPI version

This is yet another common Python wrapper for Alice and Sber Salut skills and bots in Telegram*, 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 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:

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.

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 tool** 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 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.

* The Telegram wrapper is based on the pyTelegramBotAPI package.

** The ngrok connector was taken from the flask-ngrok library. It will be refactored to a dependency, as soon as the library is updated on PyPI.

Release files for dialogic 0.3.18

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dialogic 0.3.18
File Size Uploaded
dialogic-0.3.18.tar.gz 77.8 kB Details

Release files / dialogic-0.3.18.tar.gz

Download URL dialogic-0.3.18.tar.gz
Size 77.8 kB
Tags Source
SHA-256 checksum
How to use checksums
76cefb088ee62b06bbef9595477e01221d39fccf8ac6e962c1aea0c0003d6ac3
BLAKE2b-256 checksum
How to use checksums
abe4398cf14db5b2d7836146b96920759d832c6c58218f60762a45b0ecdd6b43
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/3.10.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.6

Release history Release notifications | RSS feed

0.3.20

1 release file

0.3.19

1 release file

This release

0.3.18 This release

1 release file

0.3.17

1 release file

0.3.16

1 release file

0.3.15

1 release file

0.3.14

1 release file

0.3.13

1 release file

0.3.12

1 release file

0.3.11

1 release file

0.3.10

1 release file

0.3.9

1 release file

0.3.8

1 release file

0.3.7

1 release file

0.3.6

1 release file

0.3.5

1 release file

0.3.4

1 release file

0.3.3

1 release file

0.3.2

1 release file

0.3.1

1 release file

0.3.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page