SelfscribeDownloadOpen the app

Automations and apps

A folder can fetch records from another system, send records to it, and do small jobs when something happens. All of it is plain text in three folders inside your folder:

FolderOne file isIt says
connectors/a connectorone request to a server, and where its records go
actions/an actionsteps, done in order
automations/an automationwhen to run an action

Nothing runs until you have read what it will do and allowed it. The quickest start is a ready-made one from Settings › Automations › Gallery.

Fetch records from another system

#

A connector is a .self file of set lines:

selfscribe
~~~ selfscribe
set url https://crm.example/api/customers
set header Authorization: Bearer {secret:crm}
set pick data
set map email contact.email
set write merge id
set output data/customers.csv
~~~
# Customers, fetched
LineWhat it does
set urlThe address, https://, or http://localhost for a server on this computer.
set methodGET unless you say POST, PUT, PATCH or DELETE.
set header, set bodyA header, one line each, and what is sent. {name} takes a record's cell.
set pick dataWhere the list is in the answer.
set map email contact.emailA column of yours, and where its value is in each item.
set where, set sort, set limitKeeps, orders and counts the rows.
set outputWhere the records go: a .csv, .tsv or .json file, or a document.
set writereplace, append, merge id to keep your own columns, or mirror id to remove what the server dropped.
set pages 10Fetches a list that comes in pages.

A key or a token never goes in the file. Save it in Settings › Automations › Secrets under a name, and write {secret:NAME} where it belongs. It is kept in the system keychain.

Do things in order with an action

#

An action is steps, one set step line each:

selfscribe
~~~ selfscribe
set step call customer-out
set step set-cell data/customers.csv name = {name} | id = {reply.id}
set step notify {name} sent: id {reply.id}
~~~
# Send a customer, keep the id
StepWhat it does
callRuns a connector. Its answer is {reply}, and {reply.id} a value in it.
add-rowAdds a record at the end of a .csv or .tsv file.
set-cell, set-cellsChanges the first record that matches, or every one.
askAsks a question with buttons. It stays until it is answered.
append, prepend, write, createAdds a line to a file, or writes the file.
notify, open, copyShows a message, opens a file, or copies text.

The parts of a step are cut at | . Each button of a question names the action it runs:

selfscribe
set step add-row data/log.csv {today} | {time} | started
set step ask Night, 21:30 | Took all = took-night | Snooze 15 min = snooze 15 | Skip

A send that cannot reach the server is kept and tried again, and goes on from the step where it stopped. Look first on any action shows what would be sent and written, and does neither.

Run it when something happens

#

An automation names a moment and an action:

selfscribe
~~~ selfscribe
set when record added data/customers.csv
set do send-customer
~~~
set whenThe moment
record added SOURCEA record is added through a view.
record changed quotes status to wonA cell changes, here to one value.
record deleted SOURCEA record is deleted.
comment added, document saved, file changed FILEComments, saves and files.
daily at 09:00, every 30 minutesA time, while the folder is open.
schedule data/reminders.csvOnce a day per record, at the time in its at column.
openThe folder is opened.

The action knows the moment's names: {today}, {time} and {weekday} always, and from a record each cell by its column's name, with {was} and {value} for a changed cell.

An automation is off until you switch it on in Settings › Automations. The first time an action runs, the app shows what it will do and asks: Run once, or Always allow in this folder.

Put a button in a document

#

Add this rule to the document, then write [[Fetch the customers|fetch-customers]]:

selfscribe
inline  [[_|_]]  -> span.self-button data-self-action=_2 _1

Pressing the button runs actions/fetch-customers.self. A view can put a button in each row instead: view: data/plants.csv as table button Watered runs watered.

Show a folder as an app

#

A folder can open as an app: a few screens, a bar at the bottom to move between them, and nothing of the editor around them. Each screen is an ordinary document. Add app.self at the top of the folder:

selfscribe
~~~ selfscribe
set app Daily plan
set screen Today = today.self | check
set screen Journal = journal.self | book
set screen Progress = progress.self | chart
set accent #2f7d6b
~~~

Each set screen line is a tab of the bar, up to five, with its label, its document and an icon. View › Open this folder as an app shows the app, and the pencil at the top right goes back to the editor. A screen holds anything a document can hold. What makes it feel like an app:

  • views drawn plain, lists to tick, tiles of totals and forms,
  • buttons that run actions, and questions with buttons at a time of day,
  • links to the other documents of the folder.

View › Show this document as a page by itself does the same for one document.

Give the app to someone

#

File › Package this app for a web host… saves one .zip. Unpack it on any web host, and the address of that folder is the app. It has the app's own name, colour and icon, so a phone that installs it shows Daily plan, and it works without a connection once opened.

What each person enters is kept in their own browser, on their device. To share records between people, share the folder itself with sync.