A/B testing
Split customers between two versions of a workflow and measure which one performs better.
A/B testing shows different versions of the AI agent's behavior to different customers, so you measure what works instead of guessing. Test whether a generous retention offer keeps more customers than a conservative one, or whether a casual tone earns better satisfaction scores than a formal one.
Each customer is assigned to a group once and stays in it for the whole conversation. The assignment is tagged on the conversation, so you can compare the groups in Metrics and in the help desk.
The quickest way to set one up is to ask Copilot or your own AI agent:
Set up an A/B test on the returns workflow: half of customers get a casual tone, half a formal one. Tag the groups so I can compare resolution rate and CSAT in two weeks.
Copilot writes and tests the setup for you. The technical details are in For developers and AI agents at the end of this page.
How it works
A/B tests combine two building blocks:
- A condition provider: a short piece of code that runs when a workflow is loaded. It assigns the customer to a group at random, remembers the choice for the conversation and tags the conversation with the group.
- Workflow variants: different instructions for the same workflow. Octocom picks the first variant whose required conditions are all true, so each customer gets the instructions for their group.
For example, to test whether a warm, casual tone leads to better outcomes than a formal one when handling returns, the "Return request" workflow gets two variants:
| Variant | Condition | Instructions |
|---|---|---|
| Casual | isCasual | Use a warm, conversational tone. Use first names. Say things like "No worries, let's get this sorted!" |
| Formal | isFormal | Use a professional tone. Address the customer formally. Say "We apologize for the inconvenience." |
Both variants follow the same steps (collect the order details, confirm the return) with different wording. Customers in each group are tagged ab:return-tone:casual or ab:return-tone:formal.
A split doesn't have to be even. To be cautious, you can show a new flow to only 20% of customers and keep everyone else on the current one. A test can also sit alongside checks on live data, for example testing two retention offers only for orders that have already shipped.
Measure the results
Once enough conversations have run, compare the two groups:
- In Metrics, add a Tags filter for
ab:return-tone:casual, note the numbers, then switch the filter toab:return-tone:formal. Compare resolution rate, handoffs and CSAT. The Workflow Usage chart on the AI performance tab can also be grouped by variant. - In the help desk, filter or build a view on each tag to read conversations from each group side by side.
Tips
- Start with equal weights. Skew the split only if you're worried about the new version's impact. You can change it later.
- Test one thing at a time. If you change the tone and the refund amount in the same test, you won't know which made the difference.
- Give it time. A test needs enough conversations to be meaningful. Don't draw conclusions from 20 conversations.
- Use descriptive test names.
"refund-strategy-v2"is better than"test1". The name appears in tags and metadata, so make it easy to find. - Test both versions before you start. Groups are assigned at random. To test a specific group, ask Copilot to start a test conversation with the conversation metadata
ab_test:your-test-nameset to that group's name (themetadataoption ofstart_conversation).get_ab_test_variantthen returns that group instead of picking one. - Clean up when you're done. Once you've picked a winner, keep the winning variant's instructions in the workflow and remove the condition provider.
For developers and AI agents
The code is short, and Copilot or your own agent through Octocom MCP can write and test it for you. The helper is documented in get_ab_test_variant.
A simple test: two response styles
The tone test from How it works, step by step.
Create a condition provider
def evaluate_conditions(context):
variant = get_ab_test_variant(context, "return-tone", ["casual", "formal"])
return {
"conditions": {
"isCasual": variant == "casual",
"isFormal": variant == "formal",
},
"data": {},
}That's the whole condition provider. get_ab_test_variant picks a group at random (50/50 by default), remembers it for this conversation, and tags the conversation with ab:return-tone:casual or ab:return-tone:formal.
Set up workflow variants
In the "Return request" workflow, create the two variants from How it works: Casual requires isCasual and Formal requires isFormal. Each customer gets the variant that matches their group.
Control the split with weights
By default, get_ab_test_variant splits traffic evenly. To be cautious, for example showing a new flow to only 20% of customers, give the groups weights:
def evaluate_conditions(context):
variant = get_ab_test_variant(
context,
"new-cancel-flow",
[
{"name": "control", "weight": 4}, # 80%
{"name": "new_flow", "weight": 1}, # 20%
],
)
return {
"conditions": {
"isNewFlow": variant == "new_flow",
},
"data": {},
}Weights are relative: 4 and 1 mean 80/20. 80 and 20 give the same result.
With two groups you only need one condition. The control variant is the default (last in the variant list, with no conditions), and the new flow's variant requires isNewFlow.
| Variant | Condition | Instructions |
|---|---|---|
| New flow | isNewFlow | The new cancellation flow |
| Control | (none) | The existing cancellation flow |
Combine an A/B test with real data
A condition provider can also check the state of another system, so one provider can handle both. For example: test two refund offers, but only for orders that haven't been refunded already.
import requests
def evaluate_conditions(context):
order_id = context["args"]["orderId"]
# Fetch order state from your system
response = requests.get(
"https://api.example.com/orders",
params={"id": order_id},
timeout=30,
)
if response.status_code != 200:
return {"conditions": {"orderNotFound": True}, "data": {}}
order = response.json()
# Determine A/B variant
variant = get_ab_test_variant(context, "refund-strategy", ["standard", "generous"])
return {
"conditions": {
"orderNotFound": False,
"isRefunded": order.get("refundedAt") is not None,
"isShipped": order.get("shippedAt") is not None,
"isGenerous": variant == "generous",
},
"data": {
"orderTotal": order.get("total"),
},
}The workflow variants handle both the state checks and the split:
| # | Variant | Conditions | Instructions |
|---|---|---|---|
| 0 | Not found | orderNotFound | Ask customer to double-check order ID |
| 1 | Already refunded | isRefunded | Inform customer, no further action |
| 2 | Generous offer | isShipped, isGenerous | Offer 30% partial refund to keep the order |
| 3 | Standard offer | isShipped | Offer 15% partial refund to keep the order |
| 4 | Default | (none) | Process cancellation normally |
The state checks (not found, already refunded) come first, so they always take priority. The split only matters in the "shipped" case, where you're testing two retention offers.
What get_ab_test_variant records
The first time get_ab_test_variant runs for a test in a conversation, it:
- Picks a group at random, using the weights
- Saves the choice as conversation metadata (
ab_test:your-test-name) - Tags the conversation with
ab:your-test-name:variant-name - Adds an event to the conversation timeline
Later calls with the same test name in the same conversation return the saved group, so the customer always sees the same version.