This project has been developed as a support of NodeConfEu 2018 workshop "OK GOOGLE, HOW TO BUILD A NODE.JS TRANSACTIONAL APPLICATION ON GOOGLE ASSISTANT" :
- Part 0 : deploy an action sample using DialogFlow Online Editor
- Part 1 : use index.js from master branch to deploy a simple Node.js chatbot
- Part 2 : use index.js from transaction branch to deploy a transactional Node.js chabot
- Possible bonus and branches
- Add suggestion chips
- Default Fallback Intent : count how many times a user message was not recognized and adapt the bot answer
- Add cardinal entities to pick_kitten intent in order to recognize which kitten has been selected without using the carousel
- ask for user address and include it the transaction order
- Set a surface handoff from Google Home to a device having a screen
- Handle transaction fallback (user refused the order) and suggest to pick a new kitten
- Use app.middleware and i18n package to localize your app
Slides: http://bit.ly/ga-nodeconfeu2018
Copied from https://github.com/actions-on-google/dialogflow-transactions-nodejs/
- Use the Actions on Google Console to add a new project with a name of your choosing and click Create Project.
- Click Skip, located on the top right to skip over category selection menu.
- On the left navigation menu under BUILD, click on Actions. Click on Add Your First Action and choose your app's language(s).
- Select Custom intent, click BUILD. This will open a Dialogflow console. Click CREATE.
- Click on the gear icon to see the project settings.
- Select Export and Import.
- Select Restore from zip. Follow the directions to restore from the Transactions.zip file in this repo.
- Deploy the fulfillment webhook provided in the functions folder using Google Cloud Functions for Firebase:
- Follow the instructions to set up and initialize Firebase SDK for Cloud Functions. Make sure to select the project that you have previously generated in the Actions on Google Console and to reply
N
when asked to overwrite existing files by the Firebase CLI. - Run
firebase deploy --only functions
and take note of the endpoint where the fulfillment webhook has been published. It should look likeFunction URL (transactions): https://${REGION}-${PROJECT}.cloudfunctions.net/transactions
- Follow the instructions to set up and initialize Firebase SDK for Cloud Functions. Make sure to select the project that you have previously generated in the Actions on Google Console and to reply
- Go back to the Dialogflow console and select Fulfillment from the left navigation menu.
- Enable Webhook, set the value of URL to the
Function URL
from the previous step, then click Save. - Select Integrations from the left navigation menu and open the Integration Settings menu for Actions on Google. Click Manage Assistant App, which will take you to the Actions on Google Console.
- On the left navigation menu under DEPLOY, click on Directory Infomration.
- Add your App info, including images, a contact email and privacy policy. This information can all be edited before submitting for review.
- Check the box at the bottom to indicate this app uses Transactions under Additional Information. Click Save.
- Set up a payment method for your account in the Google Assistant settings on your phone if you haven't set one up already.
- Return Actions on Google Console, on the left navigation menu under Test, click on Simulator.
- Click Start Testing and select the latest version (VERSION - Draft).
- Type
Talk to my test app
in the simulator, or sayOK Google, talk to my test app
to any Actions on Google enabled device signed into your developer account. - Follow the instructions below to test a transaction.
- To test payment when confirming transaction, uncheck the box in the Actions console simulator indicating testing in Sandbox mode.
For more detailed information on deployment, see the documentation.
Deploy transaction branch, setup actions and intent, and test the application
- Pick a kitten in the carousel or say/type either
check transaction with action payment
- It must be confirmed that the user can transact.
- To confirm the transaction, simply say/type
confirm transaction
. Here, thetransaction_decision_action
intent will be handled inindex.js
. - You should see a transaction receipt, and a final confirmation of the order.
If the app isn't working, try the following:
- Make sure your Actions console project has filled App Information section, including name, images, email address, etc. This is required for testing transactions. After changing this, you may need to re-enable testing in the Actions console.
- Make sure your Actions console project indicates that it is using Transactions using the checkbox at the bottom of App Information
- The full transactions flow may only be testable on a phone.