Correctly Deploy a Google Apps Script
Web App for AI2


Many developers are integrating their apps with a google apps script. Your AI2 app is not connected to your google account in anyway on your device, therefore, in order to be able to run the web app, you need to ensure you are using the correct settings. The first time you publish your web app, you will be asked to give the web app permission to use your google account. You need to give the permission, otherwise the web app will not work for you in AI2.

Create new Script (uses Legacy Editor)

Let us begin by creating a new standalone script project in your google drive

Right click inside the folder where you want your script project and work through the menu to select Google Apps Script. If it is not there, then use
+ Connect more apps to search for and install it.

Click on Create and Share. You can change your sharing permissions in Google Drive later, if you need to

Give your script project a meaningful name

I usually paste and then comment out the script url to the top of my code editor for easy access

Legacy Editor

Using the Legacy editor to setup your web app is quite straightforward. Enter your code in the code editor. Web Apps should always have a doGet() or doPost() function, and these functions should always have a return. If you use doGet() you can usually run your web app in a computer browser, if you use doPost() you would need to use curl or Postman.

You follow a similar procedure whenever you make changes to your script.

Here is the legacy editor with a simple web app using doGet(). When this web app is run, it simply returns the text: Hello World.

From the File menu, select Publish, then Deploy as web app.

Here we are presented with a dialog, with two important items to select. Execute the app as "Me", the google account you are using. Who has access to the app: "Anyone, even anonymous". Click on "Deploy". Using any other settings here will mean that the web app will NOT work with your AI2 app.

New Editor

The new script editor has a few more options and tricks, but the procedure is essentially the same.

When you makes changes to your script and need to deploy a new version, see here for the method:

New Versions for New Google Script Editor

Here is the simple web app as seen in the new script editor

On the right at the top, click on the Deploy button, then select New deployment.

In the dialog presented, first click on the Select type icon and select Web app

In the main area of the dialog, Web app - Execute as "Me", the google account you are using. Who has access: "Anyone". Click on "Deploy". Using any other settings here will mean that the web app will NOT work with your AI2 app.

Your web app is deployed, click on the Copy icon to copy your script url for use in your AI2 app. Then click on Done.

You should be done now, and have successfully published your web app for use with AI2