Class Note

  1. Create a new agent on Dialogflow ES ex) in class, fortune teller bot
  2. Create intents and entities No writing text responses, it's going to be from Webhook.
  3. Install Firebase CLI & in terminal, (node has to be installed!)
mkdir week4
cd week4
npm install -g firebase-tools 
//-g: globally intalling. 
//if not, it's install only in the directory

firebase
firebase login //open up a brower to log-in (the same dialog account)

//Once I log in
firebase init //make a project then all functions will show up
//space bar + enter to select a function

//Project ID that my project on Dialogflow has
//hit "Add Firebase to an existing Google account""
//=> Projects I made will show up in the terminal console and select the one I want.
//What language? =>select JavaScript
//ESLint? No
//install dependencies with npm? => Yes
//----------Firebase initialization complete-------------

ls
code . //=>opens up VS Code

After VS code initiates, go to index.js and keep the first line which is

const functions = require("firebase-functions");

//new code
const {dialogflow} = require("actions-on-google"); //mini libraries

const app = dialogflow();

//trigger
app.intent("Default Welcome Intent", (conv) => {
	conv.ask("HEY WHATS UP!!!"); //returning texts to Dialogflow
});

exports.fortuneTeller21 = functions.https.onRequest(app);
//fortuneTeller21: the name of Webhook (just name anything I want)

In terminal,

cd functions //go into functions folder in week4 folder
ls
npm intsall actions-on-google

//Deploy!
firebase deploy

On Dialogflow, click on Fulfillment → select on Webhook to enable it

Copy "Function URL" in terminal and paste it onto URL field under Webhook.

In Default Welcome Intent page, under Fulfillment, switch on "Enable webhook call ˜".

Create an entity to detect names ⇒ "@sys.name" shows up

//trigger an intent which is "get_fortune"
app.intent("get_fortune", (conv, params) => {
	//conv.ask("You're gonna have a cool life"); 
	//returning texts to Dialogflow

	conv.ask(`Hello, ${params.name}, what did you dream about last night`);
	//receive a name (params) and construct a sentence mixing with something else.)
});