Actions on Google V2 vs. Dialogflow Fulfillment Node.js Libraries

Matt Carroll Mar 19, 2018

Disclaimer: I wrote the Dialogflow Fulfillment library and had significant design input into the Actions on Google v2 client library

TL:DR - if you want to make something for the Google Assistant, the Actions on Google v2 client library is the best you can get. If you don’t know what platform you’d like to start with or want to use multiple platforms (the Google Assistant and Alexa and Facebook Messenger) try out the Dialogflow fulfillment Node.js library.

In my last post, I went over my latest action for the Google Assistant that used Troy Hunt’s Have I Been Pwned API to tell you if your email or website was compromised in a data breach. To get a better feel for both the Actions on Google v2 library (currently in alpha) and the Dialogflow fulfillment library, I rewrote the fulfillment for “Been Pwned” twice, once using the the Actions on Google v2 alpha and the other using the Dialogflow fulfillment library beta. You can see the code on Github here. If you’d like to read about these two libraries seperately, you can see the Actions on Google v2 Alpha Medium post here and the Dialogflow Fulfillment Library Beta blog post here.

Multiplatform vs Actions on Google Only

The biggest difference with these two libraries is supported platforms. The Actions on Google library only supports on platform: the Google Assistant and supports the entirety of the API (and does so very well) whereas the Dialogflow fulfillment library directly supports 8 platforms (9 if you count Dialogflow’s simulator) but in a limited capacity (only text, cards, images and suggestions are supported).

Dialogflow Fulfillment: Custom Payloads and Actions on Google Integration

Dialogflow’s Fulfillment library lets you define a response once (i.e. a card) and have it surfaced across all 8 supported platforms (i.e. the Google Assistant and Facebook Messenger) without any additional code. In addition to the cards, text, suggestion and image responses Dialogflow lets you create platform-specific custom payloads to access platform-specific features like sending money, making an order or authenticating and support the rest of Dialogflow’s 14 platforms. There is also a integration with the Actions on Google v2 Alpha, so you can access all of the Google Assistant features.

Actions on Google: Plugins and Frameworks

Plugins let you create modules within the library for often used patterns. The most comment example would be randomization: you might have multiple ways to say the same thing and want to use different responses to keep things fresh and interesting with your users. Plugins let you create a randomization module to implement this once and use it across your fulfillment.

Actions on Google also directly supports most comment frameworks, like Express and Koa, as well as vendored serverless platforms like Google’s Cloud Functions and AWS Lambda.

Other Changes

  • You can use agent.add (Dialogflow Fulfillment) or app.ask (Actions on Google) multiple times to send multiple messages to your users (e.g. a text and a card response)
  • Both libraries use Dialogflow intent names to decide what code to run instead of action names. Actions names are still surfaced so you can still use them if you need them.
  • Both libraries use idiomatic JavaScript, changing from the builder model (app.buildRichResponse, app.buildCard) to anonymous options objects (new Card({...}))

Try them out!

You can try out the Actions on Google v2 Alpha and Dialogflow Fulfillment Beta right now. Take a look at my code implementing both libraries for the same project if you’d like to see the differences. Feel free to open an issue on either repo for feature requests, bugs, and feedback.