> ## 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.

# Sentry integration

> Connect Voiceflow to Sentry, trace custom Chat requests, investigate application failures and configure operational alerts.

## Overview

Voiceflow integrates with Sentry through instrumentation in the backend behind your custom Chat interface. Track request failures and latency, group application issues, and give the developer investigating a failure an opaque conversation ID.

- **[Connect Sentry](#connecting-sentry)** to your backend’s project.
- **[Trace Chat requests](#tracing-chat-requests)** without changing session ownership.
- **[Investigate failures](#investigating-failures)** with the correct customer evidence.
- **[Configure alerts](#alerts-and-maintenance)** and maintain the exporter.

| Signal | What it establishes |
| --- | --- |
| Request transaction | Duration and HTTP status at your backend’s Chat request boundary. |
| Explicit error issue | A failed HTTP request or a transport/response-decoding failure. |
| Opaque conversation ID | A correlation value for approved evidence held in your application. |

**Note:** 
This recipe belongs in **your custom Chat backend**. It does not install an error tracker inside Voiceflow’s hosted widget or phone channel, and does not expose internal model/tool spans, prompts, tokens or costs. A successful HTTP request also does not prove the customer’s problem was resolved. Use the [shared CX guides](/docs/guides/integrations/monitoring#guides) for those additional measurements.

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

## Connecting Sentry

Configure the backend SDK and verify the intended project.

You need a Sentry Python project and a developer who can change and deploy the backend behind your custom Chat interface. Keep the runtime session key and Sentry configuration on that server. A Studio builder coordinates the test and reviews results; request instrumentation runs in application code.

#### Studio

### 1. Prepare the Sentry project

Create or select the Sentry project for the Python backend that calls Voiceflow. Obtain its **DSN** from project settings, and agree on staging/production and release labels. The DSN routes SDK events; an organization management token is not required for this example.

### 2. Assign backend instrumentation

Ask the developer owning your Chat backend to use the [Sentry starter](/docs/examples/monitoring/sentry-starter.zip). Provide the intended project, DSN and sandbox conversation. Ask for a link to the informational connection check and a real request transaction. The developer stores configuration on the server.

### 3. Verify the destination

Have the developer run the starter’s connection check. In the selected Sentry project, find **Voiceflow connection check** in Issues with the staging environment. Then complete the [request test](#tracing-chat-requests); an informational test message does not prove Chat instrumentation.

#### Code

### 1. Install the pinned SDK

Extract the [Sentry starter](/docs/examples/monitoring/sentry-starter.zip). In `sentry`, use Python 3.11+ and run `python -m pip install -r requirements.txt`. The example pins SDK **2.75.0** and uses its [2.x transaction API](https://docs.sentry.io/platforms/python/tracing/instrumentation/custom-instrumentation/); do not mix it with a different major version’s span API.

### 2. Set backend configuration

Set these values in the host’s secret/config store or a local untracked environment file:

```bash
SENTRY_DSN='YOUR_PROJECT_DSN'
VF_ENV='staging'
VF_RELEASE='support-backend@review-1'
```

The project’s [Python setup](https://docs.sentry.io/platforms/python/) supplies the DSN. `initialize()` disables automatic integrations, breadcrumbs and stack-frame variables, and uses explicit sanitized messages/transactions. It samples every request transaction for sandbox verification; choose a deliberate production policy before scaling.

### 3. Send the informational check

Run `python voiceflow_sentry.py`. It sends **Voiceflow connection check** and flushes the SDK. Inspect diagnostics and confirm the event in the correct project and environment. The event must be visible before moving to the real Chat test.

### The check is missing

Verify the DSN, project and SDK delivery.

Check the full DSN against the selected project, environment filters and time range. Inspect SDK transport diagnostics and account rate limits. A flush completing does not by itself establish remote acceptance. Do not test with customer content or force an error in a production conversation.

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

## Tracing Chat requests

Track request latency and failures at the application boundary.

A `voiceflow.chat.turn` transaction covers the outbound `/v4/interact` request and JSON response read. A non-2xx response produces a sanitized error message; network/decoding failures produce a separate sanitized message. The actual status/body or raised error stays available to the application.

#### Studio

### 1. Exercise a real conversation

Ask a sandbox question through the custom Chat interface. Send a follow-up in the same conversation and check that the app responds normally. Ask the developer to find the matching request transactions in Sentry.

### 2. Verify failure behavior

Have the developer simulate one failed request in staging, then make telemetry delivery unavailable. Confirm the customer’s normal response/error behavior remains intact, and that telemetry failure does not repeat an action.

#### Code

### 1. Keep session setup intact

Your backend [creates the current Chat session](/docs/api-reference/v4interact/start-session-specific-environment), keeps the returned `sessionKey`, launches once and authorizes follow-up actions. Maintain a separate random application conversation ID; never export the session key as an identifier.

### 2. Instrument the existing handler

Initialize Sentry once per process, then call the synchronous wrapper from the handler that already owns the request:

```python
from voiceflow_sentry import initialize, chat_turn
initialize()  # Once at startup, after loading server configuration.

# In your authenticated synchronous request handler:
status, body = chat_turn(session_key, action, conversation_id)
# Preserve the original status/body in your existing response handler.
```

The wrapper isolates request context, attaches the opaque ID under the `voiceflow` context and returns `(status, body)`. It does not export question text, answers, credentials or exception messages. An async server should instrument its existing async client rather than call this blocking wrapper on the event loop.

### 3. Prove success, failure and isolation

Run `python -m unittest -v test_sentry.py`, then test an authorized real request and a controlled staging failure. Inspect the request transaction’s HTTP status and the corresponding issue. Confirm that one conversation’s context does not appear on another, and preserve recovery without automatically replaying the Voiceflow action.

### Transactions are missing but issues arrive

Check tracing independently from error collection.

Error issues and sampled performance transactions are separate signals. Check the trace sampling policy, project filters and backend SDK initialization. The example uses SDK 2.x `start_transaction`; newer API examples must match the version installed in your application.

<a id="investigating-failures"></a>

## Investigating failures

Relate an issue to the actual customer experience.

### Find the request and its evidence

### 1. Open the relevant issue

Filter Issues to the backend’s project, environment and release. Open **Voiceflow Chat HTTP failure** or **Voiceflow Chat transport or decode failure**, then inspect the `voiceflow.conversation_id` context and linked trace where available. The message intentionally contains no runtime error text.

### 2. Check the affected boundary

Inspect the request transaction’s `http.response.status_code` when a response arrived. For a transport/decoding failure, use the backend’s access-controlled diagnostics to investigate the actual failure. Do not assume an error means Voiceflow never processed the action; ambiguous network failures must not trigger an automatic replay.

### 3. Confirm the customer outcome

Use the application’s opaque ID mapping to retrieve approved conversation evidence. Check whether the customer received an answer, a business operation completed, or the conversation escalated. A transport issue and an unresolved customer task are different measurements.

| Observed result | Next check |
| --- | --- |
| Non-2xx runtime response | Session validity, request schema and server-owned runtime diagnostics. |
| Transport/decode failure | Backend network/read failure and possible ambiguous completion. |
| HTTP success, incorrect answer | Conversation evidence and [answer-quality review](/docs/guides/integrations/monitoring/monitor-answer-quality). |
| Successful request, failed business result | Tool/backend business status and [cross-system correlation](/docs/guides/integrations/monitoring/investigate-cross-system-failures). |

The starter uses [explicit sanitized capture](https://docs.sentry.io/platforms/python/usage/), rather than capturing arbitrary exception objects. If you add automatic framework integrations, review their captured request bodies, headers, breadcrumbs and stack variables before broadening collection.

### Many failed requests appear as one issue

Use issue grouping for diagnosis rather than a CX denominator.

Repeated sanitized messages can group together. Use individual event/transaction details and your request population to assess frequency. Issue count is not failed-request count, and neither is a resolution rate. Keep [CX outcome records](/docs/guides/integrations/monitoring/track-resolution-and-escalation) separately scoped.

<a id="alerts-and-maintenance"></a>

## Alerts and maintenance

Verify notifications and keep instrumentation reliable.

### 1. Configure the first alert

In Sentry’s [Alerts](https://docs.sentry.io/product/alerts/), create a rule for the backend project and staging environment. Choose the request-failure issue or a supported transaction/error signal, an evaluation window, a threshold and the team’s notification destination, then save it. Trigger a controlled staging failure and confirm the alert reaches its owner. Test its healthy/recovery behavior as supported by that rule type.

Alert on a sustained customer-impacting condition rather than every connection-check message. Keep ingestion/export health visible separately: no customer requests is not proof that monitoring is broken. Use [Monitor latency and errors](/docs/guides/integrations/monitoring/monitor-latency-and-errors) and [Alert on CX regressions](/docs/guides/integrations/monitoring/alert-on-cx-regressions) for population and threshold choices.

### 2. Maintain the SDK

Keep SDK initialization once per process, version it with the backend, and set a release label that identifies the deployed backend. An agent release may change independently; do not assume the backend release identifies it. Choose a production trace sampling policy and account for that sampling in comparisons.

Short-lived workers must allow the SDK to flush before exit. Avoid awaiting a flush after every customer request. Monitor dropped events, rate limits and transport health. If you rotate the project’s ingest configuration, update the backend and repeat the informational check plus a real staging turn before retiring the old configuration.

### Disable Sentry export

Preserve the runtime request and other application telemetry.

Remove this wrapper and its Sentry initialization while retaining the original Voiceflow call, session mapping and error handling. If the application uses Sentry for other services, remove only this instrumentation. Remove unused server configuration; previously collected events remain subject to Sentry retention.
