Uplink Docs Get Uplink
Build a plugin

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.

KeyHolds when
fromThe 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.
taggedThe text has every one of these tags, 1 to 8 of the plugin's own.
untaggedIt has none of these, 1 to 8.
settingA 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".
sectionActions 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.

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"}
}
FieldWhat it is
tagThe tag it gives. Required.
any0 to 30 phrases, at least atLeast of which must match.
atLeast1 to 5, and 1 if left out. At most the number of any phrases, unless it has wordsFrom too.
all1 to 8 phrases that must all match.
none1 to 20 phrases none of which may match.
wordsFromA words setting's key: the words the person typed there join any, each a plain phrase (their own words).
whenA condition.
detailWhat 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:

  1. If its when doesn't hold, with the tags given so far, the rule is passed over.
  2. Its phrases are its any, then the person's words from wordsFrom. If it has either, it counts how many of them match the text; fewer than atLeast, and it's passed over. A rule whose only phrases are the person's words does nothing until they type some.
  3. If it has all and one of them doesn't match, or none and one of them does, it's passed over.
  4. 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.
  5. 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.

FieldWhat it is
key1 to 12 lower-case letters, unique in the plugin.
label1 to 24 characters: its tab's words, or its line in the filter. Not a built-in's (name_reserved).
iconAn icon name.
kind"tab" or "filter".
leavesMainTabs 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.
takesA condition with tagged or from (takes_nothing otherwise), and no section. Required.
rowHow 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"}
FieldWhat it is
valueUp to 24 characters, large where the last words would be, with the words small under it. A template.
captionUp 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).
endAn action's id: its button at the row's end.
wordAn action's id: a word to press after the caption.
tapA 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).

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.

SlotWhere it shows
rowOn its sections' rows, where a row's end, word or tap names it.
list.conversation.menuA line in a conversation's menu in the list (a long press). At most 3 actions (slot_full).
conversation.headerA button in a texts conversation's header. At most 1 (header_full).
conversation.message.menuA line in a message's menu in a texts conversation. At most 3.
doIts fieldsNeedsSlotsWhat it does
saytext (1 to 80)nothingevery oneShows those words for a moment.
copytext (a template, 1 to 200), say (1 to 80, Copied if left out)copyevery oneCopies the text to the clipboard, and says so.
writetext (1 to 300)writeconversation.header, conversation.message.menuWrites the text in the conversation's box, for the person to send or not.
markreadnonemarkreadevery oneMarks that conversation read.
moveto: "main", or one of its own tabs' keysmoverow, list.conversation.menu, conversation.headerMoves that conversation to the tab, or back to Messages.
linkurl: the plugin's one links addresslinksevery oneOpens that page in the browser.

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.

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.

What a plugin sees

A plugin from another developer is shown, and acts on, only:

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.

Something wrong or missing here? Tell us in the Alpha testers circle, or at the app's GitHub.