This example provides sample code for integrating Tone Analyzer and Assistant in Python 2.6+. All calls are made synchronously. For sample Python 3.5 asynchronous code, please see https://github.com/aprilwebster/python-sdk.
-
tone_detection.py - sample code to initialize a user object in the assistant payload's context (initUser), to call Tone Analyzer to retrieve tone for a user's input (invokeToneAsync), and to update tone in the user object in the assistant payload's context (updateUserTone).
-
tone_assistant_integration.v1.py - sample code to use tone_detection.py to get and add tone to the payload and send a request to the Assistant Service's message endpoint both in a synchronous and asynchronous manner.
Requirements to run the sample code
Credentials & the Workspace ID can be set in environment properties, a .env file, or directly in the code.
Dependencies provided in
init.py
Command to run the sample code
python tone_assistant_integration.v1.py