Automate SMS responses to customer feedback using sentiment analysis
Assumes a macOS environment.
Install the latest versions of Python 2 and 3.
$ brew install python
$ brew install python3Install pip.
$ sudo easy_install pipInstall MongoDB.
$ brew install mongodbIf you're running El Capitan or earlier, execute this instead.
$ brew install mongodb@3.4Create the database directory. Give write permission to that directory.
$ sudo mkdir -p /data/db
$ sudo chmod -R go+w /data/dbInstall ngrok.
$ brew cask install ngrokPrepare the virtual environment.
$ cd dashboard
$ virtualenv venv
$ . venv/bin/activateInstall Python packages.
$ pip install -r requirements.txtRun the mongod process in a separate terminal window.
$ /file/path/to/process/.../mongodIf you used brew to install MongoDB, the file path should be similar to the one below.
/usr/local/Cellar/mongodb\@3.4/3.4.13/bin/mongod
Run ngrok in a separate terminal window.
$ ngrok http 5000- Sign in to Twilio to access the dashboard
- Navigate to Phone Numbers/Manage Numbers/Active Numbers
- Select a phone number
- Scroll down to the Messaging section
- Locate the 'A MESSAGE COMES IN' field
- Select Webhook in the left dropdown menu
- Enter the HTTPS ngrok URL in the text field
- Append
/smsto the end of the URL - Select HTTP POST in the right dropdown menu
- Save changes
Open environ.sh and enter values for the five soon-to-be environment variables.
export TWILIO_ACCOUNT_SID=
export TWILIO_AUTH_TOKEN=
export TWILIO_PHONE_NUMBER=
export TEXT_ANALYTICS_KEY=
export TEXT_ANALYTICS_SENTIMENT_URL=Grant environ.sh write permission. Execute the file.
$ chmod u+x environ.sh
$ source environ.shStart the local server in the same terminal window where environ.sh was executed.
$ flask runEnter the URL localhost:5000 in a browser.
When it's time to close the application, exit the virtual environment.
$ deactivateThe customer phone number may be entered in various formats.
000-000-0000
000 000 0000
000.000.0000
(000)000-0000
(000)000 0000
(000)000.0000
(000) 000-0000
(000) 000 0000
(000) 000.0000
000-0000
000 0000
000.0000
0000000
0000000000
(000)0000000The tags <firstName> and <productType> are replaced by the customer name and drink fields, respectively. All, some, or no tags can be included when editing messages.
- All form fields are validated before any SMS is sent to a customer.
- Customer name, phone number, and drink fields are cleared after a successful form submission. The message fields are preserved so the same messages can be quickly sent to another customer.
