Run Conversational and Voice Tests in Connect API

A conversational test evaluates a multi-turn exchange between a simulated caller and your agent, rather than a single utterance. Give the test a goal and a turn budget, and the service drives the conversation to completion, then scores the result. When you test a voice agent, you can capture voice quality metrics, such as how the agent paces its speech and how it handles interruptions, in addition to the standard scorers.

Use conversational tests when a single request-and-response check isn’t enough: password resets, guided troubleshooting, or any workflow where the agent must gather information across several turns. Use voice metrics when you’re validating a voice agent and need to measure the caller experience, not just the correctness of the final answer.

The primary conversational test flow uses three Connect API endpoints:

  • Run Conversational Test: Starts an asynchronous multi-turn test and returns the workbook (test suite), worksheet (run status), and row IDs that identify the run.
  • Get Conversational Test Status: Polls the run to monitor its progress.
  • Get Conversational Test Results: Retrieves the detailed results after the run completes.

You can also run ephemeral conversational tests to iterate and tune test suites (workbooks) without saving them to your org. See the reference guide for the ephemeral endpoint and request schema.

To run agent tests from the Salesforce UI instead of directly using Connect API, see Agentforce Testing Center. To run tests from the command line, see Run the Agent Tests with Agentforce DX.

Note

Prerequisites 

Conversational tests use the same authentication as the rest of Testing API. Before you call these endpoints, create an external client app and mint an access token by following the steps in Set Up Authentication for Testing API. Conversational tests also require API version 67.0 or later. The examples in this topic use version 68.0. You also need the IDs of the agent and the agent version you want to test.

Get the Agent and Agent Version IDs 

agentId is the ID of the agent’s BotDefinition record, and agentVersionId is the ID of a BotVersion record. To find both, run this SOQL query, replacing {AGENT_API_NAME} with your agent’s API name.

1SELECT Id, DeveloperName, (SELECT Id, VersionNumber, Status FROM BotVersions)
2FROM BotDefinition
3WHERE DeveloperName = '{AGENT_API_NAME}'

For example, with Salesforce CLI:

1sf data query --target-org <org-alias> --query "SELECT Id, DeveloperName, (SELECT Id, VersionNumber, Status FROM BotVersions) FROM BotDefinition WHERE DeveloperName = '{AGENT_API_NAME}'"

The top-level Id is the agentId. Each entry in BotVersions has an Id you can use as the agentVersionId. Choose the version with Status set to Active.

Understand Workbooks and Worksheets 

The Connect API responses and URLs for conversational tests refer to three related resources: workbooks, worksheets, and rows.

  • Workbook: The test suite. A workbook holds the test definitions that you run, and you name it when you start a run with workbookName.
  • Worksheet: The run state of a test suite. A worksheet represents either the current run or a stored run from the run history. Use the worksheetId to check the status and get the results of a run.
  • Row: The run of a single test case within a worksheet. A worksheet can contain multiple rows, and each row lays out its input, the agent’s run, and the result for each scorer as columns. Use the rowId with the worksheetId to check the status and get the results of one test case.

In other words, the workbook is what you test, the worksheet is what happened when you tested it, and each row is the outcome for one test case. Running the same workbook again produces a new worksheet, and you can use an earlier worksheet’s ID to look up the results of that earlier run.

Conversation-Level Testing Workflow 

  1. Start a run. Send the goal, maximum turns, and scorers in the request body. There’s no metadata to deploy.
  2. Poll for status. Check the run’s worksheet until the run completes.
  3. Get the results. Read one result per scorer, plus voice metrics for voice agents.

See Run Conversational and Voice Tests in Connect API.

Run a Conversational Test 

To start a test, make a POST request to /services/data/v68.0/einstein/ai-testing/conversational-test/run. In the request body, identify the agent, name the workbook (test suite) to store the test in, and define the test case, its goal, the maximum number of turns, and the scorers to apply.

1curl -X POST https://{INSTANCE_NAME}.my.salesforce.com/services/data/v68.0/einstein/ai-testing/conversational-test/run \
2     -H "Content-Type: application/json" \
3     -H "Authorization: Bearer {TOKEN}" \
4     -d '{
5           "workbookName": "Password_Reset_Regression",
6           "agentId": "0Xxxx0000000001CAA",
7           "evaluationMode": "TEXT",
8           "description": "Password reset regression test",
9           "testCase": {
10             "number": 1,
11             "goal": "Help me reset my password",
12             "inputs": [{ "contextVariables": [] }],
13             "maxTurns": 15,
14             "scorers": [
15               { "name": "coherence" },
16               { "name": "response_match", "expectedValue": "password reset" }
17             ]
18           }
19         }'
  • INSTANCE_NAME: The instance of your Salesforce org.
  • TOKEN: The access token obtained during setup.

testCase.inputs is required and must contain at least one entry. Use contextVariables to pass context variable values to the agent, or leave it empty as shown. If you omit inputs, the request fails with a 400 error: Test case must have at least one input.

The response returns the identifiers for the new run. Because the test runs asynchronously, the status is IN_PROGRESS until the conversation completes. Save the worksheetId and rowId—you need both to check status and retrieve results. The worksheet tracks the state of this run, so you use its ID in the status and results requests.

1{
2  "workbookId": "1W4xx0000000001CAA",
3  "workbookName": "Password_Reset_Regression",
4  "worksheetId": "1W5xx0000000001CAA",
5  "rowId": "1W6xx0000000001CAA",
6  "status": "IN_PROGRESS",
7  "errorMessage": null,
8  "runningTestSuites": null
9}

For the full request and response schema, including the test case object and all top-level parameters, see Run Conversational Test.

Test a Voice Agent 

To evaluate a voice agent, set evaluationMode to TEXT_VOICE and specify a voiceMode. To collect voice quality metrics, add a voiceMetrics array that lists the metric suites you want to measure.

1curl -X POST https://{INSTANCE_NAME}.my.salesforce.com/services/data/v68.0/einstein/ai-testing/conversational-test/run \
2     -H "Content-Type: application/json" \
3     -H "Authorization: Bearer {TOKEN}" \
4     -d '{
5           "workbookName": "Voice_Password_Reset",
6           "agentId": "0Xxxx0000000001CAA",
7           "evaluationMode": "TEXT_VOICE",
8           "voiceMode": "LIVE",
9           "persona": "DEFAULT",
10           "voiceMetrics": ["pacing_and_gaps", "interruption_quality"],
11           "testCase": {
12             "number": 1,
13             "goal": "Help me reset my password",
14             "inputs": [{ "contextVariables": [] }],
15             "maxTurns": 15,
16             "scorers": [
17               { "name": "coherence" }
18             ]
19           }
20         }'

Voice Metrics 

The voiceMetrics array accepts these values. You can request one or both in the same test.

MetricWhat it measures
pacing_and_gapsConversational pacing and timing, including speaking rate (words per minute), utterance length, inter-turn gaps, dead air, and time-to-first-audio (TTFA) latency.
interruption_qualityHow the agent and caller handle interruptions (barge-in). Reports when the agent or the caller cuts in and the overlap count—the number of times both speak at the same time.

Voice metrics require a voice run, so evaluationMode must be TEXT_VOICE and voiceMode must be set. If you request voice metrics without a voice run, they aren’t evaluated.

Get Conversational Test Status 

The test runs asynchronously, so poll for status until the run completes. Make a GET request to /services/data/v68.0/einstein/ai-testing/test-status/{worksheetId}/rows/{rowId}, using the IDs returned when you started the run. The worksheetId identifies the worksheet, which holds the run’s status.

1curl https://{INSTANCE_NAME}.my.salesforce.com/services/data/v68.0/einstein/ai-testing/test-status/{worksheetId}/rows/{rowId} \
2     -H "Authorization: Bearer {TOKEN}"

The response reports an overallStatus for the row and a per-column status. Continue polling while overallStatus is IN_PROGRESS.

1{
2  "cellStatuses": [
3    {
4      "columnId": "1W5RZ000000nHan0AE",
5      "columnName": "Utterance",
6      "columnType": "TEXT",
7      "status": "COMPLETE"
8    },
9    {
10      "columnId": "1W5RZ000000nHap0AE",
11      "columnName": "Agent Test",
12      "columnType": "AGENT_TEST",
13      "status": "IN_PROGRESS"
14    }
15  ],
16  "overallStatus": "IN_PROGRESS",
17  "rowId": "1W6RZ00000042Cv0AI",
18  "worksheetId": "1W1RZ000000kEBG0A2"
19}

For the full response schema, see Get Conversational Test Status.

Get Conversational Test Results 

After overallStatus is complete, retrieve the results by making a GET request to /services/data/v68.0/einstein/ai-testing/test-results/{worksheetId}/rows/{rowId}.

1curl https://{INSTANCE_NAME}.my.salesforce.com/services/data/v68.0/einstein/ai-testing/test-results/{worksheetId}/rows/{rowId} \
2     -H "Authorization: Bearer {TOKEN}"

The response returns the row’s results as a set of columns. Each column carries a displayContent value for quick reading and a fullContent value with the complete structured result. Each scorer you defined appears as an EVALUATION column, and each voice metric suite you requested appears as an additional evaluation column.

When you request pacing_and_gaps, the result includes a session-level pacing analysis—speaking rate, utterance length, inter-turn gaps, dead air, and time-to-first-audio latency. For the full field list, see Voice Metric Result: pacing_and_gaps.

1{
2  "columns": [
3    {
4      "columnId": "1W5RZ000000nHan0AE",
5      "columnName": "Utterance",
6      "columnType": "TEXT",
7      "displayContent": "Help me reset my password",
8      "fullContent": "{\"content\":\"Help me reset my password\",\"schema\":{\"type\":\"STRING\"}}",
9      "status": "COMPLETE",
10      "statusMessage": null
11    },
12    {
13      "columnId": "1W5RZ000000nHaq0AE",
14      "columnName": "Coherence Evaluation",
15      "columnType": "EVALUATION",
16      "displayContent": null,
17      "fullContent": null,
18      "status": "COMPLETE",
19      "statusMessage": null
20    }
21  ],
22  "overallStatus": "COMPLETE",
23  "rowId": "1W6RZ00000042Cv0AI",
24  "worksheetId": "1W1RZ000000kEBG0A2"
25}

For the full response schema, see Get Conversational Test Results.

Understand the Agent Test Results 

See Use Test Results to Improve Your Agent.

See Also