Skip to main content

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;
}

Metadata

Release files for aioAlice 1.2.3

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

Source distribution (sdist)

Source distribution for aioAlice 1.2.3
File Size Uploaded Provenance Actions
aioAlice-1.2.3.tar.gz 20.3 kB Without provenance Details for aioAlice-1.2.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for aioAlice 1.2.3
File Interpreter ABI Platform Actions
aioAlice-1.2.3-py3-none-any.whl Python 3 none any Details for aioAlice-1.2.3-py3-none-any.whl

Total release size: 47.2 kB

Release files / aioAlice-1.2.3.tar.gz

Download URL aioAlice-1.2.3.tar.gz
Size 20.3 kB
Tags Source
SHA-256 checksum
How to use checksums
aae564c2a8cca91bb7ca50b91df12249b99f4e1178f20643b436f680c006d008
BLAKE2b-256 checksum
How to use checksums
e248654657c44172565dadf8d96058868518845f58d074d549662146df69854d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.6.5

Release files / aioAlice-1.2.3-py3-none-any.whl

Download URL aioAlice-1.2.3-py3-none-any.whl
Size 26.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
49a869ea95cc064304e29e480f2984f4d521070093de2ae5773e4f07dd0c6abd
BLAKE2b-256 checksum
How to use checksums
09af83aea0c93f6ec7fbce98f93d4df70ac4b8213b07be130f53ae3a66a56589
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.6.5

Security for aioAlice 1.2.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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