Beyond Bitshares Google Assistant upgrading to latest 'Action on Google' alpha release!

Words
896
Reading
4 min
Listen
Play
8y

Beyond Bitshares Architecture

Beyond Bitshares Google Assistant Updates!

I last wrote about creating the Beyond Bitshares Google Assistant on Steemit about 3 months ago now, since then I've been focusing primarily on my studies, however with a temporary gap between classes and exams I began upgrading the Firebase cloud function for Beyond Bitshares from actions-on-google v1.10.0 to v2.0.0-alpha.

The alpha Actions on Google (v2.0.0) library was released earlier this month, they're collecting feedback from the Actions on Google developer communities and will decide their next development priorities on April 2nd 2018.

It's worth noting that Beyond Bitshares is one of the only open source Google Assistant cloud functions available, other than Google's Samples. Hopefully other Google Assistant developers can more easily migrate to the new version by going through Beyond Bitshares code!

This upgrade was required to migrate from Dialogflow v1 to v2, which brings the latest functionality offered by Dialogflow - BeyondBitshares is going to enjoy the following new functionality:

The most exciting new feature is 'Speech recognition - Google Cloud Speech' which will hopefully enable the Google Assistant platform to finally differentiate between two users in the same room. This will greatly improve security of our google assistant interactions, potentially enabling non-read-only Bitshares functionality in the future.

New features = new charges?

Dialogflow v2 functionality does appear to come with new quotas:

As long as we're below our usage quotas it should be free:

That said, the plan isn't to create a Google Assistant which nobody will use, rather we want as many users as possible! It does mean that private development instances or small testing environments will cost next to nothing to operate, which will drastically inflate the potential developer base around the world!

Whilst Dialogflow v2 looks to become a new source of bills (once above usage quotas), Firebase has modified their Blaze payment package (required for cloud function to contact external REST APIs) to offer free usage which means whilst the Beyond Bitshares userbase is small it will likely not cost anything to run. Check out their pricing comparison & calculator.

So what's changed?

Silvano Luciani (Google Assistant Developer Programs Engineer) wrote an excellent article on Medium regarding the changes between v1.10.0 and 2.0.0-alpha, it's worth a read!

The TL;DR changes for Beyond Bitshares

  • A massive reduction in pointless code, especially surrounding matching intents to functions, no more action mapping nor static declaration at the start of the code, now just app.intent('intent_name', conv => {conv.close('Thanks for talking to me!')}) which is much simpler and less tedious.
  • Asynchronous code enforcement - required the creation of promises which the function waits for before continuing (external REST API communication). This was a large change for most existing Beyond Bitshares functions, however the code is a lot more readable now. A major thanks to Shuyang Chen for helping me on Stack Overflow regarding this!
  • With the move to Async code, the HUG request has been converted so a function thus reducing code within each intent's function.
  • Dialogflow:Firebase verification has changed - requiring a simple header property in the dialogflow app object. Thanks to Shuyang Chen again for providing this information on stack overflow!
  • Much neater code thanks to the v2.0.0-alpha's more idiomatic JavaScript functionality.
  • Check out the new index.js file, compared to the old index.js file!

What is the TODO list for Beyond Bitshares?

  • Test each function, extract the error messages when they fail for debugging.
  • Parse input from DialogFlow (e.g. an username or asset name) for use in each function (currently set to static variables for testing).
  • Create entities for asset-id:asset-name, account-id:account-name, committee-id:committee-member-name, etc. So that we're able to more easily parse input data from what the user says to the bot.
  • Move from conv.close()to conv.ask() for all functions (aside from the goodbye function) so as to not immediately throw away our users, we want to offer them the ability to easily search for more information through the bot.
  • After move from close to ask, create generic fallback for all functions which allows the input of responses and suggestons as input variables (so as to create a template function, but allow for per-function custom fallback text). Will probably store the data in context data storage.
  • Create private Bitshares full API server for the HUG REST API to have local access to; this will hopefully reduce time taken to return responses - we need to be way below the 5 second max response time. Most functions don't take this long, however with increased load this will be a concern, besides it'd be better to provide immediate Google Assistant responses.
  • Investigate generalizing text fields, for enabling localization (to reach a worldwide audience). Check out this related Medium article regarding Google Assistant localization.
  • Get Beyond Bitshares into a production state & submit to Google for publishing. Once published, I'll open source the Dialogflow export on Github using the MIT license.

Interested developing your own Google Assistant?

You should consider attending your local 'Build Actions for your Community' events being hosted by Google Dev Groups to learn about the platform in person.

Alterantively, consider trying to create your first Dialogflow based Google Assistant, bearing in mind that these tutorials will likely change in the next month or two as v2.0.0-alpha becomes the master branch.


Got any questions regarding Beyond Bitshares or the Google Assistant platform? Comment below!

Would you consider approving a Bitshares worker proposal to cover this development in the future?

Best regards,
cm-steem@cm-steem

Beyond Bitshares Google Assistant upgrading to latest 'Action on Go... | Ecency