Documentation

POST /api/settings/rules

Manage the support desk's keyword rules.

RequestPOST /api/settings/rules
AuthenticationSession cookie required
Handlerbackend/server.py

What it does

Add, edit or remove the rules that decide what the desk does with an inbound message. `op` names the operation; an unrecognised one is refused by name rather than treated as a default.

Authentication

Session cookie required. Send the ff_session cookie. Without one the engine treats the caller as a new visitor with no holds and no claims, and returns a new cookie to use from then on.

Parameters

ParameterInTypeRequiredDescription
ff_sessioncookiestringOptionalThe session identifier. Omit it on the first call and store the value the response sets; every later call must send the same one or the engine treats the caller as a new visitor with no holds and no claims.
opbodystringRequiredThe operation to apply. Refused as `unknown op` when unrecognised.
idbodyintegerOptionalThe rule to edit or remove.
keywordbodystringOptionalThe keyword that triggers the rule.
scopebodystringOptionalWhere the keyword is matched.
actionbodystringOptionalWhat the desk does on a match.
canned_subjectbodystringOptionalSubject of the reply this rule sends.
canned_bodybodystringOptionalBody of the reply this rule sends.

Request

The cookie jar carries the session between calls. Angle-bracketed values are the parameter types from the table above.

curl -s -b cookies.txt -c cookies.txt \
  -X POST -H 'Content-Type: application/json' \
  -d '{"op":"<string>","id":"<integer>","keyword":"<string>","scope":"<string>","action":"<string>","canned_subject":"<string>","canned_body":"<string>"}' \
  "https://flowfinds.ai/api/settings/rules"
const res = await fetch("https://flowfinds.ai/api/settings/rules", {
  method: "POST",
  credentials: "include",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
    "op": "<string>",
    "id": "<integer>",
    "keyword": "<string>",
    "scope": "<string>",
    "action": "<string>",
    "canned_subject": "<string>",
    "canned_body": "<string>"
  }),
});
const data = await res.json();
import requests

s = requests.Session()
r = s.post("https://flowfinds.ai/api/settings/rules", json={
    "op": "<string>",
    "id": "<integer>",
    "keyword": "<string>",
    "scope": "<string>",
    "action": "<string>",
    "canned_subject": "<string>",
    "canned_body": "<string>"
  })
data = r.json()

Recorded example

curl -s -b cookies.txt -c cookies.txt \
  -X POST -H 'Content-Type: application/json' \
  -d '{"op":"add","keyword":"refund","scope":"subject","action":"…"}' \
  "$FLOWFINDS_ORIGIN/api/settings/rules"

Responses

200Applied.

FieldTypeDescription
statusstring`ok`.
rulesarrayThe rule set as stored.

Errors

StatusReasonWhen
400no account yetNo account exists to attach rules to.
400unknown opThe operation is not one the handler defines.

Related

Back to the API reference index, or read the cookbook for recipes that compose this endpoint with others.