When calling my Dialogflow's intents via the php client library it's returning an empty response for training phrases which means that when I update my intent it removes all my training phrases.
foreach($this->intentsClient->listIntents('projects/'.$this->project_id.'/agent')->iterateAllElements() as $element) {
kint($element->getTrainingPhrases());
exit;
}
WHERE
$this->intents is an instance of Client Google\Cloud\Dialogflow\V2\IntentsClient which is already authenticated.
kint is drupal's php debugging tool.
Please let me know if I might be doing something wrong, but when I retrieve the results as above I get 0 iterations available for training phrases.
Thanks!
Hi @adolflategan,
Try providing an intentView value to your listIntents call, like so:
use Google\Cloud\Dialogflow\V2\IntentView;
$intents = $this->intents->listIntents($parent, [
'intentView' => IntentView::INTENT_VIEW_FULL
]);
foreach ($intents->iterateAllElements() as $intent) {
kint($intent->getTrainingPhrases());
}
Another way to visualize the result without Drupal's tools:
foreach($intents->iterateAllElements() as $element) {
foreach ($element->getTrainingPhrases() as $phrase) {
print_r(json_decode($phrase->serializeToJsonString()));
}
}
For more information, refer to IntentView, which states the following:
An intent can be a sizable object. Therefore, we provide a resource view that does not return training phrases in the response by default.
That is perfect. Thank you so much. I missed the IntentView. Sorry about that and thank you for helping. It now works exactly as I want it to.
Most helpful comment
Hi @adolflategan,
Try providing an
intentViewvalue to yourlistIntentscall, like so:Another way to visualize the result without Drupal's tools:
For more information, refer to IntentView, which states the following: