Skip to content

jlengrand/dialogflow-fun

Repository files navigation

DialogFlow fun

CircleCI

This repository contains the code used in my "Hey Google, send 20$ to Mum" talk at JFuture in November 2019. You can find the slides of this talk in this other repository.

It is not directly possible for you to just clone this repository and get it working because it depends on environments that I used for the talk. I deploy my app on Google App Engine and some of the credentials are privately stored. The whole dialogflow agent will also be created live, except for the contact entity.

Technology used

  • The backend for this talk is built using Java 11. I wanted to use Kotlin for a while but decided to have some Java fun instead.
  • The backend is a simple Spring Boot REST application. Great to start kicking fast.
  • The virtual assistant used is Google's dialogFlow.
  • The Banking PSD2 demo is built on top of the OpenBankProject. They provide a nice 'Bank as a service' API with cool sandboxes, and some are PSD2 compliant.

Some pointers in the code

The project is composed of several modules.

  • The agent folder contains a zipped version of the DialogFlow agent I will build live. You should be able to import it.
  • The dialogflow-fun-agent module contains a few routines that interact with an agent using the DialogFlow API.
    • The CreateAgent class especially creates an agent based on input from a text file.
  • The dialogflow-fun-api module contains a simple REST API that the DialogFlow agent will interact with. It is the 'backend' of the application.
    • The backend is essentially a proxy between the DialogFlow fulfillment requests on one hand, and the OpenBankProject sandboxes on the other hand.
    • The entry point of the application is DialogFlowFunApiApplication. It hosts the controller used for the Agent fulfillment.
    • Most of the PSD2 magic happens in the OpenBankClient class. It is a simple class that makes authenticated REST GET and POST calls to the sandbox under the hood.
    • The DialogFlowService class is tasked with converting fulfillment requests into fully fledged PSD2 API calls.
    • The UserAccountLookup class is a dirty trick used for the demo to link users and bank accounts. This would have to be done differently for an actual app :).

Useful references (for potential readers of this repo :)

Missing information

If you want to run the code yourself, you'll need to have an OpenBankProject account and update the dialogflow-fun-api/src/main/appengine/app.yaml file to contain the following (with updated values):

env_variables:
  OPENBANKPROJECT_USERNAME: 'yourUsername'
  OPENBANKPROJECT_PASSWORD: 'Bnj0VyuI127SN7yjwfwfet'
  OPENBANKPROJECT_CONSUMERKEY: 'c4vkdziyokjfhwekfjhwek50oblsolo5f1g1k2tdyu2'

Google Resources (for me to remember before the talk)