简体   繁体   English

如何在对话流实现中使用 OR 运算符

[英]How to use OR operator in dialogflow fulfillment

I have a list of 4 phone's and I am using OR operator but it is not working properly我有 4 部电话的列表,我正在使用 OR 接线员,但它无法正常工作

this is my code这是我的代码

app.intent(SHOW_PHONE_INTENT, (conv) => {
  conv.contexts.set(AppContexts.AWAITING_PHONE, 1);
  conv.ask("Here's the list of phone's.");
  conv.ask(new List(PhoneList));
});

app.intent(SELECTED_PHONE_INTENT, (conv, input, option) => {
    const context = conv.contexts.get(AppContexts.AWAITING_PHONE);
    conv.contexts.set(AppContexts1.AWAITING_REPLY, 1, {phone: option});

    if (option === 'Phone1' || 'Phone2'){
      conv.ask(`${option} is in stock. Do you want to add it to your cart.`); 
    } else if (option === 'Phone3'){
      conv.ask(`${option} is out of stock. Would you like to order other products`);
    } else if (option === 'Phone4'){
      conv.ask(`${option} will be launched 1 week later. Would you like to register for this`);
    }
});

but when I select Phone4 or Phone3 then also it is returning response of option1但是当我选择 Phone4 或 Phone3 时,它也会返回 option1 的响应

conv.ask(`${option} is in stock. Do you want to add it to your cart.`);

Am I doing something wrong难道我做错了什么

请将条件语句更改为此。

if (option === 'Phone1' || option === 'Phone2')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用dialogflow-fulfillment-nodejs与Express - How use dialogflow-fulfillment-nodejs with Express 如何使用Node.js或Python在对话框流实现中使用custom_payload - How to use custom_payload in dialogflow fulfillment using nodejs or python 如何在 Dialogflow 实现内联中多次使用 web 抓取? 以及如何在履行内联代码中检测错误? - How to use multiple time web scraping in Dialogflow fulfillment inline? and how to detect error at fulfillment inline code? 如何制作多语言Dialogflow Webhook /实现? - How to make a multiple language Dialogflow webhook/fulfillment? 如何使用 nodejs 在 Dialogflow 中处理 webhook 实现 - How to handle webhook fulfillment in Dialogflow using nodejs 如何通过代码在DialogFlow实现中创建意图? - How to create intent in DialogFlow Fulfillment by code? 如何在 Dialogflow 实现中创建卡片响应? - How to create Card response in Dialogflow fulfillment? google-actions-如何在nodejs中的Promise中使用mongo-on-google库在对话框流实现中进行mongodb查询? - How to use Promise in node js for mongodb query in dialogflow fulfillment with actions-on-google library? 我们可以在对话流实现中使用带有确认事件的 SSML 标签吗 - can we use SSML tags with confirmation event in dialogflow fulfillment 实现中的DialogFlow-未定义DeepLink - DialogFlow in Fulfillment - DeepLink is not defined
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM