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

# Datadog integration

> Connect Voiceflow to Datadog to track conversations and voice calls, trace your custom Chat backend, and configure operational alerts.

## Overview

Voiceflow integrates with Datadog so you can track customer conversations alongside the rest of your application. Send conversation and call events to Datadog Logs, correlate them with Voiceflow transcripts, and trace requests from your own Chat backend.

- **[Connect Datadog](#connecting-datadog)** through a small receiver your team hosts.
- **[Track conversations and calls](#tracking-conversations)** across your deployed channels.
- **[Trace Chat requests](#tracing-chat-requests)** from a custom interface.
- **[Create dashboards and alerts](#dashboards-and-alerts)** for the signals you collect.

| What you want to monitor | Connection | Data available |
| --- | --- | --- |
| Conversations across channels | Voiceflow project webhooks → your receiver → Datadog Logs | Start/end events, conversation IDs and elapsed time. |
| Voice calls | The same receiver, with call events selected | Call timing, provider and related conversation IDs when available. |
| Requests from your own Chat interface | Instrument your server's Chat API calls | Request duration, HTTP status and an application conversation ID. |

**Note:** 
**Monitoring model behavior?** These recipes collect lifecycle events and application request traces. Internal prompts, model/tool spans, token usage, cost and evaluations are not included. Use Voiceflow's [Transcripts](/docs/documentation/measure/transcripts) and [Evaluations](/docs/documentation/measure/evaluations) to investigate conversation content and quality.

To add CX measurement beyond lifecycle logs, follow [Track resolution and escalation](/docs/guides/integrations/monitoring/track-resolution-and-escalation) and the other [shared monitoring guides](/docs/guides/integrations/monitoring#guides). They explain the additional evidence and export mapping your team supplies.

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

## Connecting Datadog

Prepare the receiving service and authorize Datadog intake.

### Before you begin

You need a Voiceflow project, a Datadog organization with Log Management, and a developer who can deploy an HTTPS webhook receiver. For request tracing, also enable [Datadog Agent Observability](https://docs.datadoghq.com/llm_observability/quickstart/) and have access to the server behind your custom Chat interface.

| Resource | Who supplies it | Where it belongs |
| --- | --- | --- |
| Datadog API key and site | Your Datadog administrator, from [Organization Settings → API Keys](https://docs.datadoghq.com/account_management/api-app-keys/) | The receiver's server secrets. An application key is not needed for these intake requests. |
| Project ID | Your Voiceflow project owner | The receiver's project check, `VF_PROJECT_ID`. |
| HTTPS receiver URL | Your application developer | Voiceflow's project webhook settings. |
| Webhook secret | Voiceflow's settings for that endpoint | The receiver's `VF_WEBHOOK_SECRET`. It verifies incoming deliveries. |

Use the Datadog site your organization belongs to, such as `datadoghq.com` or `datadoghq.eu`. The starter selects that site's intake automatically. Keep both secrets on the server.

#### Studio

### 1. Ask your developer to prepare the receiver

Give your developer the [Datadog starter](/docs/examples/monitoring/datadog-starter.zip) and this project's ID. Ask them to deploy its `/voiceflow/events` route behind HTTPS, configure the Datadog key/site, and return the exact endpoint URL. They will add the webhook secret after you save the endpoint.

If this project already has a webhook receiver, have the developer add Datadog forwarding there. Replacing its URL can interrupt another workflow.

### 2. Set the project webhook URL

Open the project in [Agent studio](https://creator.voiceflow.com), then **Settings → Webhooks**. Under **Session lifecycle webhook**, enter the developer's URL in **Webhook url**, then click outside the field and wait for **Saved**.

Voiceflow project webhook settings with the endpoint URL highlighted — Replace the example URL with your receiver's HTTPS endpoint.

### 3. Select events and finish verification setup

Choose **Listen for specific events**, then **Session started** and **Session ended**. Add **Call started** and **Call ended** for voice. Wait for **Saved**. If your workspace shows no event selector, the receiver still filters incoming deliveries to these four events.

Copy **Webhook secret** to the developer through your team's secret-sharing process. Ask them to confirm signature verification is active and a signed test delivery reaches Datadog. A saved URL alone does not complete the connection.

#### Code

### 1. Install the receiver

Download and extract the [Datadog starter](/docs/examples/monitoring/datadog-starter.zip). From its `datadog` directory, use Node.js 22 or later:

```bash
npm ci
npm test
```

The archive includes the receiver, Datadog client, Chat instrumentation and fixture tests. Tests do not send data to either service.

### 2. Configure server secrets and HTTPS

Set `DD_SITE`, `DD_API_KEY` and `VF_PROJECT_ID` in your host's secret manager. Set `DD_SERVICE=voiceflow-agent` and `DD_ENV=staging` for the first test. These label the exported service; `DD_ENV` does not select a Voiceflow Environment.

The receiver listens on loopback port `3000` by default. Expose `/voiceflow/events` through your HTTPS proxy, preserve the raw body and `svix-*` headers, and apply ingress rate limits. Its body limit is 64 KiB. Do not point Voiceflow directly at Datadog's intake: the receiver verifies signatures and translates the event.

### 3. Register the project endpoint

Open your project at [creator.voiceflow.com](https://creator.voiceflow.com), then **Settings → Webhooks → Session lifecycle webhook**. Enter the receiver's HTTPS URL in **Webhook url** and wait for **Saved**. With **Listen for specific events**, select **Session started**, **Session ended**, and the two call events if needed. Wait for the event selection's **Saved** confirmation too.

Voiceflow project Webhooks settings and the endpoint URL — Register the project receiver before testing signed delivery.

Copy **Webhook secret** from this endpoint into `VF_WEBHOOK_SECRET`, then start the receiver with `npm start`. If another integration already owns this project's URL, extend its receiver instead of replacing it. Complete the [conversation test](#tracking-conversations) before release.

### Datadog receives no logs

Check each boundary from Voiceflow delivery to indexing.

Check the receiver's HTTPS route, selected events and signature verification. A `401` from the starter means the raw body, signing headers or endpoint secret did not verify. A `503` means forwarding failed: inspect the Datadog site/key and intake health.

Datadog returns `202` when it accepts a log for processing. If the receiver succeeds but search is empty, check the search time range, selected organization, pipelines and index exclusions. The [Live Tail](https://docs.datadoghq.com/logs/live_tail/) can help separate ingestion from indexing.

<a id="tracking-conversations"></a>

## Tracking conversations and calls

Find a conversation's lifecycle and compare elapsed times.

The starter exports metadata without copying message text, phone numbers or customer IDs. It preserves `session_id` and `transcript_id` when supplied, so your team can find the matching Voiceflow conversation. Treat these IDs as sensitive operational data and apply your retention and access policy.

| Event | Meaning | Timing to use |
| --- | --- | --- |
| `runtime.session.start` | A new conversation session starts. | `start_time_ms`. |
| `runtime.session.end` | The session ends or expires. | `duration_ms` is its lifetime, including idle time. |
| `runtime.call.start` | A voice connection starts. | `start_time_ms`; conversation IDs can be absent on a reused session. |
| `runtime.call.end` | That voice connection ends. | `duration_ms` is the call's elapsed time. |

Closing the widget does not immediately end its session. Calls and sessions are not one-to-one; use **call** events for call duration. Neither duration measures response latency. See the [lifecycle reference](/docs/api-reference/webhooks/session-lifecycle#call-events) for exact event behavior.

#### Studio

### 1. Run a real channel conversation

Use your published widget or another deployed channel. Ask a sandbox support question, then follow a path that ends the conversation or let its idle timeout expire. For voice, make a short test call and hang up.

### 2. Find the same conversation in Datadog

In **Logs → Explorer**, search `service:voiceflow-agent env:staging`. Inspect a start and end event for the same `session_id`, then find the matching record in Voiceflow's [Transcripts](/docs/documentation/measure/transcripts). For voice, check the call's timing separately.

Ask your developer to confirm delivery if an event is missing, and to test an invalid signature. It must be rejected without creating a log.

#### Code

### 1. Exercise the actual session lifecycle

Start a conversation through the widget, voice connection, or current [Chat session API](/docs/api-reference/v4interact/start-session-specific-environment). Launch once and send a sandbox question. Do not use the legacy Interact endpoints for this check; they do not create the sessions these events describe.

### 2. Inspect the exported record

Search `service:voiceflow-agent env:staging` in Datadog Logs. The receiver translates a signed session-end delivery into this shape; values below are illustrative:

```json
{
  "message": "runtime.session.end",
  "service": "voiceflow-agent",
  "ddsource": "voiceflow",
  "ddtags": "env:staging",
  "event_type": "runtime.session.end",
  "event_id": "YOUR_SVIX_MESSAGE_ID",
  "project_id": "YOUR_PROJECT_ID",
  "session_id": "YOUR_SESSION_ID",
  "duration_ms": 42000
}
```

Confirm the original `event_time_ms`, available Environment fields and conversation IDs. `version_id` comes from the event's `environmentID`; the named Voiceflow Environment is `environment_id`/`environment_alias` when present. Missing optional fields stay absent.

### 3. Check delivery failure and recovery

In a sandbox, reject a signed request after changing its body; expect `401` and no log. Make Datadog forwarding fail; expect `503`, then restore it and replay the delivery through your webhook delivery tooling. Confirm the same `event_id` reaches Datadog. A retry can create a duplicate if the earlier intake succeeded before its acknowledgment was lost.

### Counts or timestamps look wrong

Account for retries, idle sessions and delayed delivery.

For event counts, use the **unique count** of `@event_id`, rather than raw log count. A call can reuse an existing conversation session, and optional session IDs can be absent; do not invent a join key when none was delivered.

Datadog dates these logs by receipt time. The original `event_time_ms` remains available for investigation, so delayed delivery does not silently look like a new customer conversation. Use native [Analytics](/docs/documentation/measure/analytics) for Voiceflow's product-level reporting.

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

## Tracing Chat requests

Measure the request boundary in your own Chat backend.

Use this path when your team owns a custom Chat interface. The [starter](/docs/examples/monitoring/datadog-starter.zip) wraps non-streaming `/v4/interact` calls and submits a `workflow` span to [Datadog Agent Observability](https://docs.datadoghq.com/llm_observability/instrument/api/). Each turn is a root span; an opaque application conversation ID groups its turns into a Datadog session.

The duration covers your server's outbound request and JSON response read. It excludes browser rendering and Voice streaming, and does not reveal internal model or tool spans. HTTP success also does not prove that the customer's task succeeded.

#### Studio

### 1. Confirm which interface you deploy

If you use Voiceflow's widget or a phone channel, continue with [lifecycle logs](#tracking-conversations). This instrumentation belongs in a backend your team controls; there is no tracing switch to turn on in the widget.

### 2. Give your developer the tracing task

Ask the developer maintaining your custom Chat backend to use `observeChatTurn` and `sendSpans` from the starter. Give them your Datadog service/site labels and an approved test conversation. They should retain the existing session and customer access checks, and use an opaque conversation ID rather than a credential or customer contact detail.

### 3. Review the result together

Ask a sandbox question through that interface. In Datadog Agent Observability, find `voiceflow.chat.turn` under `voiceflow-agent`; check its session grouping and duration. Have the developer test a failed request too. Confirm the customer still receives the application's normal response or error when Datadog is unavailable.

#### Code

### 1. Keep your existing Chat session setup

Your backend [creates the session](/docs/api-reference/v4interact/start-session-specific-environment), keeps its returned `sessionKey` in server-side conversation state and authorizes the customer's access. Launch once; reuse that key for later actions. Create a separate random application conversation ID for telemetry and retain that mapping on your server. Do not export the session key.

### 2. Wrap the non-streaming action

Import the starter into the backend that already sends Chat actions:

```js title="Instrument the existing Chat handler"
import { createDatadog, observeChatTurn } from './datadog.mjs';

const dd = createDatadog({
  site: process.env.DD_SITE, apiKey: process.env.DD_API_KEY,
  service: 'voiceflow-agent', env: 'staging',
});

// These values come from your authenticated server-side conversation state.
const result = await observeChatTurn({ sessionKey, conversationID, action });
try {
  await dd.sendSpans([result.span]);
} catch {
  // Record a telemetry health signal; preserve the actual Chat result.
  console.error('Datadog trace delivery failed');
}
// Return result.status and result.body through your existing response handler.
```

For a network/JSON-read failure, `observeChatTurn` throws an error with `error.span`. Attempt to submit that span in your handler's error path, then preserve the application's existing recovery behavior. Do not automatically repeat the customer action after an ambiguous failure.

### 3. Verify success and failure before release

Send `launch`, then a `text` action using the same session. Find their `voiceflow.chat.turn` spans in Datadog and check that `session_id` matches your opaque application ID. A `202` intake response acknowledges submission; inspect the resulting trace too.

Test a non-2xx runtime response, a network failure and unavailable Datadog intake. Preserve the real HTTP status/body for the client and omit prompts, answers and credentials from telemetry. The included fixture tests exercise these boundaries locally.

### Trace delivery slows the response

Move telemetry off the customer path with a reliable background task.

The short example awaits intake, adding up to the client's five-second telemetry timeout. In your application, hand the span to a durable queue or your host's awaited background-task facility, then respond to the customer. A detached promise may be terminated when a serverless request ends.

Monitor that queue or task separately. Retrying telemetry must not replay the Voiceflow action. Check [Datadog's site availability and span intake rules](https://docs.datadoghq.com/llm_observability/instrument/api/) before sending delayed spans; the API accepts timestamps no more than 24 hours old.

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

## Creating dashboards and alerts

Turn collected signals into useful operational checks.

Start with the questions your support team needs to answer. Keep conversation lifetime, call duration and Chat request latency separate.

| Question | Data to use | Suggested view |
| --- | --- | --- |
| How many conversations ended? | `@event_type:runtime.session.end` | Unique count of `@event_id` over time. |
| Are calls taking longer? | `@event_type:runtime.call.end`, `@duration_ms` | Duration distribution; define a numeric measure for `duration_ms`. |
| Did export stop? | Receiver/queue health and expected event volume | Delivery-failure alert; a quiet channel alone is not proof of an outage. |
| Is our custom Chat backend slow? | `voiceflow.chat.turn` spans | Request duration and error status in Agent Observability. |

### Build a conversation dashboard

In **Logs → Explorer**, filter to `service:voiceflow-agent env:staging @event_type:runtime.session.end`. Choose a timeseries with the unique count of `event_id`, then use [Export to Dashboard](https://docs.datadoghq.com/logs/explorer/export/) to add the graph to your team's dashboard. Compare the plotted period with your test conversation. Add a separate call-duration graph rather than mixing its values with session lifetime.

### Create the first log monitor

### 1. Choose the signal

In Datadog, open **Monitors → New Monitor → Logs**. Use `service:voiceflow-agent env:staging @event_type:runtime.call.end` and select `duration_ms` as a measure. Check that the query finds your test call.

### 2. Set the condition and destination

Choose the duration aggregation, threshold and time window that match your call experience. Add your team's notification destination, then save the monitor.

### 3. Verify the alert and recovery

Only [indexed Standard Tier logs](https://docs.datadoghq.com/monitors/types/log/) participate in log monitors. Confirm the query finds your test records before relying on the alert. Trigger a controlled sandbox condition and verify both the alert and recovery notification.

### Maintain the connection

Assign owners for the receiver, Datadog key, webhook signing secret and alert routing. During key rotation, update the server-held value and repeat a real conversation test before retiring the old key. For Voiceflow's signing secret, follow [secret rotation](/docs/api-reference/webhooks/session-lifecycle#rotating-the-signing-secret); the old signature secret remains valid for 24 hours.

### Disable export without disrupting the agent

Remove forwarding while preserving other webhook consumers.

Disable the Datadog destination in your shared receiver, or clear this project's webhook URL only if no other workflow uses it. Remove the custom Chat instrumentation without changing its runtime call or session handling. Then revoke the unused Datadog key and remove the server secrets.

Previously ingested data follows Datadog's retention policy. Disabling forwarding does not delete it or Voiceflow's transcripts.
