Giter VIP home page Giter VIP logo

dialogflow-transactions-nodejs's Introduction

Actions on Google: Transactions Sample

This sample shows everything you need to facilitate transactions for your Action in Node.js, including:

  • Check for transaction requirements
  • Get the delivery address
  • Confirm the transaction
  • Examples of Google Pay and merchant-managed payment options
  • Asynchronously update order status at any time (via order-update.js)

Setup Instructions

Action Configuration

  1. From the Actions on Google Console, add a new project (this will become your Project ID) > Create Project > under More options > Conversational
  2. In order to test out a transactions-based sample the following info must be provided. In the Actions console, from the left navigation menu under Deploy > Directory Information >
  • Images > add a small logo image
  • Contact details > add Developer email
  • Privacy and consent > add link to Privacy Policy
  • Additional information >
    • Select a Category
    • Do your Actions use the Transactions API to perform transactions of physical goods? > Yes > Save.
  1. From the left navigation menu under Build > Actions > Add Your First Action > BUILD (this will bring you to the Dialogflow console) > Select language and time zone > CREATE.
  2. In Dialogflow, go to Settings ⚙ > Export and Import > Restore from zip.
    • Follow the directions to restore from the agent.zip file in this repo.

Firebase Deployment & Webhook Configuration

  1. Install Firebase CLI
    • npm install -g firebase-tools
  2. Firebase SDK for Cloud Functions
    • firebase login
    • cd functions/
    • npm install
    • firebase init functions
      • What language would you like to write Cloud Functions > JavaScript
      • File functions/package.json already exists. Overwrite? > No
      • File functions/index.js already exists. Overwrite? > No
    • firebase deploy
  3. Copy the endpoint where the fulfillment webhook has been published:
Function URL (webhook): https://<REGION>-<PROJECT_ID>.cloudfunctions.net/webhook
  1. In Dialogflow Console > Fulfullment > Enable Webhook > Set URL to the Function URL that was returned after the deploy command > SAVE.

Testing this Sample

  1. From a mobile device > Assistant app > Personal Info > Payments > Set up a payment method for your Google account associated with this project.
  2. In the Dialogflow console, from the left navigation menu > Integrations > Integration Settings under Google Assistant > Enable Auto-preview changes > Test to open the Actions on Google simulator OR
  1. From the Simulator, ensure that you are testing in Development Sandbox: Enabled mode
  2. Type Talk to my test app in the simulator, or say OK Google, talk to my test app to Google Assistant on a mobile device associated with your Action's account.

Order Update Configuration (order-update.js)

  1. From the Dialogflow's 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 Actions API > Enable
  4. Under Menu ☰ > APIs & Services > Credentials > Create Credentials > Service Account Key.
  5. From the dropdown, select New Service Account
    • name: service-account
    • role: Project/Owner
    • key type: JSON > Create
    • Your private JSON file will be downloaded to your local machine
  6. In order-update.js, insert the file path to your key.
  7. In order-update.js, replace the <UNIQUE_ORDER_ID> placeholder string assigned to actionOrderId with the ID of the order you wish to update.
    • Similarly, ensure that the variable UNIQUE_ORDER_ID matches between index.js and order-update.js
  8. Run the script to send an order update by opening a terminal and running the following command: node order-update.js.

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-transactions-nodejs's People

Contributors

smishra2 avatar canain avatar taycaldwell avatar atulep avatar aotarola avatar norulesjustfeels avatar fleker avatar silvolu avatar

Watchers

James Cloos avatar Waker Mahmud avatar

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.