Monday, April 16, 2018

Developing a Google Assistant app using NodeJs, Dialogflow and Firebase Functions - 1

What is Google Assistant?

Google Assistant is a virtual personal assistant developed by google available on variety of devices like mobile phone, smart home device, on a smart watch or on a TV or even the web. It can engage in two way conversations and can work entirely with voice. 

What can it do?

With the assistant, you can control smart home devices, do most of the functions on your phone like placing a call, sending a text etc with just your voice, play content and also interact with apps. It also has routines which is a sequence of things which can be done with a single command. So existing content can be packaged into an assistant app or apps can be built without writing any code using templates or by writing custom apps. 

How to develop custom apps for Google Assistant?

For more flexibility we can also develop apps using the APIs provided by Google. There are two APIs we can use are Actions SDK and Dialogflow 
Using the actions SDK, your app can perform actions. An action defines an entry point into your app’s functionality and maps an intent that describes the action to the fulfillment that processes the intent. The fulfilment gets the user input as string, processes the input and provides a response. This interaction continues back and forth till the action is complete. 
Dialogflow is a conversational platform that lets you design and build actions by wrapping the functionality of the Actions SDK and providing additional features such as an easy-to-use IDE, natural language understanding (NLU), machine learning, and more. So it sits above the actions SDK and works with actions SDK. 

Developing the App

Here I will show how to create an app called InspireMe using the Dialogflow API. User can talk to this app to get inspirational quotes and passages. 

The flow of the app works like this 

User specifies an intent to Google Assistant or explicitly asks for taking with the app - > The welcome intent of the app is triggered - > Fulfilment is triggered for the intent - > Fulfilment picks a quote and returns in the response - > That quote is played in the response -> User is given an option to listen another quote or end the conversation - > If user selects Yes -> another quote is picked and played -> when user says no -> App wishes user a good day and the flow ends. 

Lets see how to develop this app in the next part. 

Monday, April 9, 2018

Leading metrics

You have something you want to achieve. It is somewhat big that you cannot complete it in one sitting. How can you make sure you keep track of it and work on it and achieve without wasting any time ?

It is by splitting the work into smaller things, allotting just enough time to complete and then tracking the leading metrics for the work we are doing. 

For e.g. the leading metric for an author in completing a book is number of words written per day. For a software developer, it is number of sub tasks completed/number of problems solved. These are different to the lagging metrics like number of books published or number of software released. Since for a person starting out and even for a person starting a new project, by definition, there will be some time before a project can be released. But to be productive in the time of development, it is important to keep track of the leading metrics. What gets measured, gets managed. 

This can be applied to everything important in your life. Identify the very important things where the result can be known only later. There, develop leading metrics to make sure you are on track. You will be surprised by how much you can achieve because of this. Apply this to your health, contributions, relations and finances. Let me know in comments how you have applied this to your life and how it has helped you. 

Monday, April 2, 2018

To be more productive, radically single task

Multi tasking is a myth. When we do multitasking our brains switch the context and this context switching is very in efficient. You might have noticed it when you go read something online and get back to work. It takes some time to settle in and again get back into work. It seems as if brain has to unload things from what it read online, then load the data related to work to start working and this switching sometimes takes 10 to 15 minutes. If you try to switch again in this time, now there was no way for brain to work efficiently.

The best way so is to do only one thing at a time, complete it and then go to the next, complete it and then go to the next and so on. If you try working like this you will be more productive and also more peaceful and at ease with work. You will also have worked in a more focused way with the whole processing power of the brain available to complete that work. This should help do the work better. It also helps to have pride in the work you do - that way you try to make it the best you can. 

There is nothing else to this. Just radically single task. Basically make a list of things in the order of priority that you want to do. Start with the first one. Finish it and start the second one till the time in the day is over or all your list is done! This will just guarantee that we don't get distracted at all. If you get distracted all you have to do is, just realize, recommit and then be back at what you're doing and restart the radical single tasking mode. 

Try it - it will be beautiful.

This is called the Ivy lee method of productivity. See the full story in James' blog

Monday, March 26, 2018

Are you making art ?

Have you heard about cryptokitties? Cryptokitties is a game to buy, breed, collect and sell adorable kitties - but you have to use the cryptocurrency ether to buy them. Its a rage these days and is being hailed as the first mainstream crypto application.

Why are people buying these? Because they are fun, novel and they're are cute cats :) It is introducing crypto in a fun and entertaining way. Some people are thinking it as a way to experiment with crypto while others are in it to make a quick buck.

This got me thinking about what is the motivation behind we buy anything non-essential - i.e food, medicine and transport stuff and basic clothing. It is either of these - to play, to get entertained, to be informed, to be validated or to be satisfied - in other words to get high! Everyone wants to get high. Each person's way is different.

Cryptokitties are digital collectible i.e digital works of art. It got me thinking about whether there is any difference between digital art and physical art. And also about why is art useful. I think it is because it inspires us, lifts us  and gives us a story. It inspires us because of the genius and also the effort put in by the people who made it.

I used to think that taking a picture of a scenery is same as/better than an art but realized it is not so - art can exaggerate and show us the best. May be nature might get us the best if we wait enough.
But with art there are more ways of expression- not just what is available in reality.
Art is a way of expression and if what the artist expresses, if that story impresses us or connects with us it is valuable in that it provides a high by sparking emotion in us.

The principle of true art is not to portray, but to evoke - Jerzy Kozinski

So art is anything that impresses us, makes us emotional. It can be used to improve us or diminish us. 
It is up to the artist to make his/her art empowering. It causes connection between the artist and the user of the art. Art is valued because it is scarce, it is difficult to make something that connects.
So it is a hits based thing where something that connects will be valued a lot compared to others. 

The opposite of an art is a commodity. Similar to others, easily replaceable, not having a story to it and no connection. It is also the secret to great marketing -  tell great stories about things we are selling and bringing that connection with the users. Of course it has to inspire them, help them to get their things done. 

We each influence others who we come into contact with. Instead of being a commodity without any story, we can make art to inspire and to really connect with people and create something of lasting value! 

I slept and dreamt that life was joy. I awoke and saw that life was service. I acted and behold, service was joy. - Rabindranath Tagore

Monday, March 19, 2018

Breaking the addiction... part 2

Last week I wrote about how passive entertainment addicts you and a better way to get entertained is the active entertainment through hobbies, games and playing.

Even with all those things, I was not really able to overcome the addiction and this week too. The funny thing is that I watched more Netflix over the weekend than I studied over the whole week!
But as we know breaking the addiction is not just based on the decision. 

In reality we can only break a habit with something else. It is a habit and it gives some rewards for doing that thing. 

A habit has three things - a cue, a routine and a reward. 

For e.g the cue is feeling bored or wanting relaxation. And the routine is watching Netflix. The reward is the sense of satisfaction, thrill and other stuff released with the emotional highs created by the movie or tv show. 

So the way to break this cycle is to change the routine. We will still get a cue of feeling bored or wanting relaxation. We have to do something else which will give us the thrills. Play can replace it to certain extent but realize that it cannot really replace it fully. Here is where we need the environment to encourage it - with no TVs, phones or tablets nearby. Also have a decided game or hobby material ready so that we can dive right into it and overcome the laziness to set it up. And next whenever you fail to do so, try again till you get habituated to the new routine. 

So onward I go towards overcoming that addiction and replacing it with a better one...  

Did you waste the day, or lose it, was it well or sorely spent?
Did you leave a trail of kindness or a scar of discontent?
As you close your eyes in slumber do you think that God would say,
You have earned one more tomorrow by the work you did today?
-Edgar Guest


Monday, March 12, 2018

Break the addiction to passive entertainment

When I was a child, there was just one channel Doordarshan. And I'm not even sure what they would broadcast most of the time. But every sunday 9:00 AM, we used to sit infront of the TV eagerly waiting for Jungle book. That was the first TV show that I remember watching with rapt attention.

Of course new channels came and with it came an explosion of entertainment. So our expectation of entertainment has changed. We started expecting to be entertained at any time. With youtube and netflix, now we have any time entertainment with our preferred things. It was never so easy to get entertained. And this thing is addicting. But why is this so addicting ?

Multiple reasons - With its fast cuts and engaging story, it grabs our attention with the question - what happens next?

The human body responds in a unique way to signals of danger. The brain readies the body for fleeing or fighting. And it does so by a sudden release of neuro-chemicals, including the hormone cortisol and both adrenaline and noradrenaline. These chemicals not only ready us for action, they also cause us to believe that we can overcome opposition. Confidence in threatening situations provides an evolutionary advantage, as long as it leave the door open to a rapid exit of the odds are too heavily stacked against us.  Fear, danger and violence all provide us with a natural high that makes us feel more powerful, more positive and more confident. Also, dopamine, the fuel of our reward center, is released as we encounter novel situations. These chemicals, acting together, create a feeling of satisfaction for us. 

This I feel is the main reason to get addicted to TV. This need for stimulation is called sensation seeking. And the more you love seeking these sensations, the more addicted you will be.
Because of mirror neurons, we also start feeling the emotions the characters on TV are feeling. All these things setup to cause addiction to watching the shows.

Now think about where we are getting time for watching this TV -- at the cost of other things especially being social with friends and spending time with family. If there was no TV we would have spent time talking with friends and family and playing games. So this passive entertainment is hitting and taking away at what really gives us the happy moments of life. Well will you regret not watching a TV show or will you regret not spending time with friends and family ? With kids at the age where they learn from us directly ? In the small window of time we have before they leave for their own lives ?

I certainly feel I will regret if I don't make good use of this time. So how to overcome this addiction and reclaim this time ? First become aware and accept that we might not get that much stimulation from anything else and get comfortable being bored.

Next think about active things you can do with your friends and family
Play cards and other games
Do art
... The possibilities are endless. Each of these things have their own way of giving a high to us and also we might become more close with our loved ones.

Monday, March 5, 2018

Why do we need inspiration ?

There are times when we feel we can be so much more than what we are. We all long to overcome our limitations and reach for the stars. And that longing is awakened when we are inspired. Inspiration pushes us to look for possibility and completely changes the way we look at our capabilities. We feel as if we are ready to make a dent in the universe. It reminds us that we are much more than where we are at currently and propels us to take action to reach where we want to be.

When we hear the stories of people overcoming impossible odds to achieve what they want, we feel encouraged ourselves to take on the mountains stopping us. It makes us go from thinking we can do it to believing we will do it. When we hear a quote from an accomplished person, we get reminded of all the great challenges that person has overcome in their life and that again triggers possibility in our life. This what inspiration does to us. It gives us the encouragement to act in the face of limitations and doubt.

And when it strikes, you have to lock in that fleeting moment of inspiration. The way to lock in the inspiration is to act, act swiftly and daily to keep the momentum. Momentum begets more momentum and it keeps us inspired.

It also happens that our daily life will bring situations where we feel down and uninspired and then we need some encouragement to fill out and strengthen our mind to start again. But where do we get inspiration from? 

There are multiple ways - One of them is to read a few pages from the biography or autobiography of people who you find inspiring or listen to inspiring talks. There you find people like us who faced the same daily grind of life, but have done something to tell their tale to the world. But if you don't have that much time now - there is another way. You can read or listen to a quote from an inspiring person and then consider and think about that quote for a minute. Listen to a few - I'm sure you will have filled up with possibility to ready to take on the world again. 

Better yet, why not make it a daily practice so that we don't really wait till we go completely down to get inspired? 
People often say that motivation doesn't last. Well, neither does bathing. That's why we recommend it daily. --Zig Ziglar