Skip to main content
This tutorial turns the Quickstart template into a real plugin: a Hava (weather) action that reads a city from a user setting, fetches the weather over host-brokered HTTPS and writes it on the key. What you will learn: manifest permission declaration (the network.fetch host allowlist), binding settings (settingsSchema + action.settingsChanged), client.networkFetch and fail-closed error display.
This example uses the host-brokered client.networkFetch; that is for portability to the T2 (public sandbox) target. On the T1 (local dev) host, network.fetch is not wired yet — T1 is sandboxless Node, so do the network call directly: use const text = await (await fetch(url)).text(); instead of client.networkFetch({ url, method }) and remove the network.fetch permission from the manifest. Which capability works where: Capability APIs.

1. Manifest: declare the permission and action

Update the permissions and actions sections in manifest.json:
  • network.fetch is limited to the HTTPS hosts declared in the manifest; a request outside wttr.in gets CAPABILITY_DENIED.
  • The settingsSchema field appears in the app’s settings panel when the user assigns the action to a key.

2. Runtime: event → setting → network → screen

runtime.mjs:
Contract points:
  • Reading settings: getSettings(bindingId) returns the binding-specific persistent setting; when the user changes the setting, action.settingsChanged fires and you redraw.
  • Network: networkFetch({ url, method }) is validated by the host (HTTPS-only, host allowlist, bounded request/response). The response body is the bounded value returned by the host adapter; read it defensively.
  • Errors: on failure, showError + a short title; do not swallow exceptions, log them.

3. Try it

  1. Reload the project from the Developer window (since the manifest changed, remove and select it again if needed).
  2. On the Keys screen, assign the Hava action to a key.
  3. Enter Şehir (city) in the key’s settings panel (e.g. Istanbul). The key updates like Istanbul\n+29°C.
  4. Pressing the key refreshes the data.

Where to go next

  • Cache the temperature with storageSet and show it instantly on willAppear (see reference: storage.private).
  • Knob support: switch between cities with controllers: ["Knob"] + action.dialRotate.
  • APIs with credentials: network.fetchWithCredential — the raw token never returns to the plugin.
This project can be moved to the T2 sandbox-js target: the same SDK surface works with the Worker transport. For the public upload status, see Distribution status.