Dialogflow: Respond based on values and other conditional responses

谁说我不能喝 提交于 2019-12-01 17:23:12

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.

but not

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

or anything like that

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.

Late reply, but maybe someone will find this useful.

If the conditional response only needs to reference a single parameter value, then I figured out what you can do is utilize the Entity's "Reference Value" as the response you want to give for a particular set of Synonyms.

So you'd have an entity that looked like this:

Then, setup your intent like this, with a response of $Dinetype:

Then the end result will look like this:

And you can make whatever follow-up intent you need from there.

Down-side is Dinetype won't be as reusable. But I still think it beats writing a fulfillment webhook every time you need a simple conditional response.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!