Google Hangouts Chat - Notifications

Ok made some…progress with these and really do feel it is possible.

Using the PHP code below…I’ve manage to host a test.php file on LibreNMS and call it via a browser, successfully sending a POST command to a Google Hangout Chat Room

I’ve tried to butcher the MSTeams.php file on LibreNMS in the Alert/Transport to match the below config, pulling in the various objects and arrays but really can’t get my head around it.

The main problem is, I am working blind, I update the file, send a test request from LibreNMS Transport config test page, but I have no idea what is happening at the LibreNMS as there is no console output I can find.

Code below is here:

`<?php`

`//API Url$url = 'INSERT WEBHOOK URL FROM GOOGLE CHAT HERE';`

`//Initiate cURL.$ch = curl\_init($url);`

`//The JSON data.$jsonData = array('text' => 'ALERT TEST');`

`//Encode the array into JSON.$jsonDataEncoded = json\_encode($jsonData);`

`//Tell cURL that we want to send a POST request.curl\_setopt($ch, CURLOPT\_POST, 1);`

`//Attach our encoded JSON string to the POST fields.curl\_setopt($ch, CURLOPT\_POSTFIELDS, $jsonDataEncoded);`

`//Set the content type to application/jsoncurl\_setopt($ch, CURLOPT\_HTTPHEADER, array('Content-Type: application/json'));`

`//Execute the request$result = curl\_exec($ch);`

./scripts/test-alert.php (particularly with the -d switch) will allow you to test via the CLI.

Thanks - Couldn’t get the test script to work but figured out it was a error on my part.

Will continue to attempt to get the Google Chat Hangout working.

1 Like

@murrant I did it! Thank you very much… the test-alert.php provided me exactly what I need to diagnose the problems.

I just need to tidy things up, create it as it’s own Transport option, rather than hijacking the MSTeams Transport.

Really happy though. Thanks Again.

1 Like

@Wayne_Kilner Thanks for working on this! Did you end up setting this up as a proper transport? Would you be willing/able to submit it as a PR? My company is moving us from Slack to Google Chat and we need to solve for alerting… :frowning_face:

I didn’t get it fully working within Libre as. I couldn’t get the code to remain stable during all the updates.

Instead I found a tool called Integromat (Google it) its like Ifttt or Zapier and allows Webhooks to be sent and received.

I send a push with the payload to Integromat and then split this into two Hangouts Chat rooms via the supported web hook.

Works a dream and depending on the volume of alerts can be free of any costs.

Need support, let me know.

Moving from Slack to Hangouts must be devastating, what’s the reason for the move?