There is an option in OK Google voice commands in which Google app can send Whatsapp messages to any person. How does it manage to do this?
To understand this, you will need to know the workings in the code. Anyway, I'll try to explain it in layman terms. Basically, apps can have a window (sort of) by which they can be given data to initiate the task. These windows are called intents in android. When an app is given some data, say a person's name and a message, through the intent it can decide what to do with this data. In the case of Whatsapp, it sends the given message to the given contact/person.