The Workshop I leaded from AcademiesHack hackathon
Create a DialogFlow Agent which accepts end-user's queries. It extracts keywords (for example, the country name) from those queries and populates those keywords into a Firebase database. Next on Linux, it extracts those keywords from Firebase and displays it on Google Earth.
- Go to the Dialog Flow Website. Click Sign in wih Google, and sign in.
- In the Left Panel, click on Create Agent.
- A new window would have appeared in the middle of the page, at the top click on Agent name, and give your agent a name.
- Click on CREATE.
- After it creates, click on Entities on the left side of the page.
- Then click on Create Entity.
- Give your Entity a name by clicking on Entity Name, I named mine recognizeMotor.
- Make sure that Define Synonyms and Allow automated expansion are checked.
- Click on the first Click here to edit entry box.
- For Enter Reference value enter the keyword you're checking for, I named mine Motor
- For Enter Synonym enter words synonymous to your keyword
- Click Save, then navigate to Intents on the left side of the page.
- Then click on CREATE INTENT.
- Give your Intent a name by clicking on Intent Name, I named my intent activateMotor.
- Click on Contexts, followed by ADD CONTEXT. Now, type in an Input Context, I named mine ask_for_motor.
- Click on Actions and parameters, followed by ADD PARAMETERS AND ACTION.
- Under PARAMETER NAME, give it a name, I named mine Motor.
- Under ENTITY, type in your entity made before, so I typed in
@recognizeMotor
. - Under VALUE, type in your Parameter Name, so I typed in $Motor.
- Click SAVE.
- Under Training Phrases, followed by ADD TRAINING PHRASES, type in some Phrases your end users will say. For example Activate Motor (Make sure there is a motor, or somthing synonymous in each training phrase). Keep adding new training phrases, as your phrases get populated, DialogFlow will highlight the country names in yellow, if it doesnt double click the keyword.
- Scroll down to Fulfillment, followed by ADD FULFILLMENT, then check the Enable webhook call for this intent.
- Click on SAVE.
- Click back on Intents, then Default Welcome Intent.
- Under Contexts, leave the input context blank, for the output context type in the Input Context you set for your previous intent. For me it was ask_for_motor. (If you forgot the name of your input context, then click back on Intents, then your other Intent. You should see your input context there)
- Still in the Default Welcome Intent, scroll down to Responses. Type in
Hi! Tell me when you want to turn on the motor.
- Click on Save.
- Go to the Firebase Website. Click on Get Started and sign in to your Google Account.
- Under Your projects using Firebase, click on the project with the name of your Dialog Flow Agent.
- Under Discover Firebase, click on Get Started for the Database box.
- Scroll down and click on Cloud Firestone. 5.Scroll down to Realtime Database and then click on Create database
- On the top of the page, next to Database, make sure it says Realtime Databse, if it doesn't, click on the small downward facing triangle, and select Realtime Database.
- Make sure, you are under the data section, if not just click on data.
- You should see
null
, hover over that then click on the small plus icon. - For Name, type in a name, I named mine motor State
- Set the Value to the value which will change, I set mine to false*.
- Lastly, click on the Add button.
- Copy your database URL, it should end with .firebaseio.com/.
- Head back over to Dialog Flow.
- On the left panel, click on Fulfillment
- Enable the Inline Editor, by clicking the Enabled button.
- Make sure you are under index.js.
- Delete all the code currently in the Inline Editor, and replace it with this.
- In the code, replace FIREBASEURL with your database URL. When you copy your Database URL, remove the HTTPS://. It should look something like this:
ws://NAME.firebaseio.com/
. - In the code, replace NAME with the broad name from your database. Mine looks like this:
return admin.database().ref('motorState').transaction((location) => {
. - In the code, replace NAMEOFINTENT to what your intent name is. Mine looks like this:
intentMap.set('AskLocation', handleLocation);
- In the code, replace every occurence of (PARAMETER) to the name of your (PARAMETER). Mine was Motor
- Click on DEPLOY.
- After it deployes, you can test it out. On the Try it now field, type in a greeting (like hi, hello etc). It will respond
Hi! Tell me when you want to turn on the motor.
(Or whatever you set it to before). Then say something containing your keyword. It will respond.
Use the termial for the installation
- Install all updates
sudo apt-get update
sudo apt-get upgrade
- Install curl:
sudo apt-get install curl
- Install node.js:
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs
- Install Firebase CLI:
npm install -g firebase-tools
- Log in to Firebase:
firebase login
When you run this command, it will ask if Firebase can collect ULI usage and error, just typeY
Then it will open a window, there you log into your Google Account - Initialize your Firebase CLI:
firebase init
When you run this command, it will ask you which features to select, select all of them. To select click on space, and to go down click on the down key. Click enter when you finish selecting them all.
Next, it will ask you to set up a default Firebase project. Select the project which contains your database, from the Set Up Firebase Section.
After that, just keep clicking enter. Until it asks for what language to use.
Chose JavaScript
when it askes for what language to use for Cloud Function.
Then, type y
for when it askes if you want to use ESLint
Next, type Y
when it askes to install dependencies.
After that, click enter when it askes to use your public directory.
Then, type y
for when it askes to configure it as a single-page app.
Finally, click enter for when it asks about Storage Rules.
- On Linux, open the browser and go to the Google Earth download page.
- Download and install it, by using the default software install (or any other way to install it).
- Navigate to Google Earth folder:
cd /opt/google/earth/pro
- Edit drivers.ini file with Root privileges:
sudo nano drivers.ini
BetweenSETTINGS{
andCPUVertexBlendEfficiency = 1.2
, type in the following:;ViewSync settings
ViewSync/queryFile = /tmp/query.txt
ViewSync/send = true
Click Ctrl-X
ThenY
to Save - drivers.ini should look like this.
- Download Script:
wget https://raw.githubusercontent.com/MyWorldRules/LGxVoiceControl/master/LGScript.sh
- Edit Script
nano LGScript.sh
Use the arrow keys to go down tofirebase database:get /BROADNAME/country > messages.txt
. Replace BROADNAME with the Broad Name from the Firebase database.
Click Ctrl-X
ThenY
to Save - Give execute permission to the script:
chmod +x LGScript.sh
- Open Google Earth
- Run the script:
./LGScript.sh
Note: The first time you run the file, you will get a error. From the second time onward there will be no error. - To stop the script, simply click Ctrl-C