Python helpers

Python helpers

Built-in functions your Python calls with no import, from conversation tags to order lookups.

Python helpers are built-in functions your Python automations call directly, with no install or import. They handle the plumbing, so one line can tag a conversation, find an order or classify a message. For example, shopify_find_orders(context, email) returns a customer's orders without your code ever holding a Shopify token.

Helpers read and change conversations, send messages, call the platforms you've connected, reach any API from Octocom's fixed IP address, and run AI classification and summaries. Each helper has its own page with its signature, parameters, return value, limits and examples. The tables below group them by what they work on.

How helpers are used

Every Python automation defines one entry function that receives a context dictionary, and calls helpers from it:

Where your code runsEntry functionConversation in context
Python actionsexecute_action(context)When the bot calls the action in a conversation
Condition providersevaluate_conditions(context)When evaluated for a conversation
Event handlershandle_event(context)For conversation events
Recurring jobsrun_job(context)Never
HTTP endpointshandle(context)Never
Prompt sectionsbuild_prompt_sections(context)When the prompt is built for a conversation
Sidebar widgetsget_sidebar_data(context)Always
Sidebar actionsexecute_action(context)Always
Phone line routersroute_call(context)Never

Most conversation helpers take context as their first argument and act on context["conversation"]. Where there is no current conversation, such as in recurring jobs and HTTP endpoints, pass conversation_id to the helpers that accept it: send_bot_message, close_conversation and resolve_human_decisions. Python context documents every field of context and which fields each automation type receives.

def execute_action(context):
    reason = context["args"]["reason"]
    add_conversation_tag(context, "cancel-requested")
    set_data_collection_result(context, "cancel_reason", reason)
    return {"success": True}

Helpers limited to some automation types

A few helpers only run in the automation types where they are safe. Calling one elsewhere raises RuntimeError (for open_browser, its subclass BrowserAutomationError):

Tests and agent-written code

Many helpers skip their write and return a mock result when there is no conversation in context, for example in an editor test. Check a helper's page for how it behaves in tests.

You rarely need to write this code by hand. Describe the outcome to Copilot or any agent connected through Octocom MCP: it picks the helpers, writes the code, saves the automation and tests it.

Conversations

HelperWhat it does
get_conversation_metadataRead a metadata value from the conversation
set_conversation_metadataWrite a metadata value, including keys with platform meaning
delete_conversation_metadataDelete a metadata key
add_conversation_tagAdd a tag, creating it if needed
remove_conversation_tagRemove a tag from the conversation
add_conversation_noteAdd an internal note that only agents see
get_conversation_notesRead the internal notes already on the conversation
add_conversation_eventRecord an event in the timeline, which Bot QA uses as evidence
set_data_collection_resultStore a result for analytics, filters and campaign KPIs
upsert_customerCreate or update the customer linked to the conversation
close_conversationClose a conversation through the normal close pipeline
hand_off_conversationHand the conversation to a human, or transfer a live phone call
octocom_agents_availableCheck whether any help desk agent is available right now
live_chat_agents_availableCheck whether anyone in the LiveChat handoff group is accepting chats
request_human_decision and related helpersAsk a teammate for a decision while the bot keeps the conversation
set_message_sending_delayControl how long the AI waits before sending its email replies

Messages and chat UI

HelperWhat it does
send_bot_messageSend fixed text to the customer through an existing conversation
show_cardShow a card with label/value rows and buttons under the bot's reply in web chat
ask_confirmationAsk the customer to confirm with two buttons before the bot acts
send_outbound_emailEmail a customer and create a handed-off conversation for the reply
send_transactional_emailSend a one-off email, for example to an internal team, without a conversation
send_slack_notificationPost a message to a Slack channel through an incoming webhook
add_campaign_recipientsAdd people to a continuous phone campaign's calling queue
Klaviyo helpersSubscribe, unsubscribe and record events in the business's Klaviyo account

Chat UI from actions covers every UI item an action can return, beyond cards and confirmations.

Orders and shipping

HelperWhat it does
shopify_get_order / shopify_find_ordersFind Shopify orders by number or email across every connected store
shopify_get_customer / shopify_get_customer_ordersFind a Shopify customer, or their recent orders, by exact email
shopify_graphqlRun any Shopify Admin GraphQL query or mutation
woocommerce_get_order / woocommerce_find_ordersFind WooCommerce orders by number or email
magento2_get_order / magento2_find_ordersFind Magento orders by number or email
prestashop_get_order / prestashop_find_ordersFind PrestaShop orders by number or email
bigcommerce_get_order / bigcommerce_find_ordersFind BigCommerce orders by number or email
shoptet_get_order / shoptet_find_ordersFind Shoptet orders by number or email
search_imported_ordersSearch an order feed already synchronized into Octocom
track_shipmentLook up live carrier tracking events (DHL, USPS)

The order pages include the helpers' full Python source, so you can copy and adapt them. Each platform also has a <platform>_order_widget(context) helper for a read-only orders panel: see Order widgets.

Subscriptions

HelperWhat it does
Recharge subscription helpersLook up, cancel, reschedule and discount Recharge subscriptions
Loop subscription helpersLook up, cancel, reschedule and discount Loop subscriptions
WooCommerce Subscriptions helpersLook up, cancel and reschedule WooCommerce Subscriptions

Each provider also has sidebar helpers that show subscriptions with human-confirmed cancellation buttons: see Subscription widgets.

Google Sheets

Connect each spreadsheet in Integrations -> Google Sheets first. Google Sheets helpers explains access, limits, caching and safe retries.

HelperWhat it does
list_google_sheets_tabsList the tabs with their visibility and grid size
list_google_sheets_rowsList or find rows by column values, with cursor pagination
add_google_sheets_rowAppend a row, optionally to a named tab
update_google_sheets_rowPatch one uniquely identified row, failing safely if it moved
read_google_sheets_rangeRead cells by position, with hyperlinks, formulas, notes and merges
write_google_sheets_rangeOverwrite a bounded rectangle of cells
clear_google_sheets_rangeClear values and formulas while keeping formatting and rows

AI

HelperWhat it does
llm_classify_binaryAnswer a yes/no question about any text or data
llm_classify_categoryPick one category from a list you provide
llm_summarizeSummarize the conversation, or any text
transcribe_pdfExtract text from a PDF URL, including scanned pages

Credentials and external access

Octocom doesn't limit you to a fixed menu of operations per platform. These helpers give your code the stored credentials of connected platforms, your own secrets and a fixed outbound IP, so it can call any API those systems offer, read a SQL Server database or drive a website. Integration patterns shows which building block fits each kind of system.

HelperWhat it does
get_integration_credentialsGet the stored credentials of every connected integration, per business
get_secretRead an API key or token from your organization's secret vault
proxy_request / proxy_sessionCall an API from Octocom's fixed IP, for APIs that allowlist by IP
fetch_via_proxyFetch a feed from Octocom's fixed IP in product-sync parsers
sql_server_queryRun bounded SELECT queries against an external SQL Server
open_browserDrive a website through a guarded, audited browser session

Product-sync parsers have their own set of network helpers: fetch_via_proxy, open_via_proxy and proxy_tcp_relay, plus shopify_graphql without the context argument.

Utilities

HelperWhat it does
organization_store_*Keep expiring, organization-wide JSON state with atomic compare-and-set
get_ab_test_variantAssign a sticky A/B test variant to the conversation
is_holidayCheck whether a date is a public holiday in a country or region
normalize_phone_numberParse a phone number into international E.164 format
render_pdfRender an HTML document to a PDF and get a shareable link
http_responseChoose the status code and headers an HTTP endpoint answers with

On this page