2017-12-01 2 views
3

私はDialog Flowについて読んできましたが、私にとってまだ不明な点が1つあります。私は例を挙げようとします。ダイアログフロー(API.ai)のデータコンテキストはどこにありますか

は、私は次のような変換を実装する:見ての通り、私はデータコンテキストを構築してい

User: Hello Google, what are some interesting cities? 
Bot: Hello there! Sydney, New York and Berlin are nice. 
User: Could you tell more about the second city? 
Bot: Sure. New York is amazing. In New York, you can ... 

。最初の質問の後、我々はSydney, New York and Berlinと答えたことを忘れないでください。だから、the second cityが実際に第2の質問に何を意味するのかを理解しています。

このデータをwebhookサービスに保存するか、これをダイアログフローのコンテキストに保存する必要がありますか?このようなデータをwebhookサービスに保存する必要がある場合、どのように進行中のさまざまな会話を区別できますか?

答えて

5

Dialogflow Contextに格納するのが理想的な解決策です。これはまさにContextsのためのものです!あなたは同じ言葉を使って質問を語りましたが、これは偶然ではありません。

概念的には、次のような設定でこれを行う可能性があります:あなたは今、「これら二つの比較」または「他の1について詳しく教えてください」のようなフレーズを扱う他のインテントを作成することができます

User: What are some interesting cities? 

Dialogflow sees no contexts and matches an Intent asking for cities. 

Agent replies: Sydney, New York, and Berlin are nice. 
Agent sets context "cities" with parameter "cities" -> "Sydney, New York, Berlin" 

User: Tell me more about the second one? 

Dialogflow has an Intent that expects an incoming context of "cities" with a text pattern like "Tell me more about the (number index) one?" It sends the request to that Intent along with the currently active contexts. 

Agent get a parameter with the index and the context "cities". It looks up the parameter for it, turns the string into an array, and gets the city based on the index. 
Agent replies: New York is a fun place to visit! 
Agent sets context "city" with parameter "current" -> "New York" 

User: Tell me more! 

Dialogflow matches this phrase and that the "city" context is still active and sends it to an event that reports more. 

Agent says: More awesome stuff about New York. 

User: Tell me about that first city instead. 

Dialogflow matches it against the same intent as before. 

Agent says: Sydney is pretty cool. 
Agent changes the "city" context so the parameter "current" -> "Sydney" and "previous" -> "New York". 

更新

このセットアップは良いDialogflowがよく何のバランス(メッセージを解析し、会話の現在の状態を判断)し、どのようなあなたのウェブフックは、(これらの質問に対するベストアンサーを決める)がよくありませんを打ちます。

はおそらくDialogflowの中でそれを多分するでしょうが、それは非常に非常に面倒です。それぞれの値の結果を個別に処理するために、複数のインテントを作成する必要があります。 Contextが存在する可能性のあるパラメータではなく、Contextの存在を照合するだけで済むので、都市ごとにContextを作成する必要があります(したがって、 "city_ny"と "city_sydney" Contextを持つことになります)。

webhook(私たちが現在持っている組み込みのフルフィルメントシステムさえも)を使用するほうがずっと良いでしょう。

+0

興味深い! Dialog Flow内でこれを行うことはできますか?これについてはWebhookサービスが必要ですか?つまり、どのようにDialogのフローが都市のコンテキスト配列内で '第2の都市 'を見つけることができるのですか?その上で入力コンテキストをどのように宣言できますか? –

+0

できますが...できません。 {:回答が更新されました。 – Prisoner

+0

ありがとうございます。だから私があなたを正しく理解しているかどうかをチェックさせてください。最初のサイクル( '興味深い都市とは何か?)では、Webhookサービスは' New York、Sydney、... 'と答えますが、この配列も出力コンテキストに置きます。次のサイクル(「第2都市についてもっと教えてください」)では、この配列は入力コンテキストとして提供されます。右?だから、私はwebhookサービスでコンテキストを維持していません - 代わりに、すべてが入力と出力のコンテキストで前後に置かれていますか? –

関連する問題