Human decision helpers
Ask a teammate for one decision from Python while the bot keeps the conversation.
request_human_decision(context: dict, key: str, summary: str, decisions: list, info: dict = None, timeout_hours: int = None) -> dict
get_human_decision_result(context: dict, key: str) -> dict
resolve_human_decisions(context: dict, answers: list, conversation_id: str = None) -> dictThese helpers let the bot ask your team for one specific decision, such as approving an exchange, without handing over the conversation. An agent answers on a card in the conversation. The bot is then triggered again, reads the outcome and continues with the customer.
This page is the reference. For the complete setup with the request and check actions, workflow instructions and testing, read Human-in-the-loop decisions. To let someone outside Octocom decide, for example from a link in Slack, follow the external decisions playbook.
| Helper | Where you call it | What it does |
|---|---|---|
request_human_decision | Usually a bot action | Creates the decision card, or returns the existing one |
get_human_decision_result | Usually a bot action | Reads the pending, resolved or expired outcome |
resolve_human_decisions | Only HTTP endpoints, recurring jobs, event handlers and sidebar actions | Records a decision made outside the dashboard |
request_human_decision
Registers a request for a decision, shown to agents as an Action requested card with buttons. The customer never sees it. The helper returns immediately; Python does not wait for the decision.
| Parameter | Type | Description |
|---|---|---|
context | dict | The action's context, including the current conversation |
key | str | Stable identifier for this request within the conversation, 1 to 100 characters |
summary | str | What the agent needs to decide. Must not be empty |
decisions | list | One or more buttons, each {"key": ..., "label": ...} with an optional input (see below) |
info | dict | Optional read-only fields shown on the card, as {label: value}. Values are sent as strings |
timeout_hours | int or None | Hours a pending request may wait before it expires, 1 to 336. Defaults to 48 |
A decision can ask the agent to type one value:
{"key": "reject", "label": "Reject", "input": {"label": "Reason", "type": "text", "required": True}}Returns {"status": ..., "requestId": str, "decision": str | None, "inputs": dict | None}.
- One request per key. Calling again with the same conversation and key returns the existing request, including a resolved result. It doesn't reset the request or change its summary, buttons or fields. Use a new key only for a genuinely new review.
- Pending requests keep the conversation open. It is not auto-closed for inactivity while a request is pending.
- Expiry hands off. If nobody answers within
timeout_hours, the request expires and the conversation is handed off to an agent. Expiry is final. - Testing: without
context["conversation"], it returnspendingwithrequestId: Noneand creates no card.
get_human_decision_result
Reads the current state of the request with this key in the current conversation. It never creates or resolves a request.
| Status | Meaning |
|---|---|
pending | Waiting for a decision |
resolved | Read decision (the button's key) and inputs (keyed by input label) |
expired | Nobody answered in time and the conversation was handed off |
none | No request with this key exists in the conversation |
{
"status": "resolved",
"requestId": "<request UUID>",
"decision": "reject",
"inputs": { "Reason": "This item is outside the exchange window." }
}Without context["conversation"], it returns {"status": "none"}.
resolve_human_decisions
Records a decision a human made outside the Octocom dashboard, for example on a review page backed by a custom HTTP endpoint. The card shows the outcome as if an agent had answered it, and the bot is triggered within about a minute to read it.
| Parameter | Type | Description |
|---|---|---|
context | dict | The function's context |
answers | list | One {"key": ..., "decision": ..., "inputs": {...}} per request. inputs is optional |
conversation_id | str or None | Conversation UUID or public ID. Defaults to the current conversation; required in HTTP endpoints and recurring jobs |
- Partial answers:
answerscan cover some or all of the conversation's pending requests. The rest stay pending, and the bot's turn covers only the requests answered in this call. Answer requests decided together in one call so the customer gets one reply. - Inputs: include the label of every required input. Extra labels, such as who reviewed the case, are stored and shown on the card.
- All or nothing: a refused call saves none of its answers. Recording a decision is final.
- Only HTTP endpoints, recurring jobs, event handlers and sidebar actions can call it. Anywhere else, including bot actions, it raises
RuntimeError, so the bot can never approve its own request. Withoutconversation_idor a current conversation, it raisesValueError.
Returns {"success": True, "conversationId": str} once recorded, or {"success": False, "error": str, "code": str} when refused:
| Code | Meaning |
|---|---|
invalid | The decision isn't offered by the request, or required text is missing |
not_found | The conversation or request key doesn't exist |
already_resolved | Someone already answered |
expired | The request passed its timeout and the conversation was handed off |
imported | Imported conversations can't be changed |
Only record a decision from a caller you have verified. HTTP endpoint URLs have no built-in authentication, so check a signed or stored token before calling this helper, and take the conversation ID from that token rather than from the request body.
Example: request and check actions
# requestExchangeReview
def execute_action(context):
order_id = context["args"]["orderId"]
return request_human_decision(
context,
key=f"exchange_review:{order_id}",
summary=f"Review exchange request for order {order_id}",
decisions=[
{"key": "approve", "label": "Approve exchange"},
{
"key": "reject",
"label": "Reject exchange",
"input": {"label": "Reason", "type": "text", "required": True},
},
],
info={"Order": str(order_id)},
)# checkExchangeReview
def execute_action(context):
order_id = context["args"]["orderId"]
return get_human_decision_result(context, key=f"exchange_review:{order_id}")Both actions must build the same key. Enable both in the workflow, and tell the bot to call the check action when it is notified that the review is resolved. Human-in-the-loop decisions has the full workflow instructions.