TL;DR;
Play games with connected cups and Alexa.
Alexa + π» = π
We wanted to see if we could introduce Alexa into social occasions such as drinking and games. Lumos Maxima attempts to do this by hooking up some cups with a few lights and ESP8266 Wi-Fi microchips.
How it works:
Some Uses Cases:
- Parties
- Night clubs
- Team games
- Game nights
- Assign cups (never lose your cup again) e.g. "Alexa, where is Magic Mike's cup"
Why with an App?
The app introduces some fun custom features such as allowing you to name each cup (opening up a lot of fun possibilities and games) and controlling each cup individually. It also allows you to play the games without Alexa.
Taking it further
We plan to build out the games and continue to develop the prototype. Currently on our todo list:
- Add battery back to each node (currently we power it via USB)
- 3D print base that can attach to various cups (replace the cardboard/plastic bags)
- Replace the plastic cups for some nice glass tumblers or mugs
- Add support for additional bot platforms (slack useful during work etc.)
- Trivia questions with score keeping
- Name games using the nicknames assigned from the app
- Split people into teams
- VOS games
- Sentence forming games
- Add buttons or other sensors to cups to enhance gameplay
The Alexa Skill is currently being published. We will add a link here once its ready. In the mean time you can build it yourself using the source code. There are three parts to the project. 1) VUI 2) Native App and 3) Arduino Hardware. Checkout the README in each folder for instructions on how to get setup.
---Building The Cups---Each cup runs as a node and defaults to being a "Slave". This means that they can receive commands or pass them on but cannot give commands. The cup that runs as the "Master" node can give the commands and is connected directly to the controller via the `RX` and `TX` pins on the boards (see below). The wiring to the LED and node is identical for all cups.
The cups communicate via a private wireless mesh network that the nodes make. This allows for near instant communication allowing us to create some cool light syncing effects.
The controller connects to the local wifi (setup via the app) which allows it to then connect directly to Firebase. The controller then waits for commands and also sends updates of the cups current status. The commands can be sent via Alexa or the App.
---Building The VUI---Developed using the following stack:
- Dialogflow
- Firebase
- Firebase function + AWS Lambda API Gateway and Alexa Skills Set function
Assuming you have Dialogflow, Firebase, and or AWS account access
Dialog FlowI. Create DIALOGFLOW AGENT
- Create new Agent in DialogFlow from the console
- You can either import the intents 1 by 1 or zip
assets/dialogflow
folder and import it.
- to import, cleck on
gear
icon on right panel next to the agent name
- click on
Export and Import
tab
- click on
IMPORT FROM ZIP
button, and upload the zip file
II. Setting up Dialogflow Agent webhook fulfillment - click on Fulfillment
menu on the left side of your console - toggle enabled
switch to enable webhook - enter the URL of webhook end point - fill up the necessary authentication detail for the webhook access, for AWS Lambda webhook, add x-api-key
as one of the header, and grab API key from AWS API Gateway console - select Enable webhook for all domains
for DOMAINS - P.S: 2 code base options available, can either use Firebase functions
or AWS Lambda API Gateway
I. Importing Data
- go to Realtime Database console
- click on
menu icon on the right side (three dots icon)
, click onimport JSON
- JSON file is located at
assets/firebase/realtime-db-data.json
II. Deploying Firebase function (should you choose Firebase function as your agent webhook fulfillment)
- Pre-requisite
- install Firebase CLI
npm install -g firebase-tools
- once done, login to your firebase account by running
firebase login
in your terminal
- Deployment
- go to
firebase-webhook/.firebaserc
and key in your firebase project ID and save the file
- open your terminal and go to
firebase-webhook/functions
, and do the following:
- run
npm install
- run
firebase deploy
- take note that on first deployment, it will take longer time than the subsequent deployment.
- once the deployment is done, grab the firebase function url, and use that url as the Dialogflow fulfillment webhook URL
I. Deploying AWS Lambda API Gateway function - Dialogflow webhook (should you choose AWS Lambda API Gateway function as your agent webhook fulfillment)
- AWS Lambda Console
- go to AWS Lambda console
- create a new function
- Fill up all the function details i.e. name, role.
- choose
Node.js 6.10
as Runtime
- choose
Author from scratch
- click on
Create function
button
- it should bring you to the next step, add API Gateway triggers (in Designer section, left panel, there is a list of available triggers)
- Next, you will need to configure the triggers:
- Enter your api name, e.g.
test-api
- Choose
Open with access key
as yourSecurity preference
- Click on
Add
buttons
- Save the function
- it should generate an invoke url, use that url as the Dialogflow fulfillment webhook URL
- Now for the code deployment:
- on your machine, go to
aws-lambda-webhook
folder
- create a folder called keys, put the firebase service key file and name it
firebase-service-key.json
+ create a file calleddatabase-details.js
and add in the following content
module.exports = { databaseURL: '[FIREBASE database URL]'};
- once done, run
npm install
- run
npm run zip
- it will create a zip folder called
aws-lambda-webhook.zip
- back to the AWS Lambda console, on the function settings page, under
Designer
section, click on the function name button from the graph
- under
Function code
section > Code entry type, selectUpload a .ZIP file
- upload the zip file
- save the function
- it will take a while to deploy
- API Gateway Console
- look for the api name e.g.
test-api
, and click onresources
- under
actions
drop down menu, create method forPOST
request
- set lambda region as
us-east-1
+ enter the lambda function name associated with this API
- click on save
- it will load
POST
method dashboard, go toMethod Request
- set
API Key Required
to true
- add in new headers called
x-api-key
and set is asrequired
- follow the instructions from this blog to create request object mapping
- once done, create API Keys, from left menu panel, click 'API Keys'
- under
actions
drop down menu, create API Key
- go to
Usage plans
, from left menu panel, click 'Usage plans'
- create new usage plan
- enter usage plan name
- set the rest of access limit related stuff and save
- from the usage plans dashboard, add API stage.
- once done, go to API Keys tab and add API key to the usage plan
II. Alexa skills
- Amazon Developer console - Creating custom Alexa skills
- go to Amazon Developer Console and login
- click on
Alexa
tab > click onGet started
on alexa skills > Add a new skill
- enter skill information details, and go to next step (Interaction Model)
- enter both
Intent schema
+Sample utterance
by referring to the assets file provided atalexa-skills/assets
- under
Configuration
steps, fill up the AWS Lambda ARN details
- and... done!
- AWS Lambda Console
- go to AWS Lambda console, make sure to set the region to US East (N.Virginia)
- create a new function
- Fill up all the function details i.e. name, role.
- choose
Node.js 6.10
as Runtime
- choose
Author from scratch
- click on
Create function
button
- it should bring you to the next step, add Alexa Skills Kit triggers (in Designer section, left panel, there is a list of available triggers)
- Next, you will need to configure the triggers:
- enter alexa skill ID (grab it from Amazon Developer Console > alexa skills)
- save it
- Now for the code deployment:
- on your machine, go to
alexa-skills
folder
- create a folder called keys, put the create a file called
alexa-dialogflow-keys.js
and add in the following content
module.exports = { alexaAppId: '[alexa APP ID]', apiAIDeveloperAccessToken: '[dialogflow developer access token]'};
- once done, run
npm install
- run
npm run zip
- it will create a zip folder called
alexa-skills.zip
- back to the AWS Lambda console, on the function settings page, under
Designer
section, click on the function name button from the graph
- under
Function code
section > Code entry type, selectUpload a .ZIP file
- upload the zip file
- save the function
- it will take a while to deploy
- ready to test!
Standard compliant React Native App Utilizing Ignite
Step 1: git clone this repo:
Step 2: cd to the cloned repo:
Step 3: Install the Application with yarn
or npm i
- cd to the repo
- Run Build for either OS
- for iOS
- run
react-native run-ios
- for Android
- Run Genymotion
- run
react-native run-android
This project uses react-native-config to expose config variables to your javascript code in React Native. You can store API keys and other sensitive information in a .env
file:
API_URL=https://myapi.comGOOGLE_MAPS_API_KEY=abcdefgh
and access them from React Native like so:
import Secrets from 'react-native-config'Secrets.API_URL // 'https://myapi.com'Secrets.GOOGLE_MAPS_API_KEY // 'abcdefgh'
The .env
file is ignored by git keeping those secrets out of your repo.
- Copy .env.example to .env
- Add your config variables
- Follow instructions at https://github.com/luggit/react-native-config#setup
- Done!
Comments