Как предоставить динамический c ответ для выбранной сущности в качестве параметра при выполнении диалогового потока - PullRequest
0 голосов
/ 29 февраля 2020

У меня есть сущность (предметы), и ее значения («имя», «цвет», «награды»)

У меня три намерения

Intent1 = Welcome Intent (user will get the options in the form of chips)
Intent2 = Select Option (bot will ask question to enter detail for selected option)
Intent3 = Update Option (bot will save the record and ask next option to update.)

Example - 
bot: welcome! what you want to update? name, colour, awards.
user: name
bot: Enter your name.
user: John
bot: record updated, what to update next? name, colour, awards.

Теперь проблема в том, Награды имеют несколько полей для обновления, чтобы обновить награды, пользователь должен предоставить три вещи (название награды, дата награды, описание награды)

Что я хочу, это когда пользователь выбирает опции награды из фишек, то это должно быть в новом намерении, где я получу все данные через заполнение слотов.

1 Ответ

0 голосов
/ 02 марта 2020

Первое, что нужно запомнить, это то, что Намерение представляет то, что пользователь сказал , а , а не , что вы делаете с тем, что он сказал. Поэтому не имеет смысла говорить, что вы «идете к намерению».

Во-вторых, хотя заполнение слотов кажется хорошей идеей, оно обычно приводит к дальнейшим проблемам, поскольку не обрабатывает условные выражения. хорошо информировать или обращаться с пользователями, если они пропускают то, что хотят обновить.

Все это лучше решить, настроив конечный автомат, где они находятся в разговоре, какая информация вам нужна и что они предоставили до сих пор. Основываясь на этих настройках, вы можете сами запросить их, что вы ожидаете дальше. (Вы также можете использовать один или несколько контекстов Dialogflow, полезных для определения того, как принимать результаты.)

Так, например, когда пользователь указал, что он обновляет награды, он может работать так:

User: Awards
[Your fulfillment sets the 'awards' context with a parameter that we are prompting for the name.]
Bot: Ok, I'm going to need the award name, description, and when it was awarded. What is the name?

User: Merit
[This matches the Fallback Intent with an Input Context for 'awards', since it is free-form input. Your fulfillment stores this and sets the 'awards' context with a parameter that we are now prompting for the date.]
Bot: Got it, the award is named Merit. When was it awarded?

User: Today
[This matches an Intent with a training phrase of "<@sys.date>" and the Input Context of 'awards'. There are also training phrases for things like "It was awarded <@sys.date>" and so forth. Your fulfillment sets the date and sets the 'awards' context with a parameter that we're now prompting for description.]
Bot: Got it. Awarded on March 1st. What is the description?

User: They were awesome.
[This matches the Fallback Intent with the Input Context of 'awards' again, because it is still free-form input. Our fulfillment, however, knows that this is about the description this time, so it stores it and removes the 'awards' context since we've captured everything.]
Bot: I've recorded that as a description of "they were awesome" - sure thing. That was everything we needed for now. Do you want to update the name, colour, or awards next?

Все это кажется довольно простым. Но подумайте, пошел ли разговор следующим образом:

User: Awards
[Your fulfillment sets the 'awards' context with a parameter that we are prompting for the name.]
Bot: Ok, I'm going to need the award name, description, and when it was awarded. What is the name?

User: [Having done this many times] They were given the award for Honor yesterday
[This might match an Intent with an Input Context of 'awards' and the training phrase of "Given the award for <@sys.any> <@sys.date>" and possibly "<@sys.date> they got an award for <@sys.any>". Your fulfillment sets the name and date from this, sees what information it still needs, and prompts with...]
Bot: Got it. Award named Honor. Awarded March 1. What is the description?

User: Actually, it is named Honorable Service
[This matches an Intent with a training phrase of "named <@sys.any>" and an Input Context for 'awards'. Your fulfillment changes the name stored, checks what we still need, and again prompts...]
Bot: Ok, I've changed the award name to Honorable Service. What is the description?

Первый сценарий может быть обработан заполнением слотов и простым запросом, а второй - нет. Способность обрабатывать более естественные ответы от людей и более гибкие подсказки будет лучше для ваших пользователей.

...