“Ok Google, use my Flutter app!”

In this post I would like to show you how I integrated Google Assistant/Google Now with my WeightTracker app written in Flutter (works only on Android).

First, let’s see what we are trying to accomplish:

(I had to type in the message because recording tool was capturing mic input, so Google Assistant couldn’t hear what I was saying)

How to achieve this? Let’s walk through it!

1. Let your app catch the intent.

Google Assistant actions are based on Voice Actions. If we want to integrate your app with it we need to pick one from the list (you can find list of Voice Actions here). After we choose an action (for me it was Take a note) we can add a proper intent-filter to our AndroidManifest.xml:

If there is any note saved I try to find a number there (I know it’s not perfect) and then return it. According to our app architecture we can store that value in database, use it in setState or do whatever we want.

When it comes to coding we’re all done. However saying “Ok google, save a note my weight is 80” or just “Ok google, note to self 80” may not work. We have to choose our app as a default one to use it. To do that with Google Assistant you need to say “Save a note” and then press default app’s icon and choose WeightTracker (present on the right).

And that’s it! Enjoy!

Interesting facts:

You can say “save a note blabla in Evernote” and it will pick Evernote. However if you say “save a note blabla in MyApp” it won’t work. Don’t ask me why.

If you call fetching function in onInit function, it won’t get invoked if you say “ok google…” while your app is in the foreground.

There is no option to create your own voice actions 🙁

If you download WeightTracker from Google Play and set it as default noting app, you should be able to use it with Google Assistant/Google Now. If not, please tell me!

-“If you call fetching function in onInit function” –
well, if you have Java calling Flutter instead of the reverse, this will be resolved. I understand it’s possible. Was this an approach you tried? Did you find any issues with it?

-“There is no option to create your own voice actions” – is this a general restriction, or just using your method? I know Android offers custom actions, where’s the issue implementing these using Flutter?

-Do you see any issues trying to implement a 2-way conversation with the user? In your example you only allow a 1-way call from the user, no questions back…

Thanks to share content like this. This type of content literally help people to get knowledge about trending technology. At present time, most of the person use Google flutter for his iOS app development. I am also a iOS app development and using Google flutter. If you guys have any of query regarding Google Flutter then you can ask me via reply to this comment. Thank you.

About me

Hi! My name is Marcin, I study Computer Science at Lodz University of Technology in Poland. On this blog I document some of development I do in my free time with belief that someone can get value out of this.