Dialogflow:根据值和其他条件响应进行响应 [英] Dialogflow: Respond based on values and other conditional responses

查看:125
本文介绍了Dialogflow:根据值和其他条件响应进行响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从用户那里获得了$dinetype变量.

I have $dinetype variable obtained from the user.

但是我想根据在$dinetype变量中设置的值给出响应.除了做出回应之外,我还需要设置相关的上下文.如何在DialogFlow中做到这一点?

But I would like to give response based on what value has been set in $dinetype variable. In addition to giving responses, I also need to set relevant context. How do I do this in DialogFlow?

if($Dinetype=='dineout') 
      ask ('which restaurant would you like to go to?')
      set_context ('awaiting-restaurant')
if($Dinetype=='takeaway') 
      ask ('When would you like to take away?')
      set_context ('awaiting-takeaway-time')

它完全可编程吗?还是可以在用户界面中实现与以上相同的功能?

Is it programmable at all? Or is it possible to achieve something equivalent to the above in the UI?

推荐答案

您不能直接在响应"部分中执行此操作. 响应"部分用于不需要非常大的逻辑即可处理的相当简单的响应.尽管您可以在响应中使用参数,但是您不能基于参数的值给出不同的响应.因此,您可以将响应设置为

You can't do this in the Response section directly. The Response section is meant for fairly simple responses that don't require significant logic to process. Although you can use parameters in the response, you can't give a different response based on the value of the parameter. So you can set a response to something like

I think $Dinetype is great food.

但不是

{{#if $Dinetype == "Thai"}}I think Thai food is too hot{{/if}}

或类似的东西

但是,您可以通过实现实现 Webhook来添加发送条件响应和上下文的代码.尽管您无法在意图编辑器"屏幕的一部分中为每个意图"执行此操作,但实现"屏幕包含内置的代码编辑器.

However, you can add code that sends conditional responses and contexts by implementing a Fulfillment webhook. Although you can't do this for each Intent as part of the Intent editor screen, the Fulfillment screen includes a built-in code editor.

这篇关于Dialogflow:根据值和其他条件响应进行响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆