> ## Documentation Index
> Fetch the complete documentation index at: https://www.voiceflow.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Opik integration

> Connect Voiceflow to Opik, trace requests from your custom Chat backend and review CX performance with explicit evidence.

## Overview

Voiceflow integrates with Opik through request instrumentation in the backend behind your custom Chat interface. Your developer exports an OpenTelemetry span around each non-streaming Chat action; your CX team uses those traces to investigate the customer experience.

- **[Connect Opik](#connecting-opik)** to the intended project or workspace.
- **[Trace Chat requests](#tracing-chat-requests)** while preserving application behavior.
- **[Review CX performance](#reviewing-cx-performance)** against actual conversation evidence.
- **[Maintain export](#maintaining-export)** through releases and credential changes.

| Collected by the starter | Supplied separately by your team |
| --- | --- |
| Request duration and HTTP status | End-to-end customer outcome and business success. |
| Opaque application conversation ID | Approved conversation evidence and any review labels. |
| Outer request/chain span | Internal model/tool instrumentation, tokens and costs, if you have a separate verified source. |

**Note:** 
This guide instruments **your custom Chat backend**. Voiceflow’s widget and phone channels do not expose their internal requests through this wrapper. Use [Transcripts](/docs/documentation/measure/transcripts), [Evaluations](/docs/documentation/measure/evaluations) and [lifecycle webhooks](/docs/api-reference/webhooks/session-lifecycle) for those channels’ evidence. Connecting an observability platform does not automatically export prompts, answers, model spans or quality scores.

<a id="connecting-opik"></a>

## Connecting Opik

Authorize the destination and prove the exporter reaches it.

### Before you begin

You need an Opik workspace and project, an API key permitted to write there, and the cloud or protected deployment’s HTTP OTLP endpoint. You also need a developer who can change and deploy the server behind your custom Chat interface. Studio builders can coordinate setup and review; the request instrumentation itself runs on that server.

#### Studio

### 1. Prepare the destination

Create or select the intended Opik project and obtain a workspace API key. Supply the exact workspace and project names to `OPIK_WORKSPACE` and `OPIK_PROJECT_NAME`. The example file targets Opik Cloud; replace the URL for an authorized enterprise or self-hosted deployment.

### 2. Assign the exporter setup

Ask the developer who owns your custom Chat backend to use the [tracing starter](/docs/examples/monitoring/otel-starter.zip) with its `opik.env.example` configuration. Supply the destination identifiers, environment label and an approved sandbox conversation. Keep credentials in the backend’s secret store. Ask for a connection-check result and a link to the resulting trace.

### 3. Confirm the destination

Open the configured workspace/project and find `voiceflow.connection.check` in the trace list.

Check that the destination belongs to the intended organization and staging environment before the developer enables broader traffic.

#### Code

### 1. Provision the destination

Create or select the intended Opik project and obtain a workspace API key. Supply the exact workspace and project names to `OPIK_WORKSPACE` and `OPIK_PROJECT_NAME`. The example file targets Opik Cloud; replace the URL for an authorized enterprise or self-hosted deployment.

Project attribution applies to every span, not only the root of a future multi-span trace. Keep the resource’s `opik.project_name` aligned with `projectName`; do not use process-global OTel environment overrides to route unrelated exporters.

### 2. Configure the explicit HTTP exporter

Extract the [tracing starter](/docs/examples/monitoring/otel-starter.zip). In `otel`, create a Python 3.11+ environment and install `python -m pip install -r requirements.txt`. The example pins OpenTelemetry SDK and HTTP exporter `1.45.2`.

Copy `opik.env.example` to an untracked `provider.env` file, replace its placeholders and load it into your backend environment:

```bash title="Server-side exporter configuration"
VF_ENV='staging'
OPIK_OTLP_URL='https://www.comet.com/opik/api/v1/private/otel/v1/traces'
OPIK_API_KEY='YOUR_OPIK_API_KEY'
OPIK_WORKSPACE='YOUR_WORKSPACE'
OPIK_PROJECT_NAME='voiceflow-support'
```

Use `set -a; . ./provider.env; set +a` for a local POSIX shell, or the host’s secret/config store for deployment. [Opik’s OpenTelemetry intake](https://www.comet.com/docs/opik/integrations/opentelemetry) uses HTTP and a raw API key in `Authorization`, **without `Bearer`**. Supply `Comet-Workspace` and `projectName`. The starter also sets `opik.project_name` on the resource so later spans retain their destination.

### 3. Send a connection check

Run `python voiceflow_monitoring.py opik --send-smoke`. This deliberately sends one metadata-only `voiceflow.connection.check` span; it makes no Voiceflow call. Read exporter diagnostics and confirm the resulting record:

Open the configured workspace/project and find `voiceflow.connection.check` in the trace list.

An exporter flush finishing is not proof of remote acceptance. Continue only after the correct destination displays the span.

### The expected trace is missing

Check intake, authentication and destination routing.

A gRPC exporter will not match this HTTP intake. Check the raw Authorization value, workspace and project name. Spans routed only by root attributes can split across projects; retain project attribution on the resource. Check exporter diagnostics, the selected time range and the intended project. Retrying trace delivery must not repeat a Voiceflow customer action.

<a id="tracing-chat-requests"></a>

## Tracing Chat requests

Measure non-streaming requests in the backend you own.

The span covers your server’s outbound `/v4/interact` request and JSON response read. It excludes browser rendering and streaming Voice, and is not an internal LLM call. Non-2xx responses mark an error and preserve the original response. Network/decoding errors propagate through your existing recovery path without exporting their messages.

#### Studio

### 1. Run a real Chat turn

Ask a sandbox question through the custom interface your developer instrumented. Confirm the customer sees its normal response. Use a follow-up in the same application conversation so you can check correlation across turns.

### 2. Review healthy and failed requests

Then inspect a real `voiceflow.chat.turn` and its duration, HTTP result and application conversation ID.

Have your developer test a controlled failure and an unavailable telemetry destination. Confirm export problems do not replace the customer’s real response or trigger a repeated action.

#### Code

### 1. Retain session ownership

Your backend [creates a session](/docs/api-reference/v4interact/start-session-specific-environment), stores the returned `sessionKey`, launches once and reuses that session for authorized follow-ups. Generate a separate random application conversation ID and keep its session mapping server-side. Neither the key nor a customer contact detail belongs in telemetry.

### 2. Instrument the existing call

```python title="Existing synchronous Chat handler"
from voiceflow_monitoring import Monitor

# Create once at process startup, after loading server configuration.
monitor = Monitor("opik")

# Values come from authenticated server-side conversation state.
status, body = monitor.chat_turn(session_key, action, conversation_id)
# Return the original status/body through your existing response handler.

# During graceful process shutdown:
# monitor.close()
```

Use this synchronous wrapper in a sync handler/worker. For an async framework, place the same span around your existing async HTTP client rather than blocking the event loop. Keep your customer authorization and response handling intact.

### 3. Test error and delivery behavior

Run the included `python -m unittest -v test_monitoring.py`, then test an authorized sandbox success and failure through the real backend. The wrapper uses an isolated provider and a background batch processor, so it does not replace the process-global OTel provider. Monitor exporter failures; a short-lived host must await export before it terminates.

`vf.conversation.id` is the opaque application correlation attribute. Use it to relate requests to the evidence your team reviews rather than treating trace count as resolved-conversation count.

### The trace has no prompts or model costs

Check what your instrumentation actually observes.

That is expected for this recipe: only request metadata is exported. Do not label the span as an LLM call or estimate token usage from HTTP duration. To review answers, deliberately obtain and redact the needed conversation evidence; instrument only tools or model calls your application actually owns.

<a id="reviewing-cx-performance"></a>

## Reviewing CX performance

Connect request health to actual customer evidence.

### Inspect a request

In the project’s trace view, inspect a request’s attributes and error state. Opik can [record feedback on traces](https://www.comet.com/docs/opik/tracing/annotate_traces), but that requires an explicit feedback workflow and a trace mapping; the request wrapper does not invent a customer rating.

| Question | Evidence to inspect |
| --- | --- |
| Was the request slow? | Outer-span duration, deployment environment and HTTP result. |
| Did an API failure occur? | Non-2xx status or `vf.failure.kind=transport_or_decode`. |
| Did the customer get a correct answer? | Approved conversation and a defined review rubric. |
| Was the customer’s task resolved? | Terminal business evidence or the CX outcome record. |

### Run a small CX review

### 1. Select comparable conversations

Choose a release, environment, intent and fixed time window. Start with a small support scenario such as a returns-policy question and a follow-up. Include failed and healthy requests; trace sampling is not a representative customer population by itself.

### 2. Check the actual answer

Use the opaque conversation mapping to find approved evidence in your app or Voiceflow’s Transcripts. Compare the answer with the source policy and any tool result. Record pass, fail or not assessed against the same rubric. The metadata-only trace cannot supply missing conversation content to a reviewer or judge.

### 3. Record and compare findings

Keep the trace ID with the outcome, rubric version and review window in your team’s review record. If you add platform scores or automated evaluation later, configure their evidence and mapping explicitly; an available evaluation API does not create scores for this integration. Compare the same population before and after an agent change.

Use [Monitor answer quality](/docs/guides/integrations/monitoring/monitor-answer-quality), [Capture customer feedback](/docs/guides/integrations/monitoring/capture-customer-feedback) and [Track resolution and escalation](/docs/guides/integrations/monitoring/track-resolution-and-escalation) for measurement definitions and denominator rules. Their Datadog worked queries need mapping to Opik; they are not automatic exports into this destination.

### All requests succeed but CX gets worse

Separate transport health from customer outcomes.

An HTTP success can contain an unhelpful answer, a failed business result or an escalation. Pair request health with independently measured resolution, answer-quality and feedback records. Report unknown/not-assessed coverage rather than treating it as success.

<a id="maintaining-export"></a>

## Maintaining export

Keep telemetry reliable through releases and credential changes.

Telemetry can be delayed or lost. A quiet dashboard alone does not distinguish low traffic from a delivery failure.

#### Studio

### 1. Assign the maintenance owners

Ask the developer who owns your Chat backend to monitor export health, and the Opik administrator to own destination access and retention. Confirm who investigates missing traces and where your team reports a problem.

### 2. Verify delivery after changes

After a deployment change, run an approved staging conversation through your interface. Ask the developer for its matching `voiceflow.chat.turn` link. Check the intended project and environment, request status and conversation mapping. A connection check alone does not prove that real Chat turns are being recorded.

### 3. Coordinate credential changes

Have the provider administrator and backend developer rotate the destination credential together. Obtain a successful connection check and a real staging-turn trace from the updated backend before the administrator retires the old credential. Review who can access the collected data and how long it is retained.

### Disable this destination

Coordinate removal and verify the customer experience.

Ask the developer to stop exporting to Opik while preserving the original Voiceflow request and session handling. Verify a staging conversation still works, then have the administrator revoke unused destination access. Existing records remain subject to the destination’s retention policy.

#### Code

### 1. Operate the exporter

Keep one `Monitor` per backend process and call `monitor.close()` on graceful shutdown. Batching avoids an intake request on every customer response, but it is not a durable queue. Monitor exporter errors, rate limits and shutdown loss. Add a reliable background/export pipeline if your workload needs delivery guarantees.

Each connection check and Chat turn starts an independent root span. The provider explicitly uses `ALWAYS_ON`, so an existing parent span or `OTEL_TRACES_SAMPLER` setting cannot suppress it. This records every wrapped request; delivery failures can still lose records. If you change sampling, account for the resulting population in comparisons.

Review destination access and retention. Keep opaque IDs out of high-cardinality metric grouping and never attach credentials or unreviewed conversation text as attributes.

### 2. Rotate and verify

Rotate the destination credential in the host secret store, restart or redeploy the exporter, then repeat the connection check and one real staging turn. Retire the old credential after confirming the new one reaches the intended destination. Project attribution applies to every span, not only the root of a future multi-span trace. Keep the resource’s `opik.project_name` aligned with `projectName`; do not use process-global OTel environment overrides to route unrelated exporters.

### Disable this destination

Remove export without changing the customer conversation.

Remove the Opik exporter or wrapper from the backend while retaining its original Voiceflow request, session mapping and error handling. Revoke the unused destination key and remove server secrets. Existing data remains subject to the destination’s retention policy. Do not delete a shared project or change unrelated OTel exporters as part of disconnecting this recipe.

<a id="disable-this-destination" />

Cross-system investigations also need a mapping to your application’s tool results. These request traces do not expose tools running inside Voiceflow. Follow [Investigate cross-system failures](/docs/guides/integrations/monitoring/investigate-cross-system-failures) for the correlation rules.
