Indigo API with Google Sheets (Example)
Posted: Tue May 16, 2023 6:33 am
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);
}