-
Notifications
You must be signed in to change notification settings - Fork 455
Description
Hi,
I would like to integrate the Dialogflow environments feature in my code.
The feature is currently in beta, but I think it should be possible somehow to try it (sorry if I have missed how).
Currently, when getting a session, we use the following code (kind of):
$sessionClient = new SessionsClient();
$session = $sessionClient->sessionName($projectId, $sessionId);
Where the method sessionName() is defined in src/V2/Gapic/SessionsGapicClient.php as:
public static function sessionName($project, $session)
{
return self::getSessionNameTemplate()->render([
'project' => $project,
'session' => $session,
]);
}
and getSessionNameTemplate() as:
private static function getSessionNameTemplate()
{
if (null == self::$sessionNameTemplate) {
self::$sessionNameTemplate = new PathTemplate('projects/{project}/agent/sessions/{session}');
}
return self::$sessionNameTemplate;
}
Now, per documentation, we should:
alter the endpoint URL by inserting
environments/environment-name/users/-/between agent and sessions.
A possible solution is something like this (not tested, just guessing logically):
First, should be modify the sessionName method as follows to add a possible 3rd param, the environment, and use a different template in case it's not null:
public static function sessionName($project, $session, $environment = null)
{
if ($environment) {
return self::getSessionNameWithEnvironmentTemplate()->render([
'project' => $project,
'environment' => $environment,
'session' => $session,
]);
}
return self::getSessionNameTemplate()->render([
'project' => $project,
'session' => $session,
]);
}
and to create a getSessionNameWithEnvironmentTemplate() method as follows:
private static function getSessionNameWithEnvironmentTemplate()
{
if (null == self::$sessionNameTemplate) {
self::$sessionNameTemplate = new PathTemplate('projects/{project}/agent/environments/{environment}/users/-/sessions/{session}');
}
return self::$sessionNameTemplate;
}
Let me know if beta features are not available in this SDK by choice, if I have missed it somewhere or if simply this issue makes sense :)
Thanks,
Lorenzo