Google Hangouts Chat - Notifications


#1

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);`

#2

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


#3

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.


#4

@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.