I have setup a fully operational chat bot in Hangouts Chat orchestrated by a tailored webserver. I would like now to be able to have this webserver to interact with other Hangouts bots that I created and to route some requests to some of my other servers that will have to know which bots initiated the event. With other provider, such as Slack, the app_id is provided in the event request data. But with hangouts, this is not the case. I could not find any data in the request body or headers that represent either project_id or client_id. In a more simple way my question is : "How to identify the Hangouts bot that send me an event request?" :)
One month later, I finally found the time to answer my question :)
In order to identify the Hangouts project that is calling your server, when you receive an event from Hangouts Chat, you'll find in the incoming request the header Authorization
whose value is something like Bearer abcd1234
.
If you decode this JWToken (ie, abcd1234
in our example), in the resulting data, you'll have a field aud
which is exactly the "project number" of your Hangouts app. This "project number" can be found at "https://console.cloud.google.com/home/dashboard?project=referenceofyourprojecthere".