Snippet: Sentiment Analysis
This snippet will show you how to identify and analyse the sentiment or emotion of the call. This is good for POST-call analysis or with some simple modification, can be used in real-time, to actively route caller.
You will need a machine with Python installed, the SignalWire SDK, a provisioned SignalWire phone number, and optionally Docker if you decide to run it in a container.
For this demo we will be using Python, but more languages may become available.
- SignalWire SDK
- SignalWire Phone Number
- Docker (Optional)
How this Sentiment Analysis application works
Sentiment is a score from 0 to 1, that identifies the caller's emotion. You point a SignalWire phone number to the /voice_entry endpoint and it will assign a score, and read it back to you.
Methods and Endpoints
Endpoint: /voice_entry Methods: GET OR POST Requests to voice_entry, produce a LaML Voice response to gather a clip for analysis.
Setup Your Environment File
- Copy from example.env and fill in your values
- Save new file called .env
Your file should look something like this:
## This is your key for Microsoft cognitive services MICROSOFT_KEY=
Build and Run on Docker
Let's get started!
- Use our pre-built image from Docker Hub:
For Python: docker pull signalwire/snippets-sentiment-analysis:python
- Or build your own image:
docker build -t snippets-sentiment-analysis .
- Run your image:
docker run --publish 5000:5000 --env-file .env snippets-sentiment-analysis
- The application will run on port 5000
Build and Run Natively
1. Replace environment variables 2. From command line run, python3 app.py
You can find more documentation on LaML, Relay, and all SignalWire APIs at:
If you need assistance or support with your SignalWire services please file a support ticket from your Dashboard.