set_data_collection_result
Store a collected data result on the current conversation for analytics.
set_data_collection_result(context: dict, key: str, value: str) -> dictStores a collected data result on the conversation — the same store the AI data collection feature writes to. Results appear in the conversation sidebar, Metrics → Custom Data charts, inbox "Collected Data" filters, and campaign analytics. If the key already exists, its value is replaced.
Use this for facts you want to measure across conversations (outcomes, reasons, feedback categories). For values your own flows read back later, use set_conversation_metadata instead.
Parameters
| Name | Type | Description |
|---|---|---|
context | dict | The context object passed to your action or event handler |
key | str | The result key (max 200 characters), e.g. "cancel_reason" |
value | str | The value to store (max 2,000 characters), e.g. "price" |
Returns
dict — {"success": bool, "message": str, "key": str, "value": str}
Limits
- Maximum key length: 200 characters
- Maximum value length: 2,000 characters
- Maximum 50 keys per conversation
Behavior
- One value per key: writing an existing key replaces its value.
- Values are strings; store booleans as
"true"/"false". - On phone campaign calls, the
successkey ("true"/"false") drives the campaign's success-rate KPI. - Results sync to your connected helpdesk (Zendesk/HelpScout) as
octocom:key:valuetags, same as AI-collected results. - In test/mock environments, returns a mock success response without persisting.
Examples
Record a campaign call outcome from an event handler
def handle_event(context):
# ... inspect context["conversation"]["messages"] ...
set_data_collection_result(context, "success", "true")
set_data_collection_result(context, "cancel_reason", "price")
return {"recorded": True}Record structured feedback from a mid-call action
def execute_action(context):
feedback = context["args"]["feedback_category"]
set_data_collection_result(context, "product_feedback", feedback)
return {"success": True}