I gained an interest over the summer of how to gain meaning from text. There was one SDK and one API that I wanted to experiment with: Facebook's SDK and Google's new API Perspective. I encountered the experimental API a few months ago, so when playing around with the SDK I realized I could integrate the two. The goal of the API is to see how we can better moderate comments online by measuring the "toxicity" of said comments, so I thought it would be a good fit for Facebook when people make posts.
What it does
When a user has a piece of text they want to check, the user sends the text to the Antydote bot. The bot extracts the contents of the message and sends it to the Perspective API. The API responds with a score between 0 and 1 for how toxic it is, with 1 being most toxic. Based on the outcome, the bot responds with the score as well as a comment based on the score's value.
How I built it
I used Node.js to build the backend for the bot and Express.js to host any routing requests. I hosted this code into an EC2 instance of Amazon Web Services and enabled HTTPS on it (Facebook's bot requires an HTTPS connection). In order to have the bot fully working, I needed to create a Facebook app and enable a callback URI for Messenger in order to read the messages for the user. Many of the calls for sending messages from the bot to the user were used with HTTP requests, while calls to the Perspective API were used with Google's googleapi NPM package.
Challenges I ran into
The biggest challenges involved understanding the Facebook Graph API. I wanted to incorporate webhooks where the user gives the app permission to read Facebook posts that the users make, then any time the user makes a post the bot sends a message with the score. However, it was difficult to understand the documentation in order to set up the app and there wasn't much information online in order to understand this process. Setting up the EC2 instance also took some time, but I never used AWS before today so that's understandable.
Overall, the code to make the bot itself wasn't too difficult. The timesink came from setting up the environment in order to get other features incorporated.
Accomplishments that I'm proud of
I'm proud that I was able to dive into new platforms (AWS, Facebook apps) and successfully create a prototype. Despite the problems, I was able to pivot when necessary to get a prototype finished on time while also learning about new technologies that I hadn't used before.
What I learned
You won't always be able to get the big, fancy, shiny product you want, but building a solid one with the same core goals is a good start.
What's next for Antydote
Building those webhooks!