{
"success": true,
"message": "success",
"data": {
"outcome": "TRIPPED",
"returned": true,
"matched": true,
"variables": {
"needs_review": true
},
"newText": "Your card **** **** **** 1111 is on file.",
"rendered": "Hello Sara, how can I help?",
"text": "My card is 4111 1111 1111 1111",
"vars": {
"guardrail_strikes": "1",
"_side": "caller",
"_guardrail_id": "try-it"
},
"durationMs": 3.2,
"error": {
"kind": "RUNTIME",
"message": "ReferenceError: 'txt' is not defined",
"line": 2
}
}
}{
"code": 8404,
"message": "Policy not found!",
"messageKey": "PolicyNotFound",
"params": {
"reason": "NO_DRAFT"
}
}{
"code": 8404,
"message": "Policy not found!",
"messageKey": "PolicyNotFound",
"params": {
"reason": "NO_DRAFT"
}
}{
"code": 8404,
"message": "Policy not found!",
"messageKey": "PolicyNotFound",
"params": {
"reason": "NO_DRAFT"
}
}{
"code": 8404,
"message": "Policy not found!",
"messageKey": "PolicyNotFound",
"params": {
"reason": "NO_DRAFT"
}
}{
"code": 8404,
"message": "Policy not found!",
"messageKey": "PolicyNotFound",
"params": {
"reason": "NO_DRAFT"
}
}{
"code": 8404,
"message": "Policy not found!",
"messageKey": "PolicyNotFound",
"params": {
"reason": "NO_DRAFT"
}
}Try Function or Macro
Runs code on a sample text and vars the way a call runs it, without saving anything. Send type, usedAs and code, or the functionMacroId of a saved one (fields you also send replace its saved ones). vars reach the script as on a call: values as text unless JSON, empty ones left out. A HELPER is called like a prompt calls it, with args or with its parameters read from vars. A failing script still returns 200, with error set.
{
"success": true,
"message": "success",
"data": {
"outcome": "TRIPPED",
"returned": true,
"matched": true,
"variables": {
"needs_review": true
},
"newText": "Your card **** **** **** 1111 is on file.",
"rendered": "Hello Sara, how can I help?",
"text": "My card is 4111 1111 1111 1111",
"vars": {
"guardrail_strikes": "1",
"_side": "caller",
"_guardrail_id": "try-it"
},
"durationMs": 3.2,
"error": {
"kind": "RUNTIME",
"message": "ReferenceError: 'txt' is not defined",
"line": 2
}
}
}{
"code": 8404,
"message": "Policy not found!",
"messageKey": "PolicyNotFound",
"params": {
"reason": "NO_DRAFT"
}
}{
"code": 8404,
"message": "Policy not found!",
"messageKey": "PolicyNotFound",
"params": {
"reason": "NO_DRAFT"
}
}{
"code": 8404,
"message": "Policy not found!",
"messageKey": "PolicyNotFound",
"params": {
"reason": "NO_DRAFT"
}
}{
"code": 8404,
"message": "Policy not found!",
"messageKey": "PolicyNotFound",
"params": {
"reason": "NO_DRAFT"
}
}{
"code": 8404,
"message": "Policy not found!",
"messageKey": "PolicyNotFound",
"params": {
"reason": "NO_DRAFT"
}
}{
"code": 8404,
"message": "Policy not found!",
"messageKey": "PolicyNotFound",
"params": {
"reason": "NO_DRAFT"
}
}Authorizations
Body
The code (1-20,000 characters), compiled when you save it.
Function: the body of function (text, vars) { ... }. text is what was said, as said; vars are the call's variables, as text unless a value is JSON. A CHECK returns true to match. An ACTION returns a string (the new text) or an object (the variables to set). JavaScript built-ins only (no console, fetch or timers); 50 ms and 16 MiB per run.
Macro: a template with text, vars and args, or a {% macro <name>(...) %} definition (required for HELPER, named like the record). A CHECK matches unless it renders empty, false, 0, none or no. An ACTION sets variables when it renders a JSON object; anything else is the new text. 50 ms and 64 KiB of output.
1 - 20000HELPER macros only, and optional: the parameters that the {% macro <name>(...) %} in code declares, in order. Hamsa reads them from the code; if you send them they must match it (FunctionMacroParamsMismatch). Leave out or null for CHECK and ACTION.
2064^[A-Za-z_][A-Za-z0-9_]*$What was said (up to 20,000 characters), used as sent.
20000Was this page helpful?