-
Notifications
You must be signed in to change notification settings - Fork 2
Google Script Sink
A Google Script sink can be configured for users to send message from Google Scripts directly to group conversations or user one-to-ones.
-
Edit your
config.json
file and add the following entry into thejsonrpc
key:"jsonrpc": [ { "certfile": "/root/server.pem", "module": "sinks.google.scripts.webhookReceiver", "name": "<SERVER IP>", "port": <PORT NUMBER> } ]
-
(Re-)start the bot
You can use the mockgoogle-send.py script to test your sink first before proceeding to the actual setup and configuration on Google Scripts.
usage: mockgoogle-send.py [-h] url
positional arguments:
url url to send the data
optional arguments:
-h, --help show this help message and exit
The url
should resemble the following format:
https://<SERVER IP>:<PORT NUMBER>/<CONV ID>
or
https://<SERVER IP>:<PORT NUMBER>/<USER ID>
-
Open up Google Scripts and paste the following:
function sendToHangupsBot(conv_id, message) { // Replace the address with the address and port to your server var serveraddress = '<SERVER IP>:<PORT NUMBER>'; var url = 'https://' + serveraddress + '/' + conv_id + '/'; var options = { 'method': 'post', 'contentType': 'application/json; charset=utf-8', 'validateHttpsCertificates': false, 'payload': '{"message":"'+message+'"}' }; UrlFetchApp.fetch(url, options); }
-
When you need to send a message to a particular hangout, call sendToHangupsBot() with conv_id as the name of the conversation (use /bot whereami to find that out within hangouts) and message as the message that you'd like to send.
Plugin List | Developer Reference: [ Intro | Plugins | Sinks | In-built Functionality | [Configuration] (Configuration) ]