# Google Cloud Dialogflow V2 Client - Class TrainingPhrase (2.4.0)

2.4.0 (latest) 2.3.1 2.2.1 2.1.2 2.0.1 1.17.2 1.16.0 1.15.1 1.14.0 1.13.0 1.12.3 1.11.0 1.10.2 1.9.0 1.8.0 1.7.2 1.6.0 1.5.0 1.4.0 1.3.2 1.2.0 1.1.1 1.0.1 Reference documentation and code samples for the Google Cloud Dialogflow V2 Client class TrainingPhrase.

Represents an example that the agent is trained on.

Generated from protobuf message `google.cloud.dialogflow.v2.Intent.TrainingPhrase`

## Namespace

Google \\ Cloud \\ Dialogflow \\ V2 \\ Intent

## Methods

### __construct

Constructor.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `data` | `array` Optional. Data for populating the Message object. |
| `↳ name` | `string` Output only. The unique identifier of this training phrase. |
| `↳ type` | `int` Required. The type of the training phrase. |
| `↳ parts` | `array<https://docs.cloud.google.com/php/docs/reference/cloud-dialogflow/latest/V2.Intent.TrainingPhrase.Part>` Required. The ordered list of training phrase parts. The parts are concatenated in order to form the training phrase. Note: The API does not automatically annotate training phrases like the Dialogflow Console does. Note: Do not forget to include whitespace at part boundaries, so the training phrase is well formatted when the parts are concatenated. If the training phrase does not need to be annotated with parameters, you just need a single part with only the [Part.text](https://docs.cloud.google.com/php/docs/reference/cloud-dialogflow/latest/V2.Intent.TrainingPhrase.Part#_Google_Cloud_Dialogflow_V2_Intent_TrainingPhrase_Part__getText__) field set. If you want to annotate the training phrase, you must create multiple parts, where the fields of each part are populated in one of two ways: - `Part.text` is set to a part of the phrase that has no parameters. - `Part.text` is set to a part of the phrase that you want to annotate, and the `entity_type`, `alias`, and `user_defined` fields are all set. |
| `↳ times_added_count` | `int` Optional. Indicates how many times this example was added to the intent. Each time a developer adds an existing sample by editing an intent or training, this counter is increased. |

### getName

Output only. The unique identifier of this training phrase.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `string` |   |

### setName

Output only. The unique identifier of this training phrase.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getType

Required. The type of the training phrase.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `int` | Enum of type [Type](https://docs.cloud.google.com/php/docs/reference/cloud-dialogflow/latest/V2.Intent.TrainingPhrase.Type). |

### setType

Required. The type of the training phrase.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `int` Enum of type [Type](https://docs.cloud.google.com/php/docs/reference/cloud-dialogflow/latest/V2.Intent.TrainingPhrase.Type). |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getParts

Required. The ordered list of training phrase parts.

The parts are concatenated in order to form the training phrase.
Note: The API does not automatically annotate training phrases like the
Dialogflow Console does.
Note: Do not forget to include whitespace at part boundaries,
so the training phrase is well formatted when the parts are concatenated.
If the training phrase does not need to be annotated with parameters,
you just need a single part with only the
[Part.text](https://docs.cloud.google.com/php/docs/reference/cloud-dialogflow/latest/V2.Intent.TrainingPhrase.Part#_Google_Cloud_Dialogflow_V2_Intent_TrainingPhrase_Part__getText__)
field set.
If you want to annotate the training phrase, you must create multiple
parts, where the fields of each part are populated in one of two ways:

- `Part.text` is set to a part of the phrase that has no parameters.
- `Part.text` is set to a part of the phrase that you want to annotate, and the `entity_type`, `alias`, and `user_defined` fields are all set.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://protobuf.dev/reference/php/api-docs/Google/Protobuf/RepeatedField<https://docs.cloud.google.com/php/docs/reference/cloud-dialogflow/latest/V2.Intent.TrainingPhrase.Part>` |   |

### setParts

Required. The ordered list of training phrase parts.

The parts are concatenated in order to form the training phrase.
Note: The API does not automatically annotate training phrases like the
Dialogflow Console does.
Note: Do not forget to include whitespace at part boundaries,
so the training phrase is well formatted when the parts are concatenated.
If the training phrase does not need to be annotated with parameters,
you just need a single part with only the
[Part.text](https://docs.cloud.google.com/php/docs/reference/cloud-dialogflow/latest/V2.Intent.TrainingPhrase.Part#_Google_Cloud_Dialogflow_V2_Intent_TrainingPhrase_Part__getText__)
field set.
If you want to annotate the training phrase, you must create multiple
parts, where the fields of each part are populated in one of two ways:

- `Part.text` is set to a part of the phrase that has no parameters.
- `Part.text` is set to a part of the phrase that you want to annotate, and the `entity_type`, `alias`, and `user_defined` fields are all set.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `array<https://docs.cloud.google.com/php/docs/reference/cloud-dialogflow/latest/V2.Intent.TrainingPhrase.Part>` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getTimesAddedCount

Optional. Indicates how many times this example was added to
the intent. Each time a developer adds an existing sample by editing an
intent or training, this counter is increased.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `int` |   |

### setTimesAddedCount

Optional. Indicates how many times this example was added to
the intent. Each time a developer adds an existing sample by editing an
intent or training, this counter is increased.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `int` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |