Alexa Integration Case Study
This article was contributed by the student(s) below to share their experience at the Digital Corps. Want to write something like this? Talk to a staff member!
This case study reviews how the Development Team created an Alexa skill to celebrate when Digital Corps employees finished a project.
Overview
- When a project is finished, a user will initiate the celebration by telling Alexa, “Alexa, we just finished a project”
- Alexa will respond with “What project did you finish?”
- User responds by saying the project name
- Alexa will respond “Congratulations team on finishing the {x} project, press the Echo button to begin the celebration.”
- User will press Echo button
- Alexa will say, “Whoop whoop!”
- Philips Hue lights will change colors
- An animation will appear on office TV boards
- A short audio event will play through the TV board speakers
How is it connected?
Amazon Echo
When the user invokes the Alexa skill by saying, “Alexa, we just finished a project”, the AWS lambda function will trigger.
AWS Lambda Function
To access the code in the AWS Lambda function, sign into the proper AWS Console using the digitalcorps@bsu.edu email. The code inside this function controls the Alexa skill and connects to the Firebase API.
Firebase API
To access the code in the Firebase API:
Go to go Firebase console and sign in using bsu.digital.corps@gmail.com. Go to the DigitalCorpsAutomation project.
In the side menu, underneath Develop, click on Functions.
On this page, you should see two functions: alexaCelebrateReact and scheduledFunction. Click on the three dots next to each function and choose Detailed Usage Stats.
This will take you to a page with all the information about the function. Under the Source tab you can view the full code for the function.
Summary of Functions
alexaCelebrateReact – Calls the “hueLogin” table from the Firebase database to get the login information and then changes the lights when the table “alexaCelebrate” updates (Updating that table is what the AWS lambda function does).
scheduledFunction – Every 5 minutes, makes a call to the Philips Hue API in order to get new login tokens that it then pushes to the table “hueLogin” in the database.
Firebase Database
To view the Firebase database, click on Database underneath Develop on the Project Overview page. Next, click View under Realtime Database
TV Board
The TV board will play an animation when the alexaCelebrate table in the Firebase database is updated. The table is checked through the website displayed on the TV board. The code snippet below shows the addition to useEffect, starting after the line loadSlideData() and ending with firebase.database().ref. The alert statement in the inner if statement is what will call the component to display the celebration TV panel.
Setting up the Hue Bridge and Connecting to Alexa
The bridge cannot be set up on campus because of the firewall. Someone who doesn’t have a bridge already connected to their Hue account needs to take the bridge home and set it up. Instructions on how to set up the bridge can be found on the Philips Hue website. To connect the bridge to Alexa, you will need to use the Alexa app. Choose “Add devices” in the app and select Philips Hue underneath “Popular Brands”. The bridge that is currently being used was set up with the Philips Hue account associated with bsu.digital.corps@gmail.com.
Alexa App
The Alexa app can be used to control the Philips Hue lights in the office. There is a group for each lamp and the LED strips. The individual lights can be accessed as well.
The app can also create what is called a Routine through Alexa. Routines are essentially a group of actions that Alexa will do. Routines can be scheduled through the app to occur at a certain time. Right now, there is a scheduled routine that will turn off all of the lights at the end of the day.
Buttons
The office currently has two Echo Buttons. These are rather indistinguishable from each other, so it is important to keep the proper button in the right spot, so as not to confuse the user. For the time being, the button used for the skill will be located under the TV board furthest away from the front desk. In the future, we will add names and an indication of where each button should be to the bottom of the button. Adding buttons is simple — just use the Alexa App, navigating to devices, then add devices, and follow the onscreen instructions. The Alexa API offers a “simple” way of detecting when a specific button is pressed. Look in the lambda function for more details, or read the documentation.
Receiver and Yamaha API
The office receiver is a large box capable of controlling the office surround sound speakers, as well as video input to the projector closest to the front desk. Ideally, the receiver can be used as a bluetooth speaker for the Alexa, though we have currently been unsuccessful at pairing the two together. This model has a settings panel which can be accessed by navigating to 10.30.52.154 in your browser. The receiver is connected to BC205, but accessing the settings panel can be done from any Ball State network, and will not work from any outside network.
The Yamaha API, which controls the receiver’s functions, is also housed on the device itself. This means the API can only be called from a firewall-safe server. To combat this, a bypass endpoint has been made on the prod-digitalcorps server.
This bypass endpoint just forwards a GET request as is. It does not work with any other HTTP request type. Here is the documentation for the API.
Roomba
Although the office does not have a Roomba because it “wasn’t in the budget”, it is important to note the plans and research done into the component of the system. The iRobot Roomba 690 is recommended due to it’s API options, and Alexa connectivity. Although there is no direct Roomba API, connecting to it via the Alexa API would more than solve the problems we have with such a robot. A challenge for future developers on this project is to think big when adding this piece of the puzzle. What does it mean to be a “Party Roomba”? Also, please oblige Seth when purchasing this Roomba by naming her Judy, and sending a picture to sethrcamp@gmail.com.
Complications
Thank you for your patience in this troubling time. The Alexa App is stable and recovering, but the damage was significant, and future developers will have to face many challenges just to survive. The process of transplanting a smart home system into an office space was successful, but the strain on the network security means you will have to visit home to set up and configure any hardware before use. The app has also been prescribed a number of separate accounts through different services to promote its overall health. All of these accounts, and future accounts, should be registered under the Digital Corps. Otherwise, there may be a lapse in insurance coverage, and you DO NOT want to see the out of pocket costs without aid!
What we learned
For something that started mostly as a joke, “haha wouldn’t be cool to have the office go crazy when we ring the bell,” we have actually made something pretty cool, and much more complicated than we could have imagined, primarily due to the limitations imposed by the campus network infrastructure – definitely necessary for the enterprise, but something that does not play well with smart devices for the home. This will get better with time, but do not assume that if something is possible with Alexa that it is also feasible for us to do.
Alexa works well with simple things in the home, and sure there are more complicated skills out there, but not many from small companies. I (Seth) would encourage you to think outside the box, but not too far. Stay within a foot of the box to be safe. Although we don’t think of a virtual assistant as “new tech” like we do AR or VR, it is still new, and the possibilities are slowly growing. After all, imagine trying to set all of this up without the Alexa API to sew everything together! I think the best approach for using Alexa in the future is to ask “can Alexa help us” instead of “can we make Alexa do this”.