Gmail Add-ons (if what you are talking about is indeed a Gmail Add-on) use Card-based interface and cannot be created with custom html
and 'css'. Once built such an interface, create a function that executes your library's function:
/**
* Triggers library function;
* @param {Object} e event object;
*/
function myTrigger(e) {
//access event object's params;
var parameters = e.parameters;
var id = parameters.id;
var url = parameters.url;
//you can reference lib functions by prepending its name;
myLibrary.myFunc();
}
Import your library by clicking on the project's command bar button Resources, then choose Libraries and import your project (assuming your library can be converted into an apps script project, if not, there is not much that you can do). Besides, Google discourages from using libraries in Add-ons.
You can, of course, load the external non-GAS library via UrlFetchApp.fetch()
by using eval()
(ctrq have a great tutorial on how to do that), but you are probably aware that eval()
brings security risks to your app.
Then, configure an Action
on a target Ui element (most likely a TextButton
):
//...created a TextButton and wrote it into a var tb;
//create parameters object (aquire id and url however you want)
var parameters = {
id : '',
url : ''
};
//reference Enum loadIndicator (only NONE or SPINNER currently);
var loadIndicator = CardService.LoadIndicator.SPINNER;
//create Action to set;
var action = CardService.newAction();
action.setFunctionName('myTrigger'); //reference trigger function;
action.setLoadIndicator(loadIndicator); //set a load indicator, if not invoked equals NONE;
action.setParameters(parameters) //every key in this object are strings!;
//set Action to TextButton;
tb.setOnClickAction(action);