GoogleApp
Last updated
Last updated
Use this lib to connect BJS with Google App Script
Copy this table to your Google account
Deploy as web app
Try to open web app via app Public App url
Install GoogleAppLib and WebhooksLib to your bot
Create setup command
After this step you can use this Lib and debug.
This is detail setup description. Please try to use easy setup before it.
Go to https://script.google.com and create new project by button:
Paste the script from above into the script code editor and hit Save.
You will need to contact your Google Apps administrator, or else use a Gmail account.)
Now click Deploy. You may be asked to review permissions now. Project version - always "New".
Cloick in Deploy button. You will have Public App url.
The URL that you get will be the webhook that you need use in this Lib. You can test this webhook in your browser first by pasting it. Note that depending on your Google Apps instance, you may need to adjust the URL to make it work.
You need to add permissions
Go to App > Libs and install GoogleAppLib and WebhooksLib
/setup
Use any Google App script in BJS now
Example for command /task
You can turn on debug flag with true
Then you can debug code
command onRun
You need set permissions for Google App Script
Run Libs.GoogleApp.run()
in first time. You can have like such error:
Error on Google App script: "Exception"
"The script does not have permission to perform that action. Required permissions: (https://www.googleapis.com/auth/calendar || https://www.googleapis.com/auth/calendar.readonly || https://www.google.com/calendar/feeds)"
If you have such error you need set access rights.
Full help available here. From that help:
Open the script project.
At the left, click Project Settings settings.
Select the Show "appsscript.json" manifest file in editor checkbox:
At the left, click Editor code.
At the left, click the appsscript.json
file.
Locate the top-level field labeled oauthScopes
. If it's not present, you can add it.
The oauthScopes
field specifies an array of strings. To set the scopes your project uses, replace the contents of this array with the scopes you want it to use. For example:
Save the manifest file using Ctrl+S or the Save file icon in the menu bar.
Publish your app again (see step 3)
Run Libs.GoogleAppLib.run
in first time. Then:
go to Google App Script Editor (See step 2)
select "debug" function on Tab
press "Debug" button:
Google app is runs. Bot will sent execution result to you. Also you can receive email with error description.
You can use "debug" function anytime for debugging
Also you can open web app by url (see step 5) in incognito mode. And look for any errors. For example we have permission error here:
Google App script home page
Google App Script examples - good examples for inspiration
Stack Overflow answers - ask your questions on SO
Videos - Check out the Apps Script videos on YouTube
Reference - The reference documentation provided in this section describes the various Apps Script services and the Apps Script manifest file structure.