App functions
An app's pages run in the visitor's browser, which can only talk to the app's own address. Anything else, such as showing your newest emails, pulling an exchange rate from a public service or combining this week's calendar with your open tasks, needs a function: a small piece of server-side code the App Builder writes and the app calls while someone uses it.
Ask for what you need in plain language; the builder decides when a function is needed and writes it. Functions run on Tunori and can reach the internet and the tools of your integrations that you have granted to the app.
Granting tools
Before a function may use one of your integrations, the builder asks you to grant the app the specific tools it needs, for example Gmail's Search Emails. The approval card lists the integration and each tool.
Approving means that the app's code decides what those tools are called with, for everyone who can use the app. Grant only what the app needs, and think twice about tools that change data, such as sending an email or creating a document: they run for whoever uses the app.
The Integrations tab of the builder lists the granted tools and lets you revoke them. When a function needs a tool that is not granted, the builder asks again. Deleting an integration removes its tools from every app.
Who can run functions
- Every member who can open the app, viewers included. Granting a tool therefore shares what it returns with everyone in your organization who can use the app, like a dashboard does.
- Anonymous visitors of a public app only if an admin allows it: on a public app, an admin chooses Functions: members next to the app's name and confirms. The button then shows Functions: anyone. Anyone on the internet can then run each function, with any input, from any program, not only through the app's pages, and a function may use the granted tools for them as far as its code lets them. Turn it on only for apps whose functions you would publish on a web page. Making the app members-only again switches it back.
Visitors who may not run a function get a sign-in prompt where the app uses it.
Costs and records
Running a function costs nothing by itself. Each tool call a function makes is charged like a tool call in a chat, under your organization's connected account (for Gmail, the mailbox you connected). See billing and credits.
Every function run and every tool call is recorded, with what was called, with which input and by whom (anonymous visitors by IP address). The records are kept for 90 days.
Secrets
Functions cannot keep secrets: there is no way yet to give an app an API key of its own. Public services that need no key work. A credential written into an app is caught when the app is built; see versions and publishing.