Dialogflow: Respond based on values and other conditional responses

前端 未结 2 547
眼角桃花
眼角桃花 2021-01-02 02:46

I have $dinetype variable obtained from the user.

But I would like to give response based on what value has been set in $dinetype

2条回答
  •  滥情空心
    2021-01-02 03:19

    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.

提交回复
热议问题