Google Cloud Dialogflow Cx V3 Client - Class FlowsClient (0.4.0)

Reference documentation and code samples for the Google Cloud Dialogflow Cx V3 Client class FlowsClient.

Service Description: Service for managing Flows.

This class provides the ability to make remote calls to the backing service through method calls that map to API methods.

Many parameters require resource names to be formatted in a particular way. To assist with these names, this class includes a format method for each type of name, and additionally a parseName method to extract the individual identifiers contained within formatted names that are returned by the API.

Namespace

Google \ Cloud \ Dialogflow \ Cx \ V3 \ Client

Methods

__construct

Constructor.

Parameters
Name Description
options array

Optional. Options for configuring the service API wrapper.

↳ apiEndpoint string

The address of the API remote host. May optionally include the port, formatted as "

↳ credentials string|array|FetchAuthTokenInterface|CredentialsWrapper

The credentials to be used by the client to authorize API calls. This option accepts either a path to a credentials file, or a decoded credentials file as a PHP array. Advanced usage: In addition, this option can also accept a pre-constructed Google\Auth\FetchAuthTokenInterface object or Google\ApiCore\CredentialsWrapper object. Note that when one of these objects are provided, any settings in $credentialsConfig will be ignored.

↳ credentialsConfig array

Options used to configure credentials, including auth token caching, for the client. For a full list of supporting configuration options, see Google\ApiCore\CredentialsWrapper::build() .

↳ disableRetries bool

Determines whether or not retries defined by the client configuration should be disabled. Defaults to false.

↳ clientConfig string|array

Client method configuration, including retry settings. This option can be either a path to a JSON file, or a PHP array containing the decoded JSON data. By default this settings points to the default client config file, which is provided in the resources folder.

↳ transport string|TransportInterface

The transport used for executing network requests. May be either the string rest or grpc. Defaults to grpc if gRPC support is detected on the system. Advanced usage: Additionally, it is possible to pass in an already instantiated Google\ApiCore\Transport\TransportInterface object. Note that when this object is provided, any settings in $transportConfig, and any $apiEndpoint setting, will be ignored.

↳ transportConfig array

Configuration options that will be used to construct the transport. Options for each supported transport type should be passed in a key for that transport. For example: $transportConfig = [ 'grpc' => [...], 'rest' => [...], ]; See the Google\ApiCore\Transport\GrpcTransport::build() and Google\ApiCore\Transport\RestTransport::build() methods for the supported options.

↳ clientCertSource callable

A callable which returns the client cert as a string. This can be used to provide a certificate and private key to the transport layer for mTLS.

createFlow

Creates a flow in the specified agent.

Note: You should always train a flow prior to sending it queries. See the training documentation.

The async variant is Google\Cloud\Dialogflow\Cx\V3\Client\FlowsClient::createFlowAsync() .

Parameters
Name Description
request Google\Cloud\Dialogflow\Cx\V3\CreateFlowRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\Cloud\Dialogflow\Cx\V3\Flow
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Dialogflow\Cx\V3\Client\FlowsClient;
use Google\Cloud\Dialogflow\Cx\V3\CreateFlowRequest;
use Google\Cloud\Dialogflow\Cx\V3\Flow;

/**
 * @param string $formattedParent The agent to create a flow for.
 *                                Format: `projects/<Project ID>/locations/<Location ID>/agents/<Agent ID>`. Please see
 *                                {@see FlowsClient::agentName()} for help formatting this field.
 * @param string $flowDisplayName The human-readable name of the flow.
 */
function create_flow_sample(string $formattedParent, string $flowDisplayName): void
{
    // Create a client.
    $flowsClient = new FlowsClient();

    // Prepare the request message.
    $flow = (new Flow())
        ->setDisplayName($flowDisplayName);
    $request = (new CreateFlowRequest())
        ->setParent($formattedParent)
        ->setFlow($flow);

    // Call the API and handle any network failures.
    try {
        /** @var Flow $response */
        $response = $flowsClient->createFlow($request);
        printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedParent = FlowsClient::agentName('[PROJECT]', '[LOCATION]', '[AGENT]');
    $flowDisplayName = '[DISPLAY_NAME]';

    create_flow_sample($formattedParent, $flowDisplayName);
}

deleteFlow

Deletes a specified flow.

The async variant is Google\Cloud\Dialogflow\Cx\V3\Client\FlowsClient::deleteFlowAsync() .

Parameters
Name Description
request Google\Cloud\Dialogflow\Cx\V3\DeleteFlowRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Example
use Google\ApiCore\ApiException;
use Google\Cloud\Dialogflow\Cx\V3\Client\FlowsClient;
use Google\Cloud\Dialogflow\Cx\V3\DeleteFlowRequest;

/**
 * @param string $formattedName The name of the flow to delete.
 *                              Format: `projects/<Project ID>/locations/<Location ID>/agents/<Agent
 *                              ID>/flows/<Flow ID>`. Please see
 *                              {@see FlowsClient::flowName()} for help formatting this field.
 */
function delete_flow_sample(string $formattedName): void
{
    // Create a client.
    $flowsClient = new FlowsClient();

    // Prepare the request message.
    $request = (new DeleteFlowRequest())
        ->setName($formattedName);

    // Call the API and handle any network failures.
    try {
        $flowsClient->deleteFlow($request);
        printf('Call completed successfully.' . PHP_EOL);
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedName = FlowsClient::flowName('[PROJECT]', '[LOCATION]', '[AGENT]', '[FLOW]');

    delete_flow_sample($formattedName);
}

exportFlow

Exports the specified flow to a binary file.

This method is a long-running operation. The returned Operation type has the following method-specific fields:

Note that resources (e.g. intents, entities, webhooks) that the flow references will also be exported.

The async variant is Google\Cloud\Dialogflow\Cx\V3\Client\FlowsClient::exportFlowAsync() .

Parameters
Name Description
request Google\Cloud\Dialogflow\Cx\V3\ExportFlowRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\ApiCore\OperationResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Dialogflow\Cx\V3\Client\FlowsClient;
use Google\Cloud\Dialogflow\Cx\V3\ExportFlowRequest;
use Google\Cloud\Dialogflow\Cx\V3\ExportFlowResponse;
use Google\Rpc\Status;

/**
 * @param string $formattedName The name of the flow to export.
 *                              Format: `projects/<Project ID>/locations/<Location ID>/agents/<Agent
 *                              ID>/flows/<Flow ID>`. Please see
 *                              {@see FlowsClient::flowName()} for help formatting this field.
 */
function export_flow_sample(string $formattedName): void
{
    // Create a client.
    $flowsClient = new FlowsClient();

    // Prepare the request message.
    $request = (new ExportFlowRequest())
        ->setName($formattedName);

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $flowsClient->exportFlow($request);
        $response->pollUntilComplete();

        if ($response->operationSucceeded()) {
            /** @var ExportFlowResponse $result */
            $result = $response->getResult();
            printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString());
        } else {
            /** @var Status $error */
            $error = $response->getError();
            printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedName = FlowsClient::flowName('[PROJECT]', '[LOCATION]', '[AGENT]', '[FLOW]');

    export_flow_sample($formattedName);
}

getFlow

Retrieves the specified flow.

The async variant is Google\Cloud\Dialogflow\Cx\V3\Client\FlowsClient::getFlowAsync() .

Parameters
Name Description
request Google\Cloud\Dialogflow\Cx\V3\GetFlowRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\Cloud\Dialogflow\Cx\V3\Flow
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Dialogflow\Cx\V3\Client\FlowsClient;
use Google\Cloud\Dialogflow\Cx\V3\Flow;
use Google\Cloud\Dialogflow\Cx\V3\GetFlowRequest;

/**
 * @param string $formattedName The name of the flow to get.
 *                              Format: `projects/<Project ID>/locations/<Location ID>/agents/<Agent
 *                              ID>/flows/<Flow ID>`. Please see
 *                              {@see FlowsClient::flowName()} for help formatting this field.
 */
function get_flow_sample(string $formattedName): void
{
    // Create a client.
    $flowsClient = new FlowsClient();

    // Prepare the request message.
    $request = (new GetFlowRequest())
        ->setName($formattedName);

    // Call the API and handle any network failures.
    try {
        /** @var Flow $response */
        $response = $flowsClient->getFlow($request);
        printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedName = FlowsClient::flowName('[PROJECT]', '[LOCATION]', '[AGENT]', '[FLOW]');

    get_flow_sample($formattedName);
}

getFlowValidationResult

Gets the latest flow validation result. Flow validation is performed when ValidateFlow is called.

The async variant is Google\Cloud\Dialogflow\Cx\V3\Client\FlowsClient::getFlowValidationResultAsync() .

Parameters
Name Description
request Google\Cloud\Dialogflow\Cx\V3\GetFlowValidationResultRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\Cloud\Dialogflow\Cx\V3\FlowValidationResult
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Dialogflow\Cx\V3\Client\FlowsClient;
use Google\Cloud\Dialogflow\Cx\V3\FlowValidationResult;
use Google\Cloud\Dialogflow\Cx\V3\GetFlowValidationResultRequest;

/**
 * @param string $formattedName The flow name.
 *                              Format: `projects/<Project ID>/locations/<Location ID>/agents/<Agent
 *                              ID>/flows/<Flow ID>/validationResult`. Please see
 *                              {@see FlowsClient::flowValidationResultName()} for help formatting this field.
 */
function get_flow_validation_result_sample(string $formattedName): void
{
    // Create a client.
    $flowsClient = new FlowsClient();

    // Prepare the request message.
    $request = (new GetFlowValidationResultRequest())
        ->setName($formattedName);

    // Call the API and handle any network failures.
    try {
        /** @var FlowValidationResult $response */
        $response = $flowsClient->getFlowValidationResult($request);
        printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedName = FlowsClient::flowValidationResultName(
        '[PROJECT]',
        '[LOCATION]',
        '[AGENT]',
        '[FLOW]'
    );

    get_flow_validation_result_sample($formattedName);
}

importFlow

Imports the specified flow to the specified agent from a binary file.

This method is a long-running operation. The returned Operation type has the following method-specific fields:

Note: You should always train a flow prior to sending it queries. See the training documentation.

The async variant is Google\Cloud\Dialogflow\Cx\V3\Client\FlowsClient::importFlowAsync() .

Parameters
Name Description
request Google\Cloud\Dialogflow\Cx\V3\ImportFlowRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\ApiCore\OperationResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Dialogflow\Cx\V3\Client\FlowsClient;
use Google\Cloud\Dialogflow\Cx\V3\ImportFlowRequest;
use Google\Cloud\Dialogflow\Cx\V3\ImportFlowResponse;
use Google\Rpc\Status;

/**
 * @param string $formattedParent The agent to import the flow into.
 *                                Format: `projects/<Project ID>/locations/<Location ID>/agents/<Agent ID>`. Please see
 *                                {@see FlowsClient::agentName()} for help formatting this field.
 */
function import_flow_sample(string $formattedParent): void
{
    // Create a client.
    $flowsClient = new FlowsClient();

    // Prepare the request message.
    $request = (new ImportFlowRequest())
        ->setParent($formattedParent);

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $flowsClient->importFlow($request);
        $response->pollUntilComplete();

        if ($response->operationSucceeded()) {
            /** @var ImportFlowResponse $result */
            $result = $response->getResult();
            printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString());
        } else {
            /** @var Status $error */
            $error = $response->getError();
            printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedParent = FlowsClient::agentName('[PROJECT]', '[LOCATION]', '[AGENT]');

    import_flow_sample($formattedParent);
}

listFlows

Returns the list of all flows in the specified agent.

The async variant is Google\Cloud\Dialogflow\Cx\V3\Client\FlowsClient::listFlowsAsync() .

Parameters
Name Description
request Google\Cloud\Dialogflow\Cx\V3\ListFlowsRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\ApiCore\PagedListResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\Dialogflow\Cx\V3\Client\FlowsClient;
use Google\Cloud\Dialogflow\Cx\V3\Flow;
use Google\Cloud\Dialogflow\Cx\V3\ListFlowsRequest;

/**
 * @param string $formattedParent The agent containing the flows.
 *                                Format: `projects/<Project ID>/locations/<Location ID>/agents/<Agent ID>`. Please see
 *                                {@see FlowsClient::agentName()} for help formatting this field.
 */
function list_flows_sample(string $formattedParent): void
{
    // Create a client.
    $flowsClient = new FlowsClient();

    // Prepare the request message.
    $request = (new ListFlowsRequest())
        ->setParent($formattedParent);

    // Call the API and handle any network failures.
    try {
        /** @var PagedListResponse $response */
        $response = $flowsClient->listFlows($request);

        /** @var Flow $element */
        foreach ($response as $element) {
            printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedParent = FlowsClient::agentName('[PROJECT]', '[LOCATION]', '[AGENT]');

    list_flows_sample($formattedParent);
}

trainFlow

Trains the specified flow. Note that only the flow in 'draft' environment is trained.

This method is a long-running operation. The returned Operation type has the following method-specific fields:

Note: You should always train a flow prior to sending it queries. See the training documentation.

The async variant is Google\Cloud\Dialogflow\Cx\V3\Client\FlowsClient::trainFlowAsync() .

Parameters
Name Description
request Google\Cloud\Dialogflow\Cx\V3\TrainFlowRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\ApiCore\OperationResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Dialogflow\Cx\V3\Client\FlowsClient;
use Google\Cloud\Dialogflow\Cx\V3\TrainFlowRequest;
use Google\Rpc\Status;

/**
 * @param string $formattedName The flow to train.
 *                              Format: `projects/<Project ID>/locations/<Location ID>/agents/<Agent
 *                              ID>/flows/<Flow ID>`. Please see
 *                              {@see FlowsClient::flowName()} for help formatting this field.
 */
function train_flow_sample(string $formattedName): void
{
    // Create a client.
    $flowsClient = new FlowsClient();

    // Prepare the request message.
    $request = (new TrainFlowRequest())
        ->setName($formattedName);

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $flowsClient->trainFlow($request);
        $response->pollUntilComplete();

        if ($response->operationSucceeded()) {
            printf('Operation completed successfully.' . PHP_EOL);
        } else {
            /** @var Status $error */
            $error = $response->getError();
            printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedName = FlowsClient::flowName('[PROJECT]', '[LOCATION]', '[AGENT]', '[FLOW]');

    train_flow_sample($formattedName);
}

updateFlow

Updates the specified flow.

Note: You should always train a flow prior to sending it queries. See the training documentation.

The async variant is Google\Cloud\Dialogflow\Cx\V3\Client\FlowsClient::updateFlowAsync() .

Parameters
Name Description
request Google\Cloud\Dialogflow\Cx\V3\UpdateFlowRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\Cloud\Dialogflow\Cx\V3\Flow
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Dialogflow\Cx\V3\Client\FlowsClient;
use Google\Cloud\Dialogflow\Cx\V3\Flow;
use Google\Cloud\Dialogflow\Cx\V3\UpdateFlowRequest;

/**
 * @param string $flowDisplayName The human-readable name of the flow.
 */
function update_flow_sample(string $flowDisplayName): void
{
    // Create a client.
    $flowsClient = new FlowsClient();

    // Prepare the request message.
    $flow = (new Flow())
        ->setDisplayName($flowDisplayName);
    $request = (new UpdateFlowRequest())
        ->setFlow($flow);

    // Call the API and handle any network failures.
    try {
        /** @var Flow $response */
        $response = $flowsClient->updateFlow($request);
        printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $flowDisplayName = '[DISPLAY_NAME]';

    update_flow_sample($flowDisplayName);
}

validateFlow

Validates the specified flow and creates or updates validation results.

Please call this API after the training is completed to get the complete validation results.

The async variant is Google\Cloud\Dialogflow\Cx\V3\Client\FlowsClient::validateFlowAsync() .

Parameters
Name Description
request Google\Cloud\Dialogflow\Cx\V3\ValidateFlowRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\Cloud\Dialogflow\Cx\V3\FlowValidationResult
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Dialogflow\Cx\V3\Client\FlowsClient;
use Google\Cloud\Dialogflow\Cx\V3\FlowValidationResult;
use Google\Cloud\Dialogflow\Cx\V3\ValidateFlowRequest;

/**
 * @param string $formattedName The flow to validate.
 *                              Format: `projects/<Project ID>/locations/<Location ID>/agents/<Agent
 *                              ID>/flows/<Flow ID>`. Please see
 *                              {@see FlowsClient::flowName()} for help formatting this field.
 */
function validate_flow_sample(string $formattedName): void
{
    // Create a client.
    $flowsClient = new FlowsClient();

    // Prepare the request message.
    $request = (new ValidateFlowRequest())
        ->setName($formattedName);

    // Call the API and handle any network failures.
    try {
        /** @var FlowValidationResult $response */
        $response = $flowsClient->validateFlow($request);
        printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedName = FlowsClient::flowName('[PROJECT]', '[LOCATION]', '[AGENT]', '[FLOW]');

    validate_flow_sample($formattedName);
}

getLocation

Gets information about a location.

The async variant is Google\Cloud\Dialogflow\Cx\V3\Client\FlowsClient::getLocationAsync() .

Parameters
Name Description
request Google\Cloud\Location\GetLocationRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\Cloud\Location\Location
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Dialogflow\Cx\V3\Client\FlowsClient;
use Google\Cloud\Location\GetLocationRequest;
use Google\Cloud\Location\Location;

/**
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function get_location_sample(): void
{
    // Create a client.
    $flowsClient = new FlowsClient();

    // Prepare the request message.
    $request = new GetLocationRequest();

    // Call the API and handle any network failures.
    try {
        /** @var Location $response */
        $response = $flowsClient->getLocation($request);
        printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

listLocations

Lists information about the supported locations for this service.

The async variant is Google\Cloud\Dialogflow\Cx\V3\Client\FlowsClient::listLocationsAsync() .

Parameters
Name Description
request Google\Cloud\Location\ListLocationsRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\ApiCore\PagedListResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\Dialogflow\Cx\V3\Client\FlowsClient;
use Google\Cloud\Location\ListLocationsRequest;
use Google\Cloud\Location\Location;

/**
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function list_locations_sample(): void
{
    // Create a client.
    $flowsClient = new FlowsClient();

    // Prepare the request message.
    $request = new ListLocationsRequest();

    // Call the API and handle any network failures.
    try {
        /** @var PagedListResponse $response */
        $response = $flowsClient->listLocations($request);

        /** @var Location $element */
        foreach ($response as $element) {
            printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

createFlowAsync

Parameters
Name Description
request Google\Cloud\Dialogflow\Cx\V3\CreateFlowRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

deleteFlowAsync

Parameters
Name Description
request Google\Cloud\Dialogflow\Cx\V3\DeleteFlowRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

exportFlowAsync

Parameters
Name Description
request Google\Cloud\Dialogflow\Cx\V3\ExportFlowRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

getFlowAsync

Parameters
Name Description
request Google\Cloud\Dialogflow\Cx\V3\GetFlowRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

getFlowValidationResultAsync

Parameters
Name Description
request Google\Cloud\Dialogflow\Cx\V3\GetFlowValidationResultRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

importFlowAsync

Parameters
Name Description
request Google\Cloud\Dialogflow\Cx\V3\ImportFlowRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

listFlowsAsync

Parameters
Name Description
request Google\Cloud\Dialogflow\Cx\V3\ListFlowsRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

trainFlowAsync

Parameters
Name Description
request Google\Cloud\Dialogflow\Cx\V3\TrainFlowRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

updateFlowAsync

Parameters
Name Description
request Google\Cloud\Dialogflow\Cx\V3\UpdateFlowRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

validateFlowAsync

Parameters
Name Description
request Google\Cloud\Dialogflow\Cx\V3\ValidateFlowRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

getLocationAsync

Parameters
Name Description
request Google\Cloud\Location\GetLocationRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

listLocationsAsync

Parameters
Name Description
request Google\Cloud\Location\ListLocationsRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

getOperationsClient

Return an OperationsClient object with the same endpoint as $this.

Returns
Type Description
Google\LongRunning\Client\OperationsClient

resumeOperation

Resume an existing long running operation that was previously started by a long running API method. If $methodName is not provided, or does not match a long running API method, then the operation can still be resumed, but the OperationResponse object will not deserialize the final response.

Parameters
Name Description
operationName string

The name of the long running operation

methodName string

The name of the method used to start the operation

Returns
Type Description
Google\ApiCore\OperationResponse

static::agentName

Formats a string containing the fully-qualified path to represent a agent resource.

Parameters
Name Description
project string
location string
agent string
Returns
Type Description
string The formatted agent resource.

static::flowName

Formats a string containing the fully-qualified path to represent a flow resource.

Parameters
Name Description
project string
location string
agent string
flow string
Returns
Type Description
string The formatted flow resource.

static::flowValidationResultName

Formats a string containing the fully-qualified path to represent a flow_validation_result resource.

Parameters
Name Description
project string
location string
agent string
flow string
Returns
Type Description
string The formatted flow_validation_result resource.

static::intentName

Formats a string containing the fully-qualified path to represent a intent resource.

Parameters
Name Description
project string
location string
agent string
intent string
Returns
Type Description
string The formatted intent resource.

static::pageName

Formats a string containing the fully-qualified path to represent a page resource.

Parameters
Name Description
project string
location string
agent string
flow string
page string
Returns
Type Description
string The formatted page resource.

static::projectLocationAgentFlowTransitionRouteGroupName

Formats a string containing the fully-qualified path to represent a project_location_agent_flow_transition_route_group resource.

Parameters
Name Description
project string
location string
agent string
flow string
transitionRouteGroup string
Returns
Type Description
string The formatted project_location_agent_flow_transition_route_group resource.

static::projectLocationAgentTransitionRouteGroupName

Formats a string containing the fully-qualified path to represent a project_location_agent_transition_route_group resource.

Parameters
Name Description
project string
location string
agent string
transitionRouteGroup string
Returns
Type Description
string The formatted project_location_agent_transition_route_group resource.

static::transitionRouteGroupName

Formats a string containing the fully-qualified path to represent a transition_route_group resource.

Parameters
Name Description
project string
location string
agent string
flow string
transitionRouteGroup string
Returns
Type Description
string The formatted transition_route_group resource.

static::webhookName

Formats a string containing the fully-qualified path to represent a webhook resource.

Parameters
Name Description
project string
location string
agent string
webhook string
Returns
Type Description
string The formatted webhook resource.

static::parseName

Parses a formatted name string and returns an associative array of the components in the name.

The following name formats are supported: Template: Pattern

  • agent: projects/{project}/locations/{location}/agents/{agent}
  • flow: projects/{project}/locations/{location}/agents/{agent}/flows/{flow}
  • flowValidationResult: projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/validationResult
  • intent: projects/{project}/locations/{location}/agents/{agent}/intents/{intent}
  • page: projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/pages/{page}
  • projectLocationAgentFlowTransitionRouteGroup: projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/transitionRouteGroups/{transition_route_group}
  • projectLocationAgentTransitionRouteGroup: projects/{project}/locations/{location}/agents/{agent}/transitionRouteGroups/{transition_route_group}
  • transitionRouteGroup: projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/transitionRouteGroups/{transition_route_group}
  • webhook: projects/{project}/locations/{location}/agents/{agent}/webhooks/{webhook}

The optional $template argument can be supplied to specify a particular pattern, and must match one of the templates listed above. If no $template argument is provided, or if the $template argument does not match one of the templates listed, then parseName will check each of the supported templates, and return the first match.

Parameters
Name Description
formattedName string

The formatted name string

template string

Optional name of template to match

Returns
Type Description
array An associative array from name component IDs to component values.