Hermes python

hermes-python allows you to interface seamlessly with the Snips platform: It abstracts away the connection to the MQTT bus and the parsing of incoming and outcoming messages from the Hermes python protocol.

Basic Usage

hermes_python has two ways to interact with the MQTT bus :

  • By sending messages to the Dialogue Manager

  • By subscribing callbacks to events triggered by the Dialogue Manager

hermes-python can be installed on your system with : pip install hermes-python.

Here's a basic code to connect to a distant device running the Snips platform, that listens to any incoming intents, that prints them out.

from import Hermes
MQTT_ADDR = "localhost:1883" # Specify host and port for the MQTT broker
def subscribe_weather_forecast_callback(hermes, intent_message): # Defining callback functions to handle an intent that asks for the weather.
print("Parsed intent : {}".format(intent_message.intent.intent_name))
with Hermes(MQTT_ADDR) as h: # Initialization of a connection to the MQTT broker
h.subscribe_intent("searchWeatherForecast", subscribe_weather_forecast_callback) \ # Registering callback functions to handle the searchWeatherForecast intent
# We get out of the with block, which closes and releases the connection.

Further documentation

The documentation for hermes-python can be found on readthedocs, here : Documentation.