Df Alice Connector is an extension to the Dialogflow Engine, a minimalistic open-source engine for conversational services.
Df Alice Connector allows you to program FSM-based skills for Yandex's Alice using df_engine. Using this add-on, you can take advantage of the features Alice offers, like the recognition of entities and intents, and incorporate them in your script as conditions for FSM transitions.
pip install df-alice-connector
import df_alice_connector as AliceConn
from df_alice_connector.request import GeoEntity, FioEntity, DateTimeEntity, YandexDefaultIntents, Intent
# Use this method to filter out requests that include one or several entities of a certain type.
AliceConn.cnd.has_geo(entities=[GeoEntity(...), GeoEntity(...)], full_match=...)
AliceConn.cnd.has_fio(entities=[FioEntity(...), FioEntity(...)], full_match=...)
AliceConn.cnd.has_datetime(entities=[DatetimeEntity(...), DatetimeEntity(...)], full_match=...)
AliceConn.cnd.has_number(enities=[1.0, 1.2])
# Use `has_intents` to filter requests that include a certain standard yandex intent.
AliceConn.cnd.has_intents(intents=[YandexDefaultIntents.HELP, YandexDefaultIntents.REPEAT])
intent: Intent
AliceConn.cnd.has_intents(func = lambda intent: intent.slots["some_slot"]["value"] == "y")
import df_alice_connector as AliceConn
from df_alice_connector.request import YandexRequestType
# Use `has_request_type` to filter requests depending on the type.
AliceConn.cnd.has_request_type(types=[YandexRequestType.SIMPLEUTTERANCE, ...])
# Use `has_payload` to process requests sent on button press.
AliceConn.cnd.has_payload(func = lambda x: x["key"] == "value", payload={"key": "value"})
import df_alice_connector as AliceConn
from df_alice_connector.request import YandexRequestModel
# Use `has_tokens` to filter requests depending on whether or not they include `tokens` or `banned_tokens`.
AliceConn.cnd.has_tokens(tokens=["token_1", ...], banned_tokens=["token_3", ...])
# Use the `apply` method to compare the request against any boolean function.
request: YandexRequestModel
AliceConn.cnd.apply(func=lambda request: request.command.startswith("включи свет"))
To get more advanced examples, take a look at examples on GitHub.
Please refer to CONTRIBUTING.md.