Giter Club home page Giter Club logo

dialogflow-name-psychic-nodejs's Introduction

Actions on Google: Name Psychic Sample

This sample demonstrates Actions on Google features for use on Google Assistant including permission requests for user information, surface transfer capabilities, user storage, SSML, unrecognized deep link fallbacks, and Google Maps Static API -- using the Node.js client library and deployed on Cloud Functions for Firebase.

Note that if the user is not verified, their information will never be saved across conversations and they will encounter a guest flow (requesting permission) each time.

Enable Billing

Required for running this sample

This sample uses Firebase Cloud Functions to make an HTTP request to Google Maps Static API. If you plan to run the sample, you will need to temporarily upgrade to a Firebase plan that allows for outbound networking, such as the Blaze Plan, also called Pay as you go.

Setup Instructions

Prerequisites

  1. Node.js and NPM
    • We recommend installing using NVM
  2. Install the Firebase CLI
    • We recommend using version 6.5.0, npm install -g [email protected]
    • Run firebase login with your Google account

Configuration

Actions Console

  1. From the Actions on Google Console, New project (this will become your Project ID) > Create project > under More options > Conversational
  2. From the top menu under Develop > Actions (left nav) > Add your first action > BUILD (this will bring you to the Dialogflow console) > Select language and time zone > CREATE.
  3. In the Dialogflow console, go to Settings ⚙ > Export and Import > Restore from zip using the agent.zip in this sample's directory.

Cloud Platform Console

  1. From the Dialogflow console > go to Settings ⚙ and under the General tab > go the Project Id link, which will take you to the Google Cloud Platform console
  2. In the Cloud console, go to Menu ☰ > APIs & Services > Library
  3. Select select Maps Static API > Enable
  4. Under Menu ☰ > APIs & Services > Credentials > Create Credentials > API Key and copy the key.

Firebase Deployment

  1. On your local machine, in the functions directory, run npm install
  2. Run firebase deploy --project {PROJECT_ID}, replace {PROJECT_ID} to deploy the function
  3. Run firebase functions:config:set maps.key={API_KEY} --project {PROJECT_ID}, replace {API_KEY} with the generated API key from earlier and redeploy the function.
    • To find your Project ID: In Dialogflow console under Settings ⚙ > General tab > Project ID.
  4. Return to the Dialogflow Console > select Fulfillment > Enable Webhook > Set URL to the Function URL that was returned after the deploy command > SAVE.
    Function URL (dialogflowFirebaseFulfillment): https://${REGION}-${PROJECT_ID}.cloudfunctions.net/dialogflowFirebaseFulfillment
    
  5. From the left navigation menu, select Integrations > Integration Settings under Google Assistant > Enable Auto-preview changes > Test to open the Actions on Google simulator then say or type Talk to my test app.

Running this Sample

  • You can test your Action on any Google Assistant-enabled device on which the Assistant is signed into the same account used to create this project. Just say or type, “OK Google, talk to my test app”.
  • You can also use the Actions on Google Console simulator to test most features and preview on-device behavior.

References & Issues

Make Contributions

Please read and follow the steps in the CONTRIBUTING.md.

License

See LICENSE.

Terms

Your use of this sample is subject to, and by using or downloading the sample files you agree to comply with, the Google APIs Terms of Service.

dialogflow-name-psychic-nodejs's People

Contributors

atulep avatar canain avatar norulesjustfeels avatar silvolu avatar smishra2 avatar taycaldwell avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dialogflow-name-psychic-nodejs's Issues

missing key prop on the config object.

Following the instructions, i was getting this:

actions-on-google/dialogflow-name-psychic-nodejs/functions
> eslint --fix "**/*.js"

✔  functions: Finished running predeploy script.
i  functions: ensuring necessary APIs are enabled...
✔  functions: all necessary APIs are enabled
i  functions: preparing functions directory for uploading...

Error: Error occurred while parsing your function triggers.

TypeError: Cannot read property 'key' of undefined
    at Object.<anonymous> (/Users/baskint/src/actions-on-google/dialogflow-name-psychic-nodejs/functions/index.js:25:25)
    at Module._compile (module.js:660:30)
    at Object.Module._extensions..js (module.js:671:10)
    at Module.load (module.js:573:32)
    at tryModuleLoad (module.js:513:12)
    at Function.Module._load (module.js:505:3)
    at Module.require (module.js:604:17)
    at require (internal/module.js:11:18)
    at /usr/local/lib/node_modules/firebase-tools/lib/triggerParser.js:18:11
    at Object.<anonymous> (/usr/local/lib/node_modules/firebase-tools/lib/triggerParser.js:38:3)

Upon inspection, if we change the line 25 of functions/index.js file to this, we get our API key back.
key: config.map.key
After this change, I was able to deploy the firebase function.

  functions: Finished running predeploy script.
i  functions: ensuring necessary APIs are enabled...
✔  functions: all necessary APIs are enabled
i  functions: preparing functions directory for uploading...
i  functions: packaged functions (42.29 KB) for uploading
✔  functions: functions folder uploaded successfully
i  functions: creating function namePsychic...
✔  functions[namePsychic]: Successful create operation.
Function URL (namePsychic): https://***

✔  Deploy complete!

Now test simulator is crapped out, but that is across all the Google Action projects. Oh well.

Query pattern missing

@Fleker Why I'm getting this error while publishing app for Production.

Query pattern is missing for custom intent 'handle_permission

multi-user compatible?

Is the intention that this will work for multiple different users on the same device? When my wife and I each just ask GH what our name are, it gets it right. However, when she uses name psychic it gets it wrong. Does the code need to change to support multi-users?

Thanks!

Default welcome Intent

Is it possible to comment out Default welcome Intent in index.js and let Dialogflow handle Welcome Intent. I'm getting an error when I comment out line 154-159 in index.js

Error: Dialogflow IntentHandler not found for intent:
...
...
...

Unable to deploy to gcloud

I have been trying to deploy this to gcloud but I keep getting the same errors. Please help!

sh: 1: functions: not found

npm ERR! Linux 3.16.0-4-amd64
npm ERR! argv "/nodejs/bin/node" "/nodejs/bin/npm" "start"
npm ERR! node v6.0.0
npm ERR! npm v3.8.6
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! [email protected] start: functions deploy namePsychic --trigger-http
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the [email protected] start script 'functions deploy namePsychic --trigger-http'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the name-psychic package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! functions deploy namePsychic --trigger-http
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs name-psychic
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls name-psychic
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR! /app/npm-debug.log

i am getting these errors after clicking deploy , i have copied code from index.js and pack.js

The deployment of your Cloud Function failed:
Function load error: Code in file index.js can't be loaded.
Did you list all required modules in the package.json dependencies?
Detailed stack trace: Error: Cannot find module './util'
at Function.Module._resolveFilename (module.js:476:15)
at Function.Module._load (module.js:424:25)
at Module.require (module.js:504:17)
at require (internal/module.js:20:19)
at Object. (/user_code/index.js:25:16)
at Module._compile (module.js:577:32)
at Object.Module._extensions..js (module.js:586:10)
at Module.load (module.js:494:32)
at tryModuleLoad (module.js:453:12)
at Function.Module._load (module.js:445:3)

Update readme.md

Please, update the readme.md to reflect the idea of the project and main purpose

Hi @salismt,

Hi Silvano,

I must say first I just started Firebase and Action on Google.

Apparenlty I experience the same issue. But I think I might miss a step while deploying.
Here the steps I took at deployment
In the command window

  1. npm install -g firebase-tools
  2. firebase login
  3. firebase init functions -> Javascript -> all defaults
  4. firebase functions:config:set maps.key=""
  5. firebase deploy --only functions

You mentioned above, " removing data from the associated Firebase DB", however in the firebase console, firebase DB is not in use.....What am I missing?

Thanks

Originally posted by @silvolu in #3 (comment)

Default location?

I only receive Mountain View as my location? I get the location request as expected and the cloud function writes to the Firebase database but always Mountain View. Tested on Android and iOS version of the Google Assistant.

Should we save only the name to the DB?

We currently save the name and the location, but that means the location will always be the first one read, and it can create confusion as seen in #3.
We could re-write the sample to save only the name to the db, and get a fresh location every time it's requested.

@smishra2 @entertailion

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.