Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to distribute a Google Apps Script (processing Gmail mails) publicly?

I developed a Google Apps Script to process some emails automatically (connected to Gmail), more or less like a bot, and it's working as expected. It runs every minute, using a Time-driven trigger Minutes timer > Every minute:

enter image description here

Is it possible to distribute this "script" for other users (including commercially), or will it necessarily be open-sourced? (note: Google Apps Scripts are using Javascript internally)

I see Deploy as web app, Deploy as API executable, Register in Chrome Web Store, Deploy as web add-on, Deploy from manifest, but I don't know which one to use to offer this service for other users.

enter image description here

Also, will it necessarily be on the Chrome Web Store or are there other ways to commercially distribute/grant access to a customer to such apps?

TL;DR: How to distribute to customers a Google Apps Script that processes Gmail emails? (that needs to run automatically every minute).


Note: It seems that Gmail add-ons are available here: https://gsuite.google.com/marketplace/category/works-with-gmail. But it seems that we cannot sell an add-on commercially. Are Gmail add-ons necessarily free?

enter image description here

Note: the script is not linked to a precise browser or computer (thus it cannot be installed with a browser extension on a particular computer), it quietly runs on the Gmail server every minute.

like image 492
Basj Avatar asked May 19 '18 16:05

Basj


1 Answers

Partial answer:

The page Restrictions about Gmail add-ons states that they don't provide a direct way to charge users to install an add-on:

We don't provide a way to charge users for installing add-ons, and add-ons can't include ads. However, you can roll your own payment system or call into an existing billing database. Your add-on can connect to non-Google services that bill users.

However, it's unclear for me if it's possible to run a time-driven background task (let's say once every 15 minutes) by a Gmail add-on. On the one hand, I see in the Restrictions page:

You can't create or use Apps Script simple or installable triggers in a Gmail add-on.

and time-driven triggers seem to be included in "simple" or "installable" category, but I'm not sure. For example, everyMinutes(n):

Specifies to run the trigger every n minutes. n must be 1, 5, 10, 15 or 30.

ScriptApp.newTrigger("myFunction")
    .timeBased()
    .everyMinutes(10)
    .create();

On the other hand, I see an example here with so-called Universal Actions:

/**
 * Run background tasks, none of which should alter the UI.
 * Also records the time of sync in the script properties.
 *
 * @param {Object} e an event object
 */
function runBackgroundSync(e) {
    ...
like image 74
Basj Avatar answered Sep 18 '22 08:09

Basj