Rules
On this page
A rule says when something happens to a visit, for which visits and what Talemo writes to the client. It has three parts:
- When (
event): some hours before the visit starts (1 to 72), or something happens to the visit — it is booked, moved or closed — or some days after a visit (1 to 365) that the team has closed (a cancellation belongs only to the built-in cancellation notice, see below). - For which visits (
conditions): only visits of chosen services, service groups or masters, at most 50 of each. Nothing chosen means any visit; when several lists are chosen, a visit must fit all of them. For the events after a visit there are two more: how the visit was closed (closed_as) and that the client has no later visit (no_later_visit). - What (
action): write to the client one of the messages that go with the event. The confirmation goes with "booked" and "moved", the reminder with "hours before the visit", the message to a client who did not come and the invitation to come again with "closed" and "days after the visit" (see below). The words are those of the message template, a rule has none of its own (see Channel window and WhatsApp templates). The cancellation notice belongs only to the built-in rule: it is always on, and a rule of your own with it cannot be added — the client would get the same message twice.
Rules belong to a branch. talemo_list_rules lists them, and talemo_get_rule shows one. Each has
created_by_name, the name of the person who made it; it is left out for a built-in rule, when the
person is gone, or when they have no name. In the app the assistant shows them as the cards "Rules"
(rules, a branch) and "Rule" (rule, one rule with its history); in the web they are the card
"Clients" on the page "Booking rules".
Built-in and added in words
The three notices of a visit — confirmation, reminder, cancellation — are the built-in rules of
every branch (see Visit notices). They work as they always did, and the booking
rules of the branch (confirm_on_booking, remind_before_hours) are the same settings: a change
in one is a change in the other (see Booking rules). Built-in rules change
less than the others: the confirmation can only be turned on or off, the reminder only gets other
hours, the cancellation notice cannot be changed, and none of them has conditions. Such a change is
refused with status 400, code request.body_invalid and params.field enabled, event or
conditions.
The others are added with talemo_create_rule, for example "remind about a manicure 2 hours before
the visit": event {"on": "before_start", "hours": 2}, conditions {"services": [<service_id>]}
and action {"do": "write_to_client", "message": "visit_reminder"}. The rule works at once. One
with before_start also takes the visits already booked whose hour has not come; one with visit
acts on what happens from then on. talemo_update_rule turns a rule on or off and changes its
time (event) and conditions, which replace the old ones whole. A new time moves the firings that
wait for their hour. A rule that is off writes to no client: the firings that were still waiting
for their hour are canceled (reason rule_off), and when the rule is turned on again it makes them
anew for the visits whose hour is still ahead. New conditions cancel the waiting firings of the
visits they no longer take (also rule_off). Rules are not deleted: a rule that is not needed is
turned off, and what it did stays in the visits and in its list of firings.
A message that does not go with the event, and the cancellation notice, are refused with status 400,
code request.body_invalid and params.field action; hours or days out of range, an empty list of what happens to the visit or a
word named twice — with event; a message to a client who did not come without closed_as no_show, an invitation to come again without closed_as done and
no_later_visit, or closed_as and no_later_visit with an event that does not look back — with conditions; a list of more than 50 or a number named twice —
with conditions.services, conditions.groups or conditions.masters. A service, group or master
of another branch, like a service that does not exist, is refused with status 422, code record.reference_missing, the same
params.field and params.reason: not_found — there is no such number, not_in_branch — it is of another branch, other_kind — a place or a
device is named where a master is expected. A rule is not made or changed in a closed branch: status 409 and code branch.closed.
A rule of the whole business is changed only by a role of the whole business; for
any other role it is refused with status 403 and code role.forbidden. These refusals are
legitimate answers, not failures.
After the visit: a client who did not come, and coming again
Two messages go after a visit that the team has closed. The event is visit with closed
(the team closed the visit after its time) or after_visit with days, 1 to 365: that many
days after the end of the visit, once the team has closed it. conditions.closed_as says how:
done — the client came, no_show — the client did not come.
- A client who did not come (
visit_missed): "we were waiting for you, we will find another time". It goes withvisitclosedor withafter_visit, andclosed_asno_showis required, otherwise it would go to clients who came. One message for one missed visit. It is a service message: no discount in it, and it needs no consent mark. - Time to come again (
visit_again): an invitation to a client who came. It goes withafter_visit,closed_asdoneandno_later_visit—any(no later visit at all),same_service(none with the same service) orsame_group(none with a service of the same group), otherwise clients who have booked again would be invited. It goes only to a client whose card has the mark of consent to invitations and offers (see Turning off reminders, confirmations and cancellation notices), at most one invitation or offer in 30 days to a client from all the rules together, and one for a visit. Outside the 24-hour window WhatsApp takes it only as a template of the category marketing.
For example, "invite a client three weeks after a manicure": event
{"on": "after_visit", "days": 21}, conditions {"services": [<service_id>], "closed_as": "done", "no_later_visit": "same_service"}
and action {"do": "write_to_client", "message": "visit_again"}. A rule with after_visit also
takes the closed visits whose day has not come yet; one with visit closed acts on what is closed
from then on.
When what the condition names is deleted
A service, a service group or a master named in the condition of a rule can be deleted (talemo_delete_service,
talemo_delete_service_group, talemo_delete_resource). The rule does not start to write to everyone and does not vanish: it
is paused with condition_gone (state paused, pause.reason condition_gone, pause.at is when it was deleted). The
references.gone of the rule says what was deleted: kind (service, group or master), id, name — what it was called at the hour of
deletion (empty for old data) — and at. While the pause stands, the rule writes nothing and takes no new visits, the firings
that waited for their hour are skipped with rule_paused, and its forecast is empty. Ask before deleting: dry_run of these three tools
names the rules that would be paused (rules) — show them to the person before the real call.
A master can also stop being the one the rule names without being deleted: when talemo_update_resource gives the resource another role
(a place or a device), the rule that names it as a master is paused the same way. references.gone then holds an entry with cause
role_changed (for a deleted one it is deleted), name is what the resource is called now and at is when the role was last changed in the
card. This pause is not final: give the role master back and it goes away by itself. dry_run of talemo_update_resource names these
rules (rules of the answer) — show them to the person before the real call.
Such a rule cannot be turned on: talemo_update_rule with enabled true is refused with status 409 and code rule.condition_gone
(params.field is conditions.services, conditions.groups or conditions.masters, params.count is how many of the named were deleted).
Tell the person the condition hangs and pick something else in it: conditions replaces the old one whole, and the pause goes away by
itself. A rule can always be turned off. A group made again with the same name is a new one: it does not revive the old rules.
What a rule would do
A rule writes to clients by itself, so before it starts, talemo_create_rule and talemo_update_rule
with dry_run show it with its forecast and change nothing. talemo_get_rule shows the
forecast of a rule that is already there. It has two windows: ahead — the next 14 days — and
past — the last 30 days, as if the rule had stood then. In each:
firings— how many visits the rule fires on;clients— how many clients;sends— how many messages would go;by_template— how many of them would go as a WhatsApp template, outside the 24-hour window. Meta charges the business for these by its own rates, by country and category; the forecast counts the messages and does not count the sum, and the rates are in Meta's price list for WhatsApp Business;skipped— why the rest would not go, a reason and a count: for exampleno_confirmed_contact,window_closed,template_not_approved,daily_limit, and for an invitation to come againno_marketing_consentandmarketing_limit(withdays).
A rule with visit has nothing ahead to count: what happens to visits is not known in advance, and
the forecast ahead is empty; the last 30 days show what the rule would have done. Whether a message
would go is decided by the same rules as for a real one: the contact of the client, the window of
the channel, the approved template, the limit of the day.
Three messages in a day
All rules together write to one client at most three automatic messages in any 24 hours. The
fourth is not sent and is skipped with daily_limit. The cancellation notice is not counted and is
never held back by this limit; replies of people in the chat and the word "stop" do not count
either.
The invitation to come again, like an offer, has a limit of its own: one in 30 days to a
client from all the rules together. The second is skipped with marketing_limit, and days says the
number of days. This limit is named before the daily one; a service message is never held back by it.
Whose rights, and pause
A rule runs with the rights of the person who made it, as if they had written the message
themselves. When that person leaves the business, or no longer has the right to change the
booking rules of the branch, the rule pauses (state paused, pause.reason
creator_left or creator_lost_right) and writes to nobody. It also pauses (failures) when its last
three sends did not go because of the rule itself: the channel is disconnected, the WhatsApp template
is refused, or the business has no payment method in WhatsApp. A failure of Meta or of Talemo, or one
that belongs to a single client (a number that cannot be reached, a closed window), is not counted, and
it does not break the three either. For such a pause pause.code names the cause of the last send that did not
go: channel.revoked — the channel is disconnected, channel.template_unavailable — Meta has not approved
the WhatsApp template or has paused it, channel.payment_missing — WhatsApp has no payment method at Meta;
empty when there is no such send among the last sends of the rule any more. The screens of Talemo say the same: a red line
"Three messages in a row didn’t go out: the channel is disconnected" and a gray one under it with the place of the
fix — "Phone and messengers" on the web for the channel and the templates (the app has no settings and
points to the web), Meta Business Suite for the payment method. Tell the person the same: fix it first, then
turn the rule on. A paused rule is not lost: someone who may change the branch turns it on or
off with talemo_update_rule; the pause goes, and the person who did it becomes the one whose
rights the rule runs with. So does the person who turns on a rule that was off: whoever made it may
have left while it stood. A rule that is off does not go on pause, and the waiting firing that the
pause held is canceled by turning the rule off, not let go. The count of three sends starts again from turning the rule on (and from
any change of the rule): old failures do not pause it again. Until then a case "rule paused" waits for everyone who may change the
branch of the rule (see Kinds of items in Waiting for you); it goes away
by itself when the rule is turned on or off.
Talemo can also switch the rules made in words off in a business for now, for example after a problem
(feature.off, params.feature rules_in_words). Then talemo_create_rule is refused and is not in the
list of tools, the rules made in words that are on show as paused with pause.reason feature_off
and write to nobody, and there is nothing to turn back on: they work again by themselves when Talemo
switches the rules back on. The three built-in notices of a visit work as usual.
A rule that is on, but whose WhatsApp has no approved template of its message, has state
waits_template: inside the 24-hour window the message goes as text, outside it does not go until
Meta approves the template.
What a rule did
talemo_list_rule_firings lists the firings of a rule, the newest first (limit 1 to 200, 50 when
left out). Each is one message to the client, one line per message: back-to-back visits that got one message
for all of them are one line of the first visit, with chain_size (how many visits are in the message) and the hour of the
message in due_at; limit counts messages. One that did not go or was withdrawn stays a line per visit. A line has kind (confirmation, reminder, cancellation, missed — a client who did not come — or again — an invitation to come again) and
state: planned waits for its hour (due_at), sent went to the queue of the channel,
skipped did not go, cancelled was withdrawn because the visit was canceled, done or moved, or
the rule was turned off (rule_off) or its conditions narrowed.
reason says why one did not go or was withdrawn (see Visit notices for the
reasons of the channel), and these six are added by rules: daily_limit, with limit — how many
messages a day a client gets —, has_later_visit, when the rule writes only to a client with no
later visit, rule_paused, rule_off — the rule was turned off, or its conditions no longer take
this visit —, no_marketing_consent — no client consent to invitations and offers —, and
marketing_limit, with days. party_name is the name on the card of the client. A sent one says how: channel,
via (text or a WhatsApp template) and delivery (queued, sent, delivered, read or
failed, with the code of the refusal). A waiting one that will not go by what Talemo knows now
has expected_skip, the reason. activity of a rule counts the messages that wait now and those sent
in the last 30 days, and the visits for which a message did not go: back-to-back visits are one message.