Publish Gmail Add-on developed on a Gmail Account in a G Suite domain

Stéphane Giron
4 min readJul 17, 2019

--

Developing Add-on for Gmail with Apps Script is really easy, if you never try, just check this Codelab.

Gmail to Gmail developer testing

If you develop your bot in a Gmail account you can test it as the developer by enabling it in the developer section in you Gmail settings, go there then :

  1. In the Add-ons tab, ensure that you have selected the Enable developer
    add-ons for my account checkbox.
  2. Paste your add-on’s deployment ID into the Developer add-ons textbox
    and click Install.

Pro Tips : If you want to share this development add-on with another person for testing you must share the Apps Script File at minimum in read mode with this person.

With this method it is really easy to test your add-on because you don’t have to create a G Suite Market place listing.

Gmail to G Suite developer testing

First thing you have to know, is at the date of 17 July there is a bug and you can’t test a Gmail add-on by enabling it in the Gmail settings in a G Suite domain.

Note : If you develop add-on for people of your domain you just need to publish in the Market Place. No need to do all the following. Follow documentation, link. Don’t forget to check ‘Important pro tips’ at the end of article.

If you develop an Add-on for a client or for G Suite users it is interesting to develop the add-on on your account then be able to test in G Suite environments. The work around is to publish an add-on on the G Suite domain and use your source file as a library.

We can do that easily without lot of extra work as in a Gmail Add-on it is always the same function invoked by the add-on. Steps to follow :

  1. Create a new apps script file for your add-on in the G Suite domain

2. From your source file copy/paste the manifest ‘appsscript.json’

3. Attached your source file as a library, for that go to ‘Resources>Libraries…’. You will need script project Id of source file (help)

4. In your manifest you define the function to be invoked by add-on.

“gmail”: {
“name”: “Add-on name”,
“logoUrl”: “url",
“contextualTriggers”: [{
“unconditional”: {
},
“onTriggerFunction”: “getContextualAddOn
}],
“primaryColor”: “#00BCD4”,
“secondaryColor”: “#FF4081”
}

In example above it is getContextualAddOn, it is the same as in thecodelab. So in code.js file for this function you will call the one from your source file link as library. Code.js file will looks like :

5. There is a last step we need to handle the Button click function in the add-on. When you setup an action in an Add-on you link a function :

var action = CardService.newAction().setFunctionName(‘actionFunction’);
CardService.newTextButton().setText(‘Submit’).setOnClickAction(action);

To handle this function we will link it to the function in the library so it will looks like :

So now in your source file, search for all the setFunctionName instances and create a function in the new file.

6. Now you have to publish your add-on in the G Suite Marketplace by following the official documentation, link.

!!! This is a workaround to not have to maintain multiple versions of scripts and waiting a solution from Google to use the standard developer feature.

How to publish new version

After doing some changes in the source file to publish them :

  1. Create a new version in source file ‘File > Manage versions’
  2. Update version in the libraries of domain script file
  3. Deploy new version from the manifest ‘Publish > Deploy from manifest…’

Important pro tips

Here useful tips to save some times

  • Now on G Suite domain Apps Script scripts comes with a basic GCP Project to publish Add-on you have to create a new project on Cloud Platform directly.
  • Before to link the standard GCP project to your script you will have to create an OAuth token. Then you have to link the project to your script, help.
  • In the Cloud Platform project don’t forget to activate API needed by your add-on i.e. Gmail API, Drive API for example.
  • Don’t forget to fill the ‘Consent screen’ of your project.
  • Activate the ‘G Suite Marketplace API’, then follow the process to create a listing for your add-on, link.
  • Once all that done you have an url displayed at the top of ‘Publish’ section of the G Suite Marketplace API.
  • If user can install Add-on, you can share the page.
  • If on the domain, G Suite Marketplace app need to be white listed, even if you install the add-on as an admin you have to white list it. So don’t forget that !

--

--