Page 1 of 1

Indigo API with Google Sheets (Example)

Posted: Tue May 16, 2023 6:33 am
by ryanbuckner
I wanted to share a Google Apps Script example I'm currently using. Google Sheets does not have a built in messaging function, so I created an Indigo. Action Group to send me an iMessage, and I use the following function to execute it.

Code: Select all


// Executes Indigo Action Group
// Takes Action Group ID as input
function executeActionGroup(actionId){

  // Things that are specific to your environment
  const REFLECTORNAME = "YOUR REFLECTORNAM HERE";
  const APIKEY = "YOUR API KEY HERE";
  const ACTIONGROUPID = actionId;  // an Indigo action group id

  // The message to send to the Indigo Server
  const message = JSON.stringify({
    "id": "optional message-id",
    "message": "indigo.actionGroup.execute",
    "objectId": ACTIONGROUPID
  });

  // These are options that you'll pass to the UrlFetchApp call
  const options = {
    method: "post",
    headers: {
      Authorization: `Bearer ${APIKEY}`,
      "Content-Type": "application/json"
    },
    payload: message
  };

  // Get the action group JSON from Indigo and log it to the console
 // This could use some error handling
  const response = UrlFetchApp.fetch(`https://${REFLECTORNAME}.indigodomo.net/v2/api/command`, options);
  const actionGroupInstance = JSON.parse(response.getContentText());
 
 //console.log(actionGroupInstance);

}

Indigo API with Google Sheets (Example)

Posted: Tue May 16, 2023 8:45 pm
by mundmc
Sorry if I am being thick here, but is this reliant on the iMessage plugin (which I'm sure is great and it has great support but just didn't work for me)?

Re: Indigo API with Google Sheets (Example)

Posted: Wed May 17, 2023 6:25 am
by ryanbuckner
mundmc wrote:Sorry if I am being thick here, but is this reliant on the iMessage plugin (which I'm sure is great and it has great support but just didn't work for me)?
This is really an example of how to fire any Action Group through the Indigo API using Google Apps Script

Re: Indigo API with Google Sheets (Example)

Posted: Fri May 19, 2023 8:43 pm
by mundmc
ryanbuckner wrote:
mundmc wrote:Sorry if I am being thick here, but is this reliant on the iMessage plugin (which I'm sure is great and it has great support but just didn't work for me)?
This is really an example of how to fire any Action Group through the Indigo API using Google Apps Script
Thank you for giving me the concreteness I needed!