Social media was created as a way to interact with users from all over the world, where there were seemingly no boundaries to whom we could talk, and where in the world we could talk. Now these days, there seems to be so much widespread negativity and cyber-bullying incidents that even a single phrase could unleash havoc. Oftentimes, these incidents can be prevented if we just think twice before posting something on the internet that could be potentially harmful to either one person, or an entire race of people. That's where I got the idea of Social Adviser. This app asks the user to say the possible post that he/she might upload, analyze its intended tone, and notify the user of the top two tones expressed in the said post.
Interacting with the skillIf you want to test the skill, simply grab your Echo device, plug it in, and say the following: "Alexa, tell social adviser..." followed by the actual post you want to upload. After a moment later, Alexa will tell you first, the most likely emotion you are intending to share as well as how intense that emotion is, and then will do the same for the second most likely intended emotion.
Challenges and Side NoteOne of the challenges was part of my original idea, which was to have the app not only analyze the tone, but allow the user to post it if he/she wanted to. The reason I coudn't do it at this time was that most social media APIs use some kind of OAuth to handle permissions. Now this wouldn't have been a problem if I was using a pure GUI-based app, but unfortunately, my idea didn't mention about even using a GUI, so I had to drop that part of the idea. However, I will say that I have learned more about the security involved with social media APIs.
Trying out the Source CodeNeeded Tools
Before you get started, make sure you have the following:
Hardware
- any Amazon Echo device
Software
- node.js - used for testing your code on your computer
- GitHub account - used for holding your code for Heruko to download from
- Amazon account - used for making your Alexa Skill
- IBM Bluemix account - used for the finding the intended emotions from the inputted tweet
- Heroku account - used for deploying your server code to a remote website (if you are using AWS Lambda, you won't need this)
Node
Make an empty directory, run the command npm init
, follow the instructions given, and then type the following:
npm install --save alexa-utils watson-developer-cloud
This will install the needed dependencies to run the app. Now make a JavaScript file to contain your server code, and a Procfile (no extension), for allowing Heroku to run your code on the web.
GitHub
Make a new repository WITHOUT THE README.md! Then push your current code to the repository. If you do want a README.md, make sure to pull from the repository so that your local copy of the code is consistent with the remote copy.
Amazon Alexa Skill
Let's make our first Alexa skill. Go here, create a new skill, and fill out the needed information and follow the website's instructions. For the intent schema, which defines the functions and their parameters, you can use the following:
{
"intents": [
{
"intent": "CheckPost",
"slots": [
{
"name": "post_text",
"type": "AMAZON.LITERAL"
}
]
}
]
}
You won't need to create a custom slot type, so you can ignore that. However, you will need to specify an utterance, which is like a formula for how the Echo should interpret your input. Here's what mine looks like:
CheckPost to review this post {I love this lipstick so much|post_text}
CheckPost to advise me on this post {I feel that sometimes Donald Trump can be a real pain in the neck|post_text}
CheckPost to give insight on this post {So excited that I am done with high school|post_text}
CheckPost to review my post {Anybody down to watch the latest Silicon Valley episode together|post_text}
CheckPost to advise me on my post {I wish Micheal Jackson were still alive|post_text}
CheckPost to give insight on my post {God help us from this horrible political mess that is the upcoming election|post_text}
IBM Bluemix
Create an app for it, and save the username and password of the service credentials, NOT your account credentials, since, you'll need it for using the Bluemix API as follows:
var ToneAnalyzerV3 = require('watson-developer-cloud/tone-analyzer/v3');
var toneAnalyzer = new ToneAnalyzerV3({
username: 'INSERT_SERVICE_USERNAME',
password: 'INSERT_SERVICE_PASSWORD',
version_date: '2016-05-19'
});
Heroku
Create an app on the website, link it to your GitHub repository, and enable "Automatic Deploys", which allows you to update the remote code sitting on Heroku's servers and thus update your app every time you make a commit to your GitHub repository. Now you remember the Procfile that I talked about earlier? Well edit it so that its contents say:
web: node <JS_file_name>
where <JS_file_name>
refers to the name of the JavaScript file which has the server code. More info on deploying your node.js apps on Heroku can be found here.
Comments