add_conversation_tag
Add a tag to the current conversation for filtering and analytics.
add_conversation_tag(context: dict, tag: str) -> dictAdds a tag to the conversation. If the tag doesn't exist in your system, it is created automatically.
Parameters
| Name | Type | Description |
|---|---|---|
context | dict | The context object passed to your action |
tag | str | The tag text to add (max 100 characters) |
Returns
dict — {"success": bool, "message": str, "tagId": str}
Behavior
- If the tag name doesn't exist yet, it is created automatically for your organization.
- If the tag is already on the conversation, the operation succeeds without changes.
- Skipped in test/mock environments.
Examples
Tag after a refund
def execute_action(context):
# ... process refund ...
add_conversation_tag(context, "refunded")
return {"success": True}Tag based on order value
def execute_action(context):
order = fetch_order(context["args"]["orderId"])
total = order["total"]
if total > 500:
add_conversation_tag(context, "high-value-order")
return orderTag for routing analytics
def execute_action(context):
add_conversation_tag(context, "cancel-requested")
add_conversation_tag(context, f"cancel-reason:{context['args']['reason']}")
# ... handle cancellation ...