Forms
A form is a sheet of fields a person fills in and sends once: a poll’s question and answers, a giveaway’s prize, the reason for a report. Your wisp opens one only in answer to the person’s own run or press, and it goes to them alone. Like a private card, it is kept nowhere: Woosh keeps only what it needs to check what comes back.
Every Woosh app draws forms: desktop, web, and the phone from version 1.0.24. An older phone app
shows the form’s text instead.
Opening one
Section titled “Opening one”ana runs /poll with nothing after it. Answer the run with a form, as an aside:
{ "i": 80, "t": "respond", "d": { "to": "0199dea4-5b31-7c4d-8e5f-6a7b8c9d0e11", "as": "aside", "text": "New poll: fill it in to post it.", "form": { "action": "new-poll", "title": "New poll", "text": "Ask the channel something. Everyone sees the answers as they come in.", "fields": [ { "name": "question", "label": "Question", "kind": "text", "required": true, "max": 300 }, { "name": "answers", "label": "Answers", "kind": "text", "description": "One per line, 2 to 10", "required": true, "lines": 6, "max": 900 }, { "name": "pick", "label": "People pick", "kind": "choice", "prefill": "one", "choices": [{ "value": "one", "label": "One answer" }, { "value": "many", "label": "As many as they like" }] }, { "name": "ends", "label": "Ends", "kind": "time", "required": true, "prefill": 1792003200000000, "min": 1791916800000000, "max": 1792521600000000 }, { "name": "anonymous", "label": "Hide who voted", "kind": "toggle" } ], "submit": "Post poll", "value": "step-1" } }}{"r":80,"v":"0199dea4-5b31-7c4d-8e5f-6a7b8c9d0e11"}v is the form’s id, which is the run’s own: a form goes under the run it answers, as an aside
does. ana’s apps hear an aside with the text and the form, without its value, which only
your wisp gets back. The app she ran /poll from opens the sheet at once; her other apps show a row in the
channel that opens it, and open nothing by themselves. A form is the run’s one answer: it ends
her app’s wait, and spends what a private answer spends.
respond with a form |
|
|---|---|
to |
a run, or a press |
as |
aside: a new form, under the run’s or the press’s id. update, to a press on a private card or a sending of a form: that aside moves on into the form in place, under its own id |
text? |
what an app that does not draw forms shows. Left out, Woosh writes it from the form’s title |
form |
the form |
Never a card or a patch beside a form, and never as a line: a form is always the person’s
alone.
The shape
Section titled “The shape”| Key | |
|---|---|
action |
your own name for it, which the sending brings back: written as an action’s name |
title |
1 to 80 characters, at the top of the sheet |
text? |
1 to 1,000 characters, with the marks a card’s text takes, under the title |
fields |
1 to 10 |
submit? |
the send button’s words, 1 to 40 characters; left out, Woosh’s own “Send” |
notice? |
1 to 200 characters for the whole form, shown by the send button: why it cannot go yet (“Polls are off here”) |
value? |
1 to 100 bytes of your own, brought back with the sending as an action’s value is. Woosh keeps it beside the form: it never reaches the person’s apps |
errors? |
by field name, 1 to 200 characters each, drawn under the field: mostly on a form moved on |
A field:
| Key | |
|---|---|
name |
written as an action’s name, once in the form: the key its answer comes back under |
label |
1 to 80 characters |
kind |
text, number, member, channel, role or choice, the kinds a command’s option takes, and toggle or time |
description? |
1 to 100 characters, under the label |
required? |
true when the form cannot be sent with it empty |
prefill? |
filled in as the sheet opens, written as its answer is (below): settings shown as they stand |
for text |
lines?: 1 to 10, the box’s height (left out, 1; one line holds no line break). min? and max? in characters: 0 to 4,000 and 1 to 4,000 (left out, 0 and 1,000) |
for number |
min?, max?, and whole?: true for whole numbers only, which the app steps by one; its min and max are whole too |
for choice |
choices: 1 to 25 of value and label, each 1 to 100 characters, each value once. pick?: how many may be picked, from 1 (left out) to all of them |
for toggle |
nothing more: on or off, and off when its prefill is left out. With required it must be on to send (“I read the rules”) |
for time |
min? and max?, as times. The person picks a day and a time to the minute, on their own clock and in their own language |
A choice with pick above 1 is drawn as tick boxes. A time is always on a whole minute: its
prefill, min, max and answer are each a multiple of 60,000,000 microseconds.
A form holds at most 4,000 characters of words (its title, text, button words and notice, every
label, description, choice label and error, and the text it fills in) and 8 KB. A form past a
limit, or with a part out of place, is refused, invalid, and w says what is wrong, as for a
card: a min above its max, a time off the minute, a whole field with a bound that is not
whole, or a prefill that is not of its kind or breaks its own limits or choices.
No field is hidden and none is a password. The sheet shows your wisp’s name and picture at its head, so the person knows who gets the answers, and Woosh’s own line at its foot telling them never to share a password.
A sending
Section titled “A sending”ana fills it in and presses Post poll. Her app checks each field as she types, by the rules
above, then Woosh checks them all again: that the form is still known (an hour from when it was
sent or moved on), that it is hers and in this channel, that your wisp is still there and online,
that she is within her own 3 runs and presses a second, and every value. Then your line hears
act:
{ "c": 61, "n": 120, "t": "act", "d": { "server": "5c3b1a2d-8e4f-4a6b-9c7d-0e1f2a3b4c55", "channel": "6d4c2b3e-9f5a-4b7c-8d6e-1f2a3b4c5d66", "message": "0199dea4-5b31-7c4d-8e5f-6a7b8c9d0e11", "id": "0199dea4-6c42-7d5e-9f60-7b8c9d0e1f22", "user": "3f1c9a52-6d1e-4c8b-9a51-2b7e0c4d8f11", "name": "ana", "avatar": "639201477315520417", "kind": "form", "action": "new-poll", "value": "step-1", "values": { "question": "Where do we eat?", "answers": "Pizza\nTacos\nPizza", "pick": "one", "ends": 1792003200000000, "anonymous": false }, "expires": 1791916930000000 }}| Key | |
|---|---|
message |
the form’s id |
id |
the sending: what you answer |
kind |
form |
action |
the form’s own |
value? |
the form’s own value |
values |
the answers, by field name. Always there on a sending, {} when every field was left empty. Text as text, a number as a number, a member, channel or role as its id (lowercase), a choice as its value, or a list of values where pick is above 1, a toggle as true or false (always there), a time in microseconds since 1970 like every time on the line. A field left empty is left out |
Every value has been checked against its field before your wisp hears it, and comes written one way, whatever the person’s app sent. What is left to you is your own rules: two answers that say the same thing.
The rules
Section titled “The rules”A sending Woosh refuses never reaches your wisp. The person’s app is told why field, with
field (the field’s name), rule (the one broken) and limit (the number or time it names,
where it names one), and writes its own words under the field. Woosh names the first rule a
sending breaks: a field the form does not have, then each field in the form’s order, then whether
each member, channel and role is the server’s.
rule |
The value | limit |
|---|---|---|
needed |
a required field left empty | |
on |
a required toggle left off | |
kind |
not of its field’s kind | |
short, long |
text under min or over max characters |
min, max |
line |
a line break in a text of one line | |
low, high |
a number or a time under min or over max |
min, max |
whole |
a number that is not whole, in a whole field |
|
minute |
a time that is not on a whole minute | |
choice |
not one of the field’s choices | |
pick |
more picks than pick, or one twice |
pick |
member, channel, role |
not of the server | |
unknown |
a field the form does not have | |
total |
the text answers together past 8,000 characters, named at the field that passes it | 8,000 |
Every rule is also a file of cases, /forms/rules.json, which Woosh’s own
apps test against. SDK authors can test against it too:
| Key | |
|---|---|
server |
the ids that are the server’s, by kind (member, channel, role): any other is not of the server |
forms |
forms by a name of the file’s own, each as a wisp sends it |
shapes |
forms a wisp might send, each ok or refused with its why |
sendings |
values a person might send to one of the named forms, each ok, with heard where your wisp hears them written otherwise, or refused with its field, rule and limit |
A refusal’s words are not part of a case: only its codes are compared.
Answering a sending
Section titled “Answering a sending”A sending is a press on an aside, so it is answered as a press on a private
card is, once, before expires, by as:
as |
What happens |
|---|---|
update with a form |
the sheet stays open, moved on: errors or a notice from your own rules, or a next step. A field keeps what the person typed when the new form has one of the same name; a new field starts from its prefill |
update with text or a card |
the form’s row in the channel becomes that, and the sheet closes |
aside |
a new aside under the sending’s id (words, a card or a new form); the sheet closes and the form’s row goes |
line |
a line in the channel; the sheet closes and the row goes |
A form is sent once. While a sending waits for your answer, a second one is refused, sent;
once its 15 seconds pass unanswered, the person may send it again. Answer it as an update with
a form and it can be sent again; answer it any other way and the form is gone, so a poll is
never posted twice: a later sending is refused, gone. When a form goes, the person’s apps hear
so (form.gone): each closes its sheet, and none keeps a row that cannot be sent. A form that
only moves on is not gone, and nothing is told when its hour runs out: a sending after it is
refused, gone.
ana wrote Pizza twice. Move the form on with the reason under the field:
{"i":82,"t":"respond","d":{"to":"0199dea4-6c42-7d5e-9f60-7b8c9d0e1f22","as":"update","text":"New poll: two answers say Pizza.","form":{"action":"new-poll","title":"New poll","fields":[{"name":"question","label":"Question","kind":"text","required":true,"max":300},{"name":"answers","label":"Answers","kind":"text","description":"One per line, 2 to 10","required":true,"lines":6,"max":900},{"name":"pick","label":"People pick","kind":"choice","prefill":"one","choices":[{"value":"one","label":"One answer"},{"value":"many","label":"As many as they like"}]},{"name":"ends","label":"Ends","kind":"time","required":true,"prefill":1792003200000000,"min":1791916800000000,"max":1792521600000000},{"name":"anonymous","label":"Hide who voted","kind":"toggle"}],"submit":"Post poll","value":"step-1","errors":{"answers":"Two answers say Pizza."}}}}Everything she typed stays, and the words show under Answers. A notice in place of errors
says something of the whole form, as when polls are off in a channel, and the sheet stays open
just the same. When it is right, post the poll and answer the sending as an update with words
(“Your poll is up.”): the form’s row becomes them, and the sheet closes.
While your wisp works on a sending, the sheet shows it working. With no answer in 15 seconds, the sheet stays open with everything typed and says your wisp did not answer: nothing a person typed is lost to a slow wisp. Closing the sheet sends nothing, and your wisp hears nothing of it; the row in the channel opens it again until the form is gone.
Kept nowhere
Section titled “Kept nowhere”A form and its answers are never stored. The form reaches the person’s open apps as an aside does, and they keep it until it is gone or dismissed. Woosh keeps its shape (the names, kinds, limits and choices of its fields, its action and value, whose it is and where), never its words, for an hour. The answers pass once through your line, so they sit in its 10-minute replay as a command’s options do, for a line coming back with its cursor. Keep what you need of them yourself.