Common automation patterns

Ready-to-adapt recipes for common support automations, from order lookups to refund policies.

These recipes build common support automations end to end, with the Python and workflow instructions to adapt. Each one combines workflows with custom actions or condition providers where it needs them, so the AI agent can finish the job on its own. For example, Enforce a time-based refund policy checks the order date before the AI agent decides what to offer.

The APIs in the examples are placeholders. Point them at your own systems, whatever your industry, or ask Copilot or your own AI agent to adapt a recipe and build it for you.

Look up and change records

Look up an order or other record

Connect a workflow to your order management system so the AI agent can look up an order and share its status. The same pattern works for any record a customer asks about: a booking, a claim, a ticket or an account.

What you need:

  • A Python action that calls your OMS or ERP API
  • A workflow that collects the order ID and calls the action

Action: getOrderDetails

Workflow instructions:

  1. Ask for the customer's order ID and email address
  2. Call getOrderDetails with both values
  3. Share the order status, items, and tracking link
  4. If there's no tracking number yet, explain the order is still being processed
  5. If the order wasn't found, ask the customer to double-check the details

Tip: Requiring both order ID and email adds a layer of customer authentication: the AI agent won't reveal order details to someone who only guesses an order number.

Identify a logged-in customer

If the customer is logged in on your website, you can pass their identity to the AI agent automatically, with no need to ask for their email or user ID.

How it works:

  1. Your website writes the user's info to localStorage using the octocom:data: prefix
  2. The chat widget sends it as conversation metadata
  3. Your Python actions read it with get_conversation_metadata

On your website:

In your action:

The AI agent doesn't need to ask for the customer's identity: it already has it. See Chat custom data for the details, including how to pass tokens safely.

Handle refunds safely

Process refunds automatically while making sure the order is actually eligible.

What you need:

  • A Python action that validates the order state before processing
  • A workflow (or variant) that guides the conversation

Action: processRefund

Why this matters: The action checks the order state before touching anything. If the order is already refunded or hasn't been delivered, it returns an error instead of processing a duplicate refund. The AI agent receives the error and explains it to the customer.

Generate a return label

Call your shipping provider's API to create a return label and share it with the customer.

Action: generateReturnLabel

Workflow instructions:

  1. Confirm the customer wants to return their order
  2. Call generateReturnLabel with the order ID
  3. Share the label download link and tracking number
  4. Explain the return process (where to drop off, when to expect the refund)

Place an order from chat

Let the AI agent collect product selections and create an order directly in your system, turning the chat into a sales channel.

What you need:

  • A Python action that creates orders via your API
  • A workflow that guides the customer through product selection and checkout

Action: createOrder

Workflow instructions:

  1. Help the customer find products (use searchProducts if available)
  2. Confirm the items and quantities, and show a running total
  3. Collect the customer's name and phone number
  4. Call createOrder with the cart details
  5. Share the order ID and confirmation link
  6. Do not collect payment or shipping details in chat: the confirmation link handles that

Why a Python action? The AI agent passes cart items as a JSON string. The action parses it and handles edge cases, which an API action can't do.

Apply policies with condition providers

Enforce a time-based refund policy

Use a condition provider to check whether the order falls within your policy window, and route to a different variant for each case.

Condition provider:

Variants:

#VariantConditionsWhat the AI agent does
0Not foundorderNotFoundAsk customer to verify order ID
1Not deliverednotDeliveredExplain the order hasn't arrived yet
2Already refundedisRefundedInform customer it's already been refunded
3Within 14 dayswithin14DaysProcess full refund: within standard return window
4Within 60 dayswithin60DaysOffer partial refund or store credit: extended window
5Default(none)Deny refund: outside policy window, explain why

The condition provider does the date math. Each variant gets simple, focused instructions for its specific case.

Offer different policies to different customers

Combine customer data with condition provider logic to route VIP customers, first-time buyers, or high-value orders to different treatment.

Condition provider:

Variants:

#VariantConditionsWhat the AI agent does
0VIPisVipOffer full refund, no questions asked. Apologize for the inconvenience
1First orderisFirstOrderOffer full refund with a discount code for their next order
2Default(none)Follow standard return policy: collect reason, process per normal rules

Offer a retention discount before cancelling

Instead of cancelling immediately, the AI agent can try to keep the customer by offering a discount or partial refund, and only cancel if they insist. The same ladder works for subscriptions, plans and contracts.

What you need:

  • Actions for applying a partial refund and cancelling the order/subscription
  • A workflow with instructions that walk through escalating offers

Workflow instructions:

  1. Ask the customer why they want to cancel
  2. Based on the reason, offer a 15% partial refund to keep the order: "I understand. What if we applied a 15% discount to this order?"
  3. If they decline, offer 30%: "I can go up to 30% off. Would that work?"
  4. If they still decline, confirm the cancellation and call cancelOrder
  5. After any accepted offer, call processPartialRefund with the agreed percentage

The AI agent follows the script naturally, so it feels like a conversation, not a hard sell. You control exactly how many offers to make and at what thresholds.

With condition providers: For more control, add a condition provider that checks order state before the retention flow starts. This lets you skip the offers for orders that are already shipped (where cancellation isn't possible) or route to different offer levels based on order value, payment method, or customer history. See time-based policies and per-customer policies.

With A/B testing: Not sure if 15%/30% is the right ladder? Use A/B testing to test different offer sequences and measure which retains more customers.

Involve people and other systems

Queue requests for your team in a Google Sheet

When your team completes a request by hand (a refund in a back office, a cancellation, an unsubscribe), the AI agent can collect everything they need and write it to a shared spreadsheet. The customer gets an immediate confirmation and your team gets a structured queue instead of chat transcripts to read.

If the system has no API but your team uses it in a browser, browser automation can complete the request end to end instead.

Action: recordRequest

Use this single action across several workflows. The requestType argument tells them apart:

  • Cancel order workflow -> calls recordRequest with requestType: "cancellation"
  • Refund request workflow -> calls recordRequest with requestType: "refund"
  • Email unsubscribe workflow -> calls recordRequest with requestType: "unsubscribe"

To give each request type its own tab of the same spreadsheet instead of one combined list, pass the tab name as a third argument:

    add_google_sheets_row("YOUR_SHEET_ID", { ... }, sheet_name=request_type)

Every tab keeps its own header row, so different request types can collect different columns.

The AI agent confirms to the customer that their request has been submitted and your team will process it. Your team works through the spreadsheet, updating the "Status" column as they go.

If the customer changes their mind before the request is processed, update the same row by matching both a stable request key and its current status:

def execute_action(context):
    order_id = context["args"]["orderId"]

    return update_google_sheets_row(
        "YOUR_SHEET_ID",
        {"Status": "Cancelled"},
        where={"Order ID": order_id, "Status": "Pending"},
    )

The helper changes exactly one row. It fails if no pending request matches or if duplicate rows match, so it cannot silently cancel an ambiguous request. See list_google_sheets_rows and update_google_sheets_row for pagination and large-sheet guidance.

Prerequisite: Share the Google Sheet (Editor access) with the Google service account shown on your Google Sheets integration page in the dashboard. The sheet needs a header row matching the column names in your data dict. See add_google_sheets_row for details.

Qualify a B2B quote request

For businesses that sell to other businesses, the AI agent can qualify leads and collect quote details before handing off to the sales team.

Workflow instructions:

  1. Confirm the customer is a business or professional buyer
  2. Collect: company name, contact person, email, phone number
  3. Ask which products they're interested in (product codes and quantities)
  4. Ask for their delivery postal code
  5. Summarize the request and confirm it's correct
  6. Call transferConversation to hand off to the commercial team

This is a pure instruction workflow with no custom actions. The AI agent structures the conversation so the sales team gets a complete, qualified request instead of a vague inquiry. To create the lead in your CRM as well, add a custom action that calls its API before the handoff.

Send customers to self-service

For order changes, address updates, plan changes or similar requests where you have a self-service portal, the AI agent can collect details and direct the customer there instead of escalating.

Workflow instructions:

  1. Acknowledge the customer's request
  2. Collect the order ID so you have context
  3. Explain that this type of change can be made through the self-service portal
  4. Share the direct link to the relevant page
  5. Only escalate to a human if the customer says the portal isn't working or they've already tried

This reduces support volume without frustrating the customer: they get a direct link to solve their problem, and the AI agent only escalates when self-service genuinely fails.

Get a decision from a supplier or warehouse

When someone outside Octocom has to decide, such as a supplier reviewing damage photos, the AI agent can send them a link and carry on with the customer once they answer. The link can go in Slack, a Google Sheets row, an email or any other system, and other systems can record the decision through the API with no page at all.

The AI agent registers a human decision request, the reviewer records the outcome on a portal page backed by an HTTP endpoint, and the AI agent reads the result and replies. See the external decisions playbook for the full setup.

Answer product and availability questions

These patterns fit businesses that sell products or run physical locations. When a product catalog is synced, the AI agent searches it on its own with searchProducts. These recipes add live data from your other systems.

Check stock in a store

Let customers ask whether a product is available in a specific location.

What you need:

  • An API action (or Python action) that checks your inventory system
  • A workflow that collects the product and store, then calls the action

API action: getProductStock

Configure the path as /stock/$productId and add storeId as a query parameter with the value $storeId, so both become arguments the AI agent fills in. This is a good fit for an API action: a single GET request with no logic needed.

Workflow instructions:

  1. Ask which product the customer is looking for
  2. Use searchProducts to identify the product and get its ID
  3. Ask which store they want to check
  4. Call getProductStock with the product ID and store ID
  5. Share the availability result

Summarize product reviews

Surface product reviews so the AI agent can help customers decide.

What you need:

  • A Python action that fetches reviews from your review system or feed
  • A workflow triggered when the customer asks about reviews

Action: getProductReviews

Workflow instructions:

  1. Identify which product the customer is asking about (use searchProducts if needed)
  2. Call getProductReviews with the product ID
  3. Summarize the reviews: mention the average rating and highlight 2-3 key themes
  4. Do not reveal reviewer names or emails
  5. If no reviews exist, let the customer know and offer to help with other product questions

Calculate shipping costs

Let customers get a shipping estimate before checkout.

What you need:

  • A Python action that calls your shipping API with the products and destination
  • A workflow that collects the necessary details

Action: getShippingCost

Workflow instructions:

  1. Ask which products the customer wants to ship (or use the products from their current conversation)
  2. Ask for their zip/postal code
  3. Call getShippingCost with the product list and zip code
  4. Present the cost and estimated delivery time

On this page