Python Context
The context object passed to every Python function — conversation data, customer profile, business info, and more.
Every Python function in Octocom — whether it's a custom action, condition provider, event handler, or sidebar widget — receives a single context dictionary as its argument. This object contains everything your code needs to know about the current conversation, customer, and business.
Top-level fields
| Field | Type | Description |
|---|---|---|
conversation | dict or None | The current conversation — messages, IDs, subject, and channel info |
business | dict | The business this conversation belongs to |
customer | dict or None | The customer's profile — None if the customer hasn't been identified |
args | dict | Arguments passed to the function (custom actions, condition providers, and event handlers) |
browser_session | dict or None | Browser session data — only present for web chat conversations |
context["conversation"]
Contains the full conversation with its messages. Always present for event handlers and sidebar widgets. Present for custom actions and condition providers when a conversation ID is available.
| Field | Type | Description |
|---|---|---|
id | str | Internal conversation UUID |
publicId | str | Short public ID shown in the dashboard (e.g., "A1B2C3") |
subject | str | Conversation subject line |
businessSlug | str | Slug of the business this conversation belongs to |
initialChannel | str or None | Channel of the first message (e.g., "web", "email", "instagram") |
latestChannel | str or None | Channel of the most recent message |
messages | list | Array of message objects (see below) |
Messages
Each entry in context["conversation"]["messages"] is a dictionary:
| Field | Type | Description |
|---|---|---|
sender | str | Who sent the message — "customer", "bot", or "agent" |
timestamp | str | When the message was sent (ISO 8601 format) |
content | str | The message text |
channel | str | The channel the message was sent on |
context["business"]
Basic information about the business.
| Field | Type | Description |
|---|---|---|
name | str | The business name |
slug | str | The business slug |
context["customer"]
The customer's profile. This is None if the customer hasn't been identified yet (e.g., the conversation just started and no email has been collected).
| Field | Type | Description |
|---|---|---|
id | str | Internal customer UUID |
email | str or None | Customer email address |
name | str or None | Customer name |
phone | str or None | Customer phone number |
instagramUsername | str or None | Customer's Instagram handle |
context["args"]
A dictionary of arguments passed to the function. The contents depend on the function type:
- Custom actions — arguments defined in the action configuration and provided by the bot (e.g.,
context["args"]["orderId"]) - Condition providers — arguments defined in the workflow configuration and collected from the customer (e.g.,
context["args"]["email"]) - Event handlers — contains a single
event_typekey with the event name (e.g.,context["args"]["event_type"]returns"conversation_closed") - Sidebar widgets — do not receive
args
context["browser_session"]
Browser session data for web chat conversations. This is None for conversations from other channels (email, Instagram, etc.). Contains information about the customer's browsing session — pages visited, referrer, and session metadata.
Availability by function type
Not every field is present in every function type:
| Field | Custom Actions | Condition Providers | Event Handlers | Sidebar Widgets |
|---|---|---|---|---|
conversation | If available | If available | Always | Always |
business | Always | Always | Always | Always |
customer | If available | If available | If available | If available |
args | Always | Always | Always | Not present |
browser_session | Web chat only | Web chat only | Web chat only | Web chat only |