Dialogflow后续意图检测PHP SDK

时间:2018-10-25 11:44:38

标签: php symfony dialogflow

我正在将php sdk用于dialogflow api,我正在使用以下代码

    // create text input
    $textInput = new TextInput();
    $textInput->setText($user_text);
    $textInput->setLanguageCode($this->language_code);

    // create query input
    $queryInput = new QueryInput();
    $queryInput->setText($textInput);


    // get response and relevant info
    $response = $sessionsClient->detectIntent($session, $queryInput);
    $queryResult = $response->getQueryResult();
    $queryText = $queryResult->getQueryText();
    $intent = $queryResult->getIntent();

如何获取跟踪意图名称并使用queryinput调用它。

示例:

Intent: Contact form
Training phrase: Contact from , etc.
Followup Intent: Ask username

now if $user_text is "Contact from" ie training phrase of Intent: Contact form than how can i get the Followup intent name form

 $response = $sessionsClient->detectIntent($session, $queryInput);

如何在$ response或其他变量中获取关注意图名称。

1 个答案:

答案 0 :(得分:1)

您不会直接调用跟进意图。在您以某种方式将响应发送给他们之后,后续意图可能会由用户的下一个响应触发。

请记住-所有Intent都是由某种用户活动触发的-在这种情况下,通常是由您指定的$user_text来触发。

如果您需要根据期望或需要用户答复的方式显示内容,则应将其与匹配的Intent(或Intent名称)以及可能有用的任何其他当前状态相关联。您不知道下一个要触发的意图是什么-它可能是跟进意图,或者如果是更好的匹配,则可能是其他意图。您唯一知道的就是刚刚匹配的内容。