All guides Backups and undo: getting an earlier version of your app back Files and images your app's users upload: taking, storing, showing and sharing them Plans and limits: how many projects you can have, the Exotool notice, and what happens at the limit Resources: connecting an Exotool app to outside services Sign-in and permissions: users, logging in and who may do what in your app Storing data: objects, sets and where your app keeps them Taking payments: cards, charges and holds with Stripe or PayPal
Resources: connecting an Exotool app to outside services
This guide is for the person whose app needs something outside itself: a database, a mail account, a payment account, text messages, a map key, a web host, or any other service with an address and a key. It says what a resource is, which kinds there are, how to make one, how to give it to a project, and how the app then uses it. It also covers what an assistant (Claude or ChatGPT) can and cannot do with resources.
Contents
- What a resource is
- The kinds of resource
- Making a resource
- Giving a resource to a project: roles
- Using a resource in the app
- Other resources: any service, with fields you name
- Secrets: what is kept where
- Resources and an assistant
- Resources in a deployed app
- When something does not work
1. What a resource is
A resource is a saved connection to a service outside your app: where the service is, and the name, password or key that lets your app use it. A MySQL database, a mail account, a Stripe account, a Twilio account, a Google Maps key and a web host are all resources.
Three things make resources worth having:
- You enter the details once. A resource belongs to your account, not to one project, so the same mail account or database can serve every app you build.
- The details stay out of your design. The diagram of an app never holds a password or a key; it only says "this project uses that resource". You can show, copy or share a design without giving a secret away.
- You can swap one for another. Point a project at a test mail account while you build and at the real one when you go live, without touching the app's design.
An app does not need any resource to run. A new project stores its data in a built-in store, and shows maps in the preview with Exotool's own key. You add a resource when the app has to do something that needs an outside service: send mail, take a payment, send a text message, keep its data in MySQL, or be deployed to a host of your own.
2. The kinds of resource
| Kind | What it is for | What you connect | How the app uses it |
|---|---|---|---|
| Database | Keeping the app's data in a MySQL database instead of the built-in store | A MySQL database: its address and the login the app uses | Nothing changes in the app's design: objects and sets are stored in MySQL |
| E-mail Server | Sending mail | An SMTP account, or a SendGrid or Mailgun account through its API | send_mail(...) |
| E-Commerce Server | Taking card payments | A Stripe account or a PayPal account | The credit card form and charge_credit_card(...); with Stripe also holds: authorize_card, capture_card, release_card |
| SMS Server | Sending text messages | A Twilio account | send_sms(to, body) |
| Maps | Showing maps in a deployed app | A Google Maps browser key | The Map elements and the map functions |
| Web Server (a web host) | Deploying the app to a host of your own | FTP, SFTP, a Subversion or GitHub repository, or a zip file to download | The editor's Deploy dialog |
| Other | Any service Exotool has no built-in kind for | Fields you name yourself, each a key and a value | Read in a code block: section 6 |
Every plan may use every kind.
Two notes on the table:
- Database. A project always has a store for its data, and you choose which: Single File (the default, built in, nothing to set up), Multiple Files (also built in: one small file for each record), or MySQL. Only MySQL needs a resource.
- Maps. A preview shows maps with Exotool's own key. A deployed app needs a Maps resource with a key of your own.
3. Making a resource
Resources are made in the editor, on the Resources page, which opens from the launcher's menu.
- Open Resources.
- Press +. The kinds are listed by category, each with a short explanation.
- Choose the kind and fill in the fields it asks for.
- Save.
What to know when you fill it in:
- A secret field is kept encrypted and is never shown again. You can replace a password or a key later, but not read it back. Keep your own record of it.
- Every resource has a name: a short identifier of letters, digits and underscores, made from its title unless you give one. The resources list and the details popup show it, and Edit changes it. The name matters for Other resources, where code refers to it (section 6), and for a deployed app (section 9).
Making a resource does not change any app. An app uses it only after you give it to a project.
4. Giving a resource to a project: roles
A project uses a resource through a role. A role is a slot: "this project's mail account", "this project's payment account". Each project has these roles:
| Role | Takes | When it is not set |
|---|---|---|
| Database | Single File, Multiple Files, or a MySQL resource | Single File |
| E-mail server | An E-mail Server resource | send_mail sends nothing and returns an error string |
| E-commerce server | An E-Commerce Server resource | Card charges fail with an error |
| SMS server | An SMS Server resource | send_sms sends nothing and returns an error string |
| Maps | A Maps resource | The preview uses Exotool's key; a deployed app shows no map |
| Web server | A Web Server resource | The app has nowhere to be deployed to; a host can also be added on the spot in the Deploy dialog |
| Other resources | Any number of Other resources | Their fields cannot be read |
You set a project's roles in the project's settings. The Other resources are chosen under Settings > In General > Other resources (hold Ctrl, or Cmd on a Mac, to choose more than one).
A change of roles takes effect at the next build. After you set or swap a resource, build the project again so that the app picks it up. Until then the app runs with what it was built with.
The same resource can fill the same role in any number of projects.
5. Using a resource in the app
For the built-in kinds there is nothing to write about the resource itself. You call the function, and the app uses whatever resource fills the role:
// mail: goes through the project's E-mail Server resource
result = send_mail("ann@example.com", "Your order", "Thank you for your order.", "shop@example.com")
// a text message: goes through the project's SMS Server resource
result = send_sms("+14155551234", "Your code is 482913")
// a card payment: goes through the project's E-Commerce Server resource
result = charge_credit_card(_cardvalues_, 25.00, "Order 1042")
Each of these returns "OK" or an error string, so test the result and tell the person when it
is not "OK". The language reference has every function with its arguments: send_mail,
send_sms, and the section "E-Commerce" for the payment calls.
A database resource needs no code at all. Objects and sets are read and written the same way whichever store the project uses, and nothing in the design changes. Changing the Database role changes where the app keeps its data from the next build on. Data already in the old store does not move over by itself: the app starts in the new store without it.
Payments with Stripe deserve one sentence: the card never reaches your app's server. The credit card form hands the card to Stripe from the person's device, and your server charges through a payment method id. Amounts are in the currency of the resource.
6. Other resources: any service, with fields you name
When a service has no built-in kind (a geocoding service, a weather service, an API of your own), make an Other resource: on the Resources page choose Add a Resource, then Other (custom fields). You name its fields. Each field has a key, a value and a protected flag.
- An unprotected field is for a value that may be seen: a public key, an address, a region. The app's device code can read it.
- A protected field is for a secret: an API secret, a password. It is kept encrypted, is never listed and is never sent to the device. Only server code can read it.
The app reads a field in a code block, by the resource's name and the field's key:
// on the device: an unprotected field
key = JS< exotool.resource("MAPS", "api_key") >JS
// on the server: any field, protected or not. Use the secret inside the block that needs it.
place = PHP<
$r = @file_get_contents("https://geo.example.com/lookup?q=" . urlencode($args->q)
. "&key=" . urlencode(exotool_resource("GEO", "server_secret")));
return json_decode($r, true);
>PHP
In a server block a variable of the activity is read as $args->name (here $args->q), and
the block hands its result back with return.
Both functions take a third argument, the value to use when the field is not set.
Use a protected value inside the block that consumes it, and return only the result. A block that returns the secret itself turns it into an activity variable, and a server variable can be written into the app's store. Make the request to the provider in the block, and hand back the answer.
A key that the browser must hold, such as a maps key or a sign-in client id, is unprotected by
nature. Protect it on the provider's side instead: restrict it to your app's addresses, and
remember that the preview's address, under exotool.app, must be among them.
A project may use several Other resources (section 4).
7. Secrets: what is kept where
- A secret you type into a resource is encrypted when it is saved and is never shown again, in the editor or anywhere else.
- The diagram holds no secret. It names the resources a project uses, nothing more.
- The device never receives a protected field, not even its name. Unprotected fields of Other resources do reach the device, which is what they are for.
- The built app holds the settings it needs to run: the database's address, the mail account, and so on. In a deployed app an operator can keep them out of the app's files altogether (section 9).
- An assistant never sees a secret (section 8).
8. Resources and an assistant
When you build with Claude or ChatGPT through Exotool's connector, the assistant can:
- list your resources: for each, its kind, its title and its name; for an Other resource the keys of its fields and which of them are protected. Never a value, never a secret;
- set a project's roles: point the project at one of your resources, or back at the built-in store, and rebuild.
The assistant cannot make, change or delete a resource. That is done only in the editor, because making a resource means typing a secret, and a secret should not pass through a conversation. So the usual order is: you make the resource in the editor, then ask the assistant to use it in the project, for example "use my SendGrid resource for this app's mail".
9. Resources in a deployed app
A deployed app uses the resources its project had when it was deployed. A common arrangement is one set for development (a test mail account, a test payment account) and another for production; swap the roles before you deploy.
The operator of the host can change any setting of a resource without a rebuild, by setting
an environment variable named EXOTOOL_RES_<NAME>_<KEY>, both in upper case: for the field
api_key of the resource named MAPS, EXOTOOL_RES_MAPS_API_KEY. The app runs as compiled
when nothing is set. A secret can be left blank in the resource and given only on the host, so
that it is never in the app's files. Renaming a resource changes those variable names for every
deployed app that uses it, which is why the editor asks you to confirm a rename.
The deployment guide has the rest: encrypted values, secret stores, backups of a MySQL database, and several apps sharing one database.
10. When something does not work
| What you see | Likely cause | What to do |
|---|---|---|
send_mail returns an error string and no mail arrives |
The project has no E-mail Server resource, or its settings are wrong | Set the e-mail role and rebuild; check the account's settings; some hosts block outgoing SMTP, so use a SendGrid or Mailgun resource there |
| Mail is sent but refused | The from-address is not allowed by the mail account | Use an address the account may send from |
send_sms returns an error string |
No SMS Server resource, or a number the provider refuses | Set the SMS role and rebuild; give the number in international form, such as +14155551234 |
| The build warns that a card cannot be charged because the project has no E-Commerce Server resource, and a charge then fails in the app | The e-commerce role is not set | Make an E-Commerce Server resource and set the role, then rebuild. The guide on payments has the details |
A hold (authorize_card) is refused |
The resource is a PayPal account | Holds work with Stripe only |
| The app does not see a resource you just set | The project was not rebuilt | Build again: roles take effect at the next build |
| A map is blank in the deployed app but fine in the preview | The deployed app has no Maps resource | Make a Maps resource with your own Google Maps key and set the role |
| A browser key is refused | The key is restricted to other addresses | Add your app's address, and the preview's under exotool.app, at the provider |
exotool.resource(...) gives nothing for a field |
The field is protected, or the resource is not among the project's Other resources | Read a protected field on the server with exotool_resource; add the resource under Settings > In General > Other resources and rebuild |
| A deployed app cannot reach its database | The host lacks PHP's mysqli, or the database refuses connections from the host |
See the deployment guide, section 3, "What is sent, and what the host needs" |