Skip to main content

Asynchronous library for Yandex Dialogs (Alice) API

Project description

aioAlice

AsyncIO library for Yandex Alice (Yandex Dialogs)

Why?

  • Work with classes, don't bother parsing JSON
  • Auto answer to webhook even if you were not fast enough to create answer - there won't be a server error, but you'll get a log

Auto response will not help if you are not using async IO. So consider not to use any long processing synchronous tasks inside handlers

  • Handy handlers to match incoming commands
  • Finite-State Machine
  • Easy images upload, easy answers generation

Installation

# make sure you use virtual env and python 3.6+:
python3.6 -m venv aliceenv
source ./aliceenv/bin/activate

pip install pip -U
pip install setuptools -U
pip install uvloop  # uvloop if you want

pip install aioalice -U
# Or install from GitHub:
# pip install git+https://github.com/surik00/aioalice.git -U

# or if you don't have git installed:
# 1. download ZIP
# 2. unarchive and go to dir
# 3. run:
python setup.py install

Quick start

Hello alice

dp = Dispatcher()

@dp.request_handler()
async def handle_all_requests(alice_request):
    return alice_request.response('Hello world!')

Cards

JSON serializing

If you want to use a faster json library, install rapidjson or ujson, it will be detected and used automatically


Skills using aioAlice


Testing and deployment

In all examples the next configuration is used:

WEBHOOK_URL_PATH = '/my-alice-webhook/'  # webhook endpoint

WEBAPP_HOST = 'localhost'  # running on local machine
WEBAPP_PORT = 3001  # we can use any port that is not use by other apps

For testing purposes you can use ngrok, so set webhook to https://1a2b3c4d5e.ngrok.io/my-alice-webhook/ (endpoint has to be WEBHOOK_URL_PATH, because WebApp expects to get updates only there), post has to be WEBAPP_PORT (in this example it is 3001)

For production you can use Nginx, then edit Nginx configuration and add these lines inside the server block:

location /my-alice-webhook/ {  # WEBHOOK_URL_PATH
    proxy_pass         http://127.0.0.1:3001/;  # addr to reach WebApp, in this case it is localhost and port is 3001
    proxy_redirect     off;
    proxy_set_header   Host $host;
    proxy_set_header   X-Real-IP $remote_addr;
    proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header   X-Forwarded-Host $server_name;
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aioAlice-1.5.1.tar.gz (19.2 kB view details)

Uploaded Source

Built Distribution

aioAlice-1.5.1-py3-none-any.whl (28.6 kB view details)

Uploaded Python 3

File details

Details for the file aioAlice-1.5.1.tar.gz.

File metadata

  • Download URL: aioAlice-1.5.1.tar.gz
  • Upload date:
  • Size: 19.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.64.0 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.4 CPython/3.6.15

File hashes

Hashes for aioAlice-1.5.1.tar.gz
Algorithm Hash digest
SHA256 cb3317b34044650f88f57c6b6052ea211539c4cdf55978741010905ac7b37955
MD5 2d2f02b216f8ebbbfe941321253c5472
BLAKE2b-256 e4b6b0840ac6517d67e256cbe5fb2121161cbd7309ef6650ae16a4daf92b5d28

See more details on using hashes here.

Provenance

File details

Details for the file aioAlice-1.5.1-py3-none-any.whl.

File metadata

  • Download URL: aioAlice-1.5.1-py3-none-any.whl
  • Upload date:
  • Size: 28.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.64.0 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.4 CPython/3.6.15

File hashes

Hashes for aioAlice-1.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0da8e114bf7b43f892f0a0d0aa3dd4acaf0f73ae3b5cef60f933515053e6c688
MD5 958a70539f6b24547bd8b3fa97bd816b
BLAKE2b-256 c168dddca1079d569fa12f329e32ed3b4390f57b2d634dd66120900e1fac2132

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page