Watson conversation 沃森会话语境

Watson conversation 沃森会话语境,watson-conversation,watson-dialog,Watson Conversation,Watson Dialog,我目前正在使用watson聊天机器人对话应用程序。我遇到了一种情况,我必须刷新上下文,只是在某个阶段取决于用户输入,但我一直无法实现这一点 I tried setting the context = {}, if the user input isn't in the Array, but it seems to check the context at every stage of the Application. if(context.city !== array[i]['city'])

我目前正在使用watson聊天机器人对话应用程序。我遇到了一种情况,我必须刷新上下文,只是在某个阶段取决于用户输入,但我一直无法实现这一点

I tried setting the context = {}, if the user input isn't in the Array, but it seems to check the context at every stage of the Application. 

if(context.city !== array[i]['city']){
        context = {};
 }

what i am asking the user is to input a list of cities, which is in an Array. If the user inputs a location that isn't in the Array first, it let's the user know that it isn't in the Array. If the user inputs a city that is not in the Array after inputing a city that is already in the array, it is returning the last context. 

for example,

City = Boston.
You just input Boston, price is 20.
Then if i do City = Atlanta(Bearing in mind Atlanta is not in the Array)
it does city is Atlanta, price is 20. 

Any idea how to fix this, on any steps i can follow to stop this from happening?

您可以在应用程序或高级编辑器中将context.city设置为空字符串或null 然后在您的应用程序中,基于(var i=0;i for(var i = 0; i < array.length; i++){ if (context.city !== array[i]['city']){ if(inputBox.value === context.city) { context = latestResponse.context; context.rate = rate; context.currency = currency; } else { context.city = ""; context.rate = ""; context.currency = ""; } } } if(context.city!==数组[i]['city']){ if(inputBox.value==context.city) { context=latestResponse.context; context.rate=速率; context.currency=货币; } 其他的 { context.city=“”; context.rate=“”; context.currency=“”; } } } 对于现在或将来可能遇到同样问题的其他人


这就是我解决问题的原因。所需的信息在一个数组中,所以我在上面循环,并检查context.city!=数组

谢谢,我在发布这篇文章10分钟后就想出了一个办法。非常感谢。