As part of our research in Personal Robots Group we explore how children interact and learn with personal assistants, robots and smart toys that are becoming more and more common in their homes. We discovered that they would get frustrated when Alexa didn't know how to answer their questions and we decided to build a skill that would allow them to personalize and customize the interaction with Alexa and make it a real personal chat bot.
What it does
Currently the Alexa Scratch skill is integrated with the Alexa Scratch extension we built for Scratch 3.0 which can be run from any mobile device or computer. Currently the Alexa Extension allows users to :
- teach it answers to questions
- share with it their preferences (favorite color, movie etc)
- leave messages
- execute specific blocks on scratch
- communicate with other extensions like Jibo, Wemo plu, Spotify etc
How we built it
We have a NodeJS backend which hosts our REST APIs. We are using Express Framework to write these APIs easily. To store data, we are using MongoDB, a NoSQL database. We access mongoDB from NodeJS server using mongoose module. We also have a WebSocket server running on the same NodeJS server. We use socket.io module for this purpose. Our websocket server is used to communicate with our Scratch client.
When a user logs in through Scratch, the user is given a 5-digit access code. The user can use this access code to login through Alexa using his/her voice. The scratch client connects to the websocket server and sends a registration request containing the access code. The Websocket server identifies the user using the access code and saves the current socket ID of the user.
When the user asks the answer to a question about himself/herself, alexa skill makes a request to the express server with the authentication token of the user that the skill has received after logging in using the access code. This authentication is unique to every user and is used for further requests to save or get details regarding the user. When the user asks alexa skill to run a block set on the Scratch extension, the request is sent to the express REST API with the users authentication token. The NodeJS server identifies the user using this authentication token, gets the current socket ID of the user, and sends the run block set command to the Scratch client using the active socket connection.
Challenges we ran into
- Finding a way to get Alexa to run specific commands (like executing blocks on Scratch) - currently hardcoding block set 1, 2, 3 in the interaction code
- Allow users to create and account easily and connect to it via voice
- Access other skills Alexa has via the sdk
Accomplishments that we're proud of
- Integration with other scratch extensions
- Enabling ongoing conversation thread once the user is logged in
What we learned
so many things... how to debug across oceans and how important it to actually have an echo dot :)
What's next for Alexa Scratch Skill
more blocks, easier ways to connect
Try it !
Click on the link bellow, add extensions button at the bottom left and add Alexa extension https://stefania11.github.io/scratch-gui/
The skills was certified and you can try this now on your own device by saying:
"Alexa open Personal Chatbot"
Credits: we built the Alexa Extension for Scratch 3.0 by using the open source code for Scratch Blocks, Scratch VM and Scratch GUI provided by Lifelong Kindergarten Research Group at MIT Media Lab and by referencing their documentation for Scratch Extensions.