To capture, review, and analyze voice conversations, Dialogflow CX lets you
export conversational audio to Cloud Storage.

Dialogflow CX provides two separate, independent mechanisms to export audio:

- **Agent and flow settings** : Configured using [`AdvancedSettings.audio_export_gcs_destination`](https://docs.cloud.google.com/dialogflow/cx/docs/reference/rpc/google.cloud.dialogflow.cx.v3.md.txt#google.cloud.dialogflow.cx.v3.AdvancedSettings). Applies to Dialogflow CX v3 session methods (`DetectIntent` and `StreamingDetectIntent`) as well as v2 and v2beta1 conversation participant methods (`AnalyzeContent`, `StreamingAnalyzeContent`, and `BidiStreamingAnalyzeContent`).
- **Security settings** : Configured using [`SecuritySettings.audio_export_settings`](https://docs.cloud.google.com/dialogflow/cx/docs/reference/rpc/google.cloud.dialogflow.cx.v3.md.txt#google.cloud.dialogflow.cx.v3.SecuritySettings.AudioExportSettings). Applies to both v3 session methods and v2 and v2beta1 participant methods, and supports audio redaction, audio format selection, and data retention policies.

These two export mechanisms are independent. If you configure both,
Dialogflow CX exports audio to both Cloud Storage destinations.

## Comparison of audio export mechanisms

The following table summarizes the differences between agent or flow export
and security settings export:

| Feature | Agent and flow settings | Security settings |
|---|---|---|
| **Primary purpose** | Immediate debugging, session-level playback in the [Conversational Agents console](https://conversational-agents.cloud.google.com), and logging | Long-term compliance, Sensitive Data Protection redaction, conversation analytics, and telephony call archival |
| **Configuration level** | Agent level (global default) or flow level (overrides agent-level setting for that flow) | Security settings resource level (reusable across agents and locations) |
| **Console configuration** | - **Agent settings \> Logging settings** : Enter a URI in **Specify a Cloud Storage URI to store and playback voice conversations**. - **Agent settings \> Speech and IVR \> Advanced speech settings** : Enter a URI in **Audio export bucket** (automatically synchronizes with Logging settings). - **Flow settings \> Speech and IVR \> Advanced speech settings \> Customize** : Enter a URI in **Audio export bucket** to override the agent-level bucket for that flow. | - **Agent settings \> Security**: Select a security settings resource. - **Security settings** page \> **Export** tab \> **Audio Export to Cloud Storage** : Configure **GCS Bucket** , **Audio Format** , and **Enable audio redaction (only for end user input audio)**. |
| **API fields and configuration** | Configured in [`AdvancedSettings`](https://docs.cloud.google.com/dialogflow/cx/docs/reference/rpc/google.cloud.dialogflow.cx.v3.md.txt#google.cloud.dialogflow.cx.v3.AdvancedSettings) on [`Agent`](https://docs.cloud.google.com/dialogflow/cx/docs/reference/rpc/google.cloud.dialogflow.cx.v3.md.txt#google.cloud.dialogflow.cx.v3.Agent) or [`Flow`](https://docs.cloud.google.com/dialogflow/cx/docs/reference/rpc/google.cloud.dialogflow.cx.v3.md.txt#google.cloud.dialogflow.cx.v3.Flow): - [`audio_export_gcs_destination`](https://docs.cloud.google.com/dialogflow/cx/docs/reference/rpc/google.cloud.dialogflow.cx.v3.md.txt#google.cloud.dialogflow.cx.v3.GcsDestination) (`GcsDestination`): Destination message containing `uri` (`string`), which specifies the full Cloud Storage URI in the format `gs://BUCKET_NAME/PATH`. | Configured in [`AudioExportSettings`](https://docs.cloud.google.com/dialogflow/cx/docs/reference/rpc/google.cloud.dialogflow.cx.v3.md.txt#google.cloud.dialogflow.cx.v3.SecuritySettings.AudioExportSettings) on [`SecuritySettings`](https://docs.cloud.google.com/dialogflow/cx/docs/reference/rpc/google.cloud.dialogflow.cx.v3.md.txt#google.cloud.dialogflow.cx.v3.SecuritySettings): - `gcs_bucket` (`string`): Bare bucket name (for example, `my-bucket`) without the `gs://` prefix or directory paths. - `audio_export_pattern` (`string`): Optional directory and filename pattern. For runtime requests, Dialogflow CX uses a timestamp directory pattern (defaulting to `%Y/%m/%d/%H`; if the pattern contains `{`, Dialogflow CX falls back to `%Y/%m/%d/%H`). For telephony call recordings, if the pattern contains `{conversation}`, Dialogflow CX replaces `{conversation}` with the conversation ID and `{timestamp}` with Unix epoch microseconds; otherwise, recordings use the default path `gs://BUCKET_NAME/CONVERSATION_ID.ext` (where `.ext` is `.raw` for `MULAW`, `.mp3` for `MP3`, or `.ogg` for `OGG`). - `enable_audio_redaction` (`bool`): Enables Sensitive Data Protection redaction for input audio (requires `redaction_strategy`). - `audio_format` (`AudioFormat`): File format for telephony audio (`MULAW`, `MP3`, or `OGG`). - `store_tts_audio` (`bool`): Stores synthesized text-to-speech audio from the agent (default `false`). |
| **Applicable API methods** | - **Dialogflow CX v3** : `DetectIntent` and `StreamingDetectIntent` - **Dialogflow v2 / v2beta1** : `AnalyzeContent`, `StreamingAnalyzeContent`, and `BidiStreamingAnalyzeContent` | - **Dialogflow CX v3** : `DetectIntent` and `StreamingDetectIntent` - **Dialogflow v2 / v2beta1** : `AnalyzeContent`, `StreamingAnalyzeContent`, and `BidiStreamingAnalyzeContent` |
| **End-user audio export** | Supported for all applicable methods | Supported for all applicable methods |
| **Text-to-speech (TTS) audio export** | Supported automatically for `DetectIntent` and non-streaming TTS in `StreamingDetectIntent` (v3), as well as all participant methods (`AnalyzeContent`, `StreamingAnalyzeContent`, `BidiStreamingAnalyzeContent`). Streaming TTS in `StreamingDetectIntent` (when `enable_streaming_synthesize` is set) is not exported. | Supported for `DetectIntent`, non-streaming TTS in `StreamingDetectIntent`, and all participant methods when you set `store_tts_audio` to `true`. |
| **Audio redaction** | Supported for end-user audio when the agent is configured with a security settings resource that has a `redaction_strategy`. | Supported for LINEAR16, MULAW, and ALAW end-user audio when `enable_audio_redaction` is `true` and `redaction_strategy` is configured. If redaction fails or audio lacks word offsets, the audio file is not stored. Synthesized TTS audio is not redacted. |
| **Audio format and extensions** | Original audio encoding. No file extension is appended to exported files by default. | Telephony recordings can be configured as `MULAW` (`.raw`), `MP3` (`.mp3`), or `OGG` (`.ogg`). Runtime input audio appends `.wav` if a WAV header is written; TTS audio appends `.wav`, `.mp3`, or `.ogg` based on output encoding. |
| **Cloud Storage path structure** | Flat directory containing individual utterance files: `gs://BUCKET_NAME/PATH/PROJECT_ID_SESSION_ID_ENCODING_SAMPLE_RATE_CHANNELS_TIMESTAMP` (where for synthesized TTS audio, `CHANNELS` is `2` for `DetectIntent` and `1` for participant methods; for input audio, `CHANNELS` matches the input channel count). | - **Runtime requests** : Timestamped directory structure per conversation: `gs://BUCKET_NAME/YYYY/MM/DD/HH/CONVERSATION_ID/FILENAME` (where `FILENAME` is `YYYY-MM-DD-HH-MM-SS-UUUUUU` in UTC). - **Telephony recordings** : When `audio_export_pattern` contains `{conversation}`, recordings use `gs://BUCKET_NAME/audio_export_pattern` (with `{conversation}` and `{timestamp}` replaced); otherwise, recordings default to `gs://BUCKET_NAME/CONVERSATION_ID.ext` (where `.ext` is `.raw` for `MULAW`, `.mp3`, or `.ogg`). |
| **Required IAM permissions** | **Storage Object Creator** (`roles/storage.objectCreator`) on the target bucket for the Dialogflow Service Agent (and partner telephony service accounts, if applicable). | **Storage Object Creator** (`roles/storage.objectCreator`) on the target bucket for the Dialogflow Service Agent. The calling user also requires `storage.buckets.getIamPolicy` (and `storage.buckets.setIamPolicy` unless pre-granted). |
| **Data retention policy interaction** | Independent of data retention policies; governed by target bucket lifecycle. | Active whenever `gcs_bucket` is configured (not disabled by `retention_strategy`); governed by target bucket lifecycle. |

## Precedence and interaction

Agent or flow settings and security settings operate independently:

- **No override**: Neither setting overrides, disables, or replaces the other.
- **Independent exports**: If you configure both an agent or flow export bucket and security settings audio export, Dialogflow CX exports conversation audio to both Cloud Storage destinations independently.
- **Separate destinations**: The two features use different directory path conventions and support different formatting and redaction options.
- **Shared bucket redaction behavior** : If `AdvancedSettings.audio_export_gcs_destination` and `SecuritySettings.audio_export_settings.gcs_bucket` point to the same Cloud Storage bucket, and `enable_audio_redaction` is `false`, Dialogflow skips Sensitive Data Protection redaction for that shared bucket even if `redaction_strategy` is configured on the security settings (which skips redaction on your `AdvancedSettings` exports as well). Configuring separate buckets prevents `enable_audio_redaction: false` on the security settings from disabling redaction on your `AdvancedSettings` exports. To ensure that audio written to the security settings destination is redacted, set `enable_audio_redaction` to `true` and configure `redaction_strategy`.

## Required IAM permissions

To allow Dialogflow CX to write exported audio files to your Cloud Storage
bucket, grant the **Storage Object Creator** (`roles/storage.objectCreator`) role
on the target bucket to the following service accounts:

- **Dialogflow Service Agent** : `service-PROJECT_NUMBER@gcp-sa-dialogflow.iam.gserviceaccount.com`
- **Partner built-in telephony service account** (if you use partner telephony): `one-click@df-cx-ALPHANUMERIC_VALUE-ALPHANUMERIC_VALUE.iam.gserviceaccount.com`

Replace `PROJECT_NUMBER` with the numeric Google Cloud project number where
your Dialogflow CX agent resides. To find the Dialogflow Service Agent in the
Google Cloud console, go to the **IAM** page and select **Include Google-provided
role grants**.

When you configure `audio_export_settings` in security settings by using the
console or API, Dialogflow validates the bucket policy and attempts to
grant the **Storage Object Creator** role to the Dialogflow Service Agent
automatically:

- The calling user account must have the `storage.buckets.getIamPolicy` permission on the target bucket, even when IAM roles are granted manually beforehand.
- The calling user account must also have the `storage.buckets.setIamPolicy` permission on the bucket, unless the **Storage Object Creator** role has already been granted to the Dialogflow Service Agent.
- If either required permission is missing during validation, the request fails with a `PERMISSION_DENIED` error.

## Dialogflow ES compatibility

Audio export compatibility with Dialogflow ES depends on the request method:

- **Participant methods (`AnalyzeContent`, `StreamingAnalyzeContent`, and `BidiStreamingAnalyzeContent`)** : A Dialogflow v2 or v2beta1 client calling `AnalyzeContent`, `StreamingAnalyzeContent`, or `BidiStreamingAnalyzeContent` with an Dialogflow ES agent can use Dialogflow CX `SecuritySettings` (configured through a `ConversationProfile`) to export conversation audio.
- **Session methods (`DetectIntent` and `StreamingDetectIntent`)** : In Dialogflow ES, `DetectIntent` and `StreamingDetectIntent` do not support audio export to Cloud Storage. Audio export for session methods is available in Dialogflow CX.