Tags, tabs and buttons
Tags, tabs and kinds with their rows, buttons and menu lines, and what happens as texts arrive.
A plugin's rules say what it does: tags it gives texts by their words, sections (tabs and kinds) that take tagged texts, actions (buttons and menu lines) and incoming rules for texts as they come. Any of them can say when it applies with a condition. The examples here are from Bills and Parcels.
"rules": {
"tags": [], // up to 32 tag rules
"sections": [], // up to 4 tabs and kinds
"actions": [], // up to 12 buttons and menu lines
"incoming": [] // up to 8 rules for texts as they come
}
(JSON has no comments: they're only to say what each is.) Each part may be left out, but a plugin needs at least one tag rule or one section (empty_pack).
Conditions
A condition, a rule's when or a section's takes, is an object whose keys are all optional. Every one given must hold.
| Key | Holds when |
|---|---|
from | The sender is one of these, 1 to 50 of them, each 3 to 64 characters. A number is compared by its digits alone, so +1 (555) 010-0100 and 15550100100 are the same; a name a company texts from is compared in any case. An entry with no digit or letter in it, such as (-), matches nobody. |
tagged | The text has every one of these tags, 1 to 8 of the plugin's own. |
untagged | It has none of these, 1 to 8. |
setting | A switch's key alone: that switch is on (its default until the person changes it). Or {"key": "level", "is": "loose"}: that choice is loose (its default until changed); for a switch, "is" is "on" or "off". |
section | Actions only: the conversation is in this section of the plugin's own, or "main" for Messages. Never true in a message's menu, which isn't in a section. Anywhere else it's section_condition. |
- A plugin with an incoming rule can't use
fromanywhere (from_with_incoming): nobody can judge a rule that marks read or silences texts from numbers they don't know. Nor can a plugin with alinkbutton (bad_link_when): a tag given by sender, a tab that takes by sender or that tab's row would offer the link for those numbers alone, and pressing it would tell the page which numbers wrote. - In a tag rule,
taggedanduntaggedsee only the tags given by the rules before it, so naming a tag no earlier rule gives isunknown_tag. Everywhere else, a tag no rule gives isunknown_tag, and a section the plugin doesn't have isunknown_section. - There's no condition on groups: a plugin never sees one.
Tags
A tag rule gives a text a tag when its words match. Several rules may give the same tag: they're different ways to get it.
{
"tag": "bill",
"any": ["your bill is ready", "amount due {amount}"],
"atLeast": 1,
"none": ["unsubscribe"],
"wordsFrom": "extra",
"when": {"untagged": ["paid"]},
"detail": {"from": "token"}
}
| Field | What it is |
|---|---|
tag | The tag it gives. Required. |
any | 0 to 30 phrases, at least atLeast of which must match. |
atLeast | 1 to 5, and 1 if left out. At most the number of any phrases, unless it has wordsFrom too. |
all | 1 to 8 phrases that must all match. |
none | 1 to 20 phrases none of which may match. |
wordsFrom | A words setting's key: the words the person typed there join any, each a plain phrase (their own words). |
when | A condition. |
detail | What the tag keeps: words of your own (1 to 200 characters); {"from": "token"}, what a phrase's first token found; or {"from": "match"}, the whole of what a phrase matched. Nothing if left out. |
A rule needs something to start it: any, all, wordsFrom, or a when with from or tagged (tag_rule_no_trigger).
How a text's tags are worked out
For each text the plugin sees, its tag rules run in the order they're written, each one like this:
- If its
whendoesn't hold, with the tags given so far, the rule is passed over. - Its phrases are its
any, then the person's words fromwordsFrom. If it has either, it counts how many of them match the text; fewer thanatLeast, and it's passed over. A rule whose only phrases are the person's words does nothing until they type some. - If it has
alland one of them doesn't match, ornoneand one of them does, it's passed over. - Its detail: your own words, if that's what it says; for
{"from": "token"}, going through its phrases in order, what the first token found in the first phrase that has a token and matches; for{"from": "match"}, the whole match of the first phrase that matches. Trimmed, cut to 200 characters, and nothing where it's empty. - The text gets the tag if it hasn't got it yet. If it has it already with no detail, and this rule found one, the detail is kept.
Whenever one of the plugin's settings changes, every conversation's tags are worked out again.
An example of atLeast
{"tag": "school", "any": ["school", "pupils", "uniform", "half term"], "atLeast": 2}
"Half term starts Monday: uniform list attached." gets the tag, since two phrases match; "School's out!" doesn't, with one.
An example of wordsFrom
Bills has a words setting, More words for bills, and its first rule says "wordsFrom": "extra". Someone who types council tax, water rates there gets "Your council tax is due next week." in their Bills tab, though none of Bills' own phrases match it.
Tabs and kinds
A section takes the conversations whose last text from them meets its takes. A tab is a tab of its own in the list, beside Messages and Codes; a kind is a line in the list's filter, which people show or hide in Messages as they do the built-in kinds.
| Field | What it is |
|---|---|
key | 1 to 12 lower-case letters, unique in the plugin. |
label | 1 to 24 characters: its tab's words, or its line in the filter. Not a built-in's (name_reserved). |
icon | An icon name. |
kind | "tab" or "filter". |
leavesMain | Tabs only, true if left out: its conversations leave Messages for the tab. false keeps them in Messages too. On a kind it's leaves_main_on_filter. |
takes | A condition with tagged or from (takes_nothing otherwise), and no section. Required. |
row | How its conversations' rows look (below). |
Every section needs the sort permission. A plugin's kinds start shown, and the person hides one in the filter as they would any kind.
Built-in plugins sort first
Built-in plugins' tabs and kinds are asked first, then plugins from other developers in the order they were added, each one's sections in the order written: the first that takes a conversation has it. So a plugin never takes what Codes or the spam filter takes, nor what a kind of Kinds of text takes. Kinds of text is on from the start, and its Payment reminders and Deliveries & tracking take most bill and parcel texts before any other plugin is asked. Your plugin still tags them, but its tab gets them only where the person switches that kind off, in Marketplace › Kinds of text.
Try it says when this happens ("In this app, Kinds of text › Payment reminders takes this text first"), and every plugin's page with tabs or kinds says it to the people who add it: Built-in plugins sort first: a text Codes, Spam filter or a kind of Kinds of text takes stays theirs.
Rows
A section's row draws its conversations' rows in the list:
"row": {"value": "{tag:bill}", "caption": "A bill", "end": "copyamount"}
| Field | What it is |
|---|---|
value | Up to 24 characters, large where the last words would be, with the words small under it. A template. |
caption | Up to 60 characters, a quiet line under the words: why it's in this tab. A template. |
face | {"name": "Parcels", "color": "#4F46E5"}: in place of the sender's face, the first letter of name (1 to 24 characters, plain words) on that colour (#RRGGBB: bad_color otherwise). |
end | An action's id: its button at the row's end. |
word | An action's id: a word to press after the caption. |
tap | A copy action's id: what tapping the row does, in place of opening the conversation (a long press opens its menu, whose first line is Open conversation). |
- The row always keeps the conversation's own name. A plugin can't choose what a conversation is called, since anyone who texts could then choose the name their conversation shows.
- A face's name is plain words with no placeholder, and never a company's logo. The guidelines on other companies' names apply to it.
- A row's
tapcan only copy (verb_not_here): tapping what looks like a conversation never opens a page or writes anything. - An action a row names must list
rowin itsslots(unknown_action), and can't be awrite(verb_not_here). - A text with a sign-in code in it never gets a plugin's row.
Buttons and menu lines
{
"id": "copyamount",
"label": "Copy the amount",
"icon": "copy",
"slots": ["row", "list.conversation.menu", "conversation.message.menu"],
"when": {"tagged": ["bill"]},
"do": "copy",
"text": "{tag:bill}",
"say": "Amount copied"
}
An action has an id, a label (1 to 32 characters), an icon, 1 to 4 different slots, an optional when, what it does (do), and that verb's fields.
| Slot | Where it shows |
|---|---|
row | On its sections' rows, where a row's end, word or tap names it. |
list.conversation.menu | A line in a conversation's menu in the list (a long press). At most 3 actions (slot_full). |
conversation.header | A button in a texts conversation's header. At most 1 (header_full). |
conversation.message.menu | A line in a message's menu in a texts conversation. At most 3. |
do | Its fields | Needs | Slots | What it does |
|---|---|---|---|---|
say | text (1 to 80) | nothing | every one | Shows those words for a moment. |
copy | text (a template, 1 to 200), say (1 to 80, Copied if left out) | copy | every one | Copies the text to the clipboard, and says so. |
write | text (1 to 300) | write | conversation.header, conversation.message.menu | Writes the text in the conversation's box, for the person to send or not. |
markread | none | markread | every one | Marks that conversation read. |
move | to: "main", or one of its own tabs' keys | move | row, list.conversation.menu, conversation.header | Moves that conversation to the tab, or back to Messages. |
link | url: the plugin's one links address | links | every one | Opens that page in the browser. |
- Only a copy's
textholds placeholders. A label, asay's text, a copy'ssayand awrite's text have no{or}at all (bad_template): a stranger's words never reach the app's menus, and the words a button writes are the words the reviewer read. - A
movegoes only to Messages or one of the plugin's own tabs, never to a kind (verb_not_here). - A
linkopens only the plugin's one address (link_not_declared), and a plugin with one can't usefromanywhere, so which texts offer the button can't tell a server which numbers wrote. - An action is offered only where its
whenholds and the plugin sees the text, and a copy only where its placeholders can be filled. Itssectioncondition reads the section the conversation is in. - The list's menu, a texts conversation's header and its messages' menu are where they show. Telegram, Signal and spaces' chats never show a plugin's buttons.
- A plugin's buttons are kept from running away: words it says are shown at most once every second and a half, and it can copy at most ten times a minute.
As texts arrive
{"in": "receipts", "do": ["markread"], "setting": "autoread"}
An incoming rule marks a text read, or takes its notification away, as it comes: in is one of the plugin's own sections, do is markread, mute or both, setting is the switch that turns it on, and when is an optional condition. It acts when the conversation is in that section, the switch is on and the condition holds.
- The switch must start off (
"default": false:incoming_needs_toggle), so nothing is marked read or silenced until the person switches it on. - It runs on the phone, while the app is open, after Android has shown the notification, which it then takes away: the sound has played by then. Nothing runs while the app is closed.
- It never runs on a computer, nor on a paired iPhone. Its switch's hint says so there.
muteis for one text at a time: it takes away that text's notification and never mutes the conversation, so the next text there notifies as usual unless it too is in that section with the switch on.markreadmarks the conversation read, which takes its notification away too.- Marking a conversation read marks every text in it read, and its one notification lists every text not read yet, so it acts only where each of those is one it would mark read or silence itself as it came. A bank's alert still unread under a receipt keeps Bills from marking the receipt read; two receipts don't.
- It never acts on a text with a sign-in code in it, whatever Codes' own switch says.
- Removing the plugin switches those switches off again, so adding it back starts with them off.
- A new version that gives a switch a job it didn't have (another section, silencing as well as marking read, or a switch that was an ordinary setting before) starts that switch off as it's added or updated. A switch is only ever on for what the person switched it on for.
markreadneeds themarkreadpermission, andmutethemuteone.
Templates
A template is text with {tag:<name>} in it, <name> one of the plugin's own tags: {tag:bill} becomes the detail the bill tag kept, $45.20. {{ and }} are a plain { and }; any other {…} is bad_template.
- Only a row's
valueandcaptionand a copy'stextare templates; a placeholder anywhere else isbad_template. - Where the tag is missing, or kept no detail, the field is left out: that part of the row is empty, and the copy button isn't offered.
- A row's value and caption are cut to their length with "…"; copied text is cut without one.
What a plugin sees
A plugin from another developer is shown, and acts on, only:
- texts from one person who isn't in the phone's contacts: never a group, whose last words may be anyone's;
- words known to be theirs: never your own, and not a conversation you started that has had nothing back yet;
- texts not sent with Uplink's own encryption;
- texts (SMS and picture messages): never chats on other networks, circles and spaces, or friends by username.
While Uplink can't read your contacts (Settings › Android › Contacts is Off), no number has a name and a contact can't be told from a stranger, so a plugin from another developer sees nothing at all.
Where those don't hold, it gives no tags and offers no buttons. And whatever it sees, it does nothing to a text with a sign-in code in it: it can tag one, but its tabs don't take it, its rows don't draw it, a conversation moved into its tab by hand goes back to where it belongs, and its incoming rules leave it alone. That's wider than what the Codes tab takes: a word like code, password, verification or 验证码 anywhere in the text with a run of four to ten letters and digits holding a digit, so "G-482913 is your Google verification code." counts, and so does "Use code SAVE20". Nor does it to a conversation with such a text still unread under newer words, a code then "Never share this code" a moment later, until it's read, on a computer paired with the phone as on the phone; nor, until the phone has said, to one it's asking about. The same goes for a conversation moved into its tab whose sender is in your contacts now. Try it, and filters.classify once the plugin is on, count as texts from a stranger, so they reach it: testing what it sees.
Docs