Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sending chat message from google app script

I already developed applicaton for google app script that can send email messages, but right now there is a need for me to send gtalk chat/xmpp message to user from my script. my question is, is it possible for me to send gtalk chat/xmpp message directly from google app script? if it is not possible then is there any work around about this?

like image 958
user1501185 Avatar asked Jul 05 '12 06:07

user1501185


2 Answers

Basically, there are two types of messages you can automate through the App script.

  1. Synchronous: building a boot that can respond to user inputs.
  2. Asynchronous: specified trigger-based messaging systems. like submitting a google form or time-based.

Let's talk about Asynchronous

You can do it by Using incoming webhooks.

  • Create a Google Chart Room > Create a webhook URL. click_here
  • Use this Code:

function myFunction() {


    var WebWhooklink = "PEST_YOUR_WEBHOOK_URL_HERE"
    
    var message = { text: "Hello Chat"};
    var payload = JSON.stringify(message);
    var options = {
            method: 'POST',
            contentType: 'application/json',
            payload: payload
    };
  
    var response =  UrlFetchApp.fetch(WebWhooklink, options ).getContentText();
}

like image 164
Deepak Kumar Sahoo Avatar answered Oct 01 '22 01:10

Deepak Kumar Sahoo


There is no built-in support for sending Google Chat messages. You can file a feature request on the issue tracker.

like image 22
Eric Koleda Avatar answered Oct 01 '22 03:10

Eric Koleda