Contact Sales

All fields are required

Snippet: Sentiment Analysis | SignalWire

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.

  • Python
  • 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

  1. Copy from example.env and fill in your values
  2. 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

For Python:

1. Replace environment variables
2. From command line run, python3 app.py
More Documentation

You can find more documentation on LaML, Relay, and all SignalWire APIs at:


Support

If you have any issues or want to engage further about this snippet, please open an issue on this repo or join our fantastic Slack community and chat with others in the SignalWire community!

If you need assistance or support with your SignalWire services please file a support ticket from your Dashboard.