多次使用app.ask功能 [英] Using app.ask more than once function

查看:153
本文介绍了多次使用app.ask功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的函数中,我想多次使用 app.ask(’blah blah blah’); 。但是,在测试它时,只说了第一个 app.ask(),我希望它也能说出第二个响应。

Within my function I would like to use app.ask('blah blah blah'); more than once. However when testing it, only the first app.ask() is spoken for which I expected it to also speak out the 2nd response too.

该函数看起来像这样:

for(var i = 0; i < array.length; i++) {
    if (array == ##) {
      app.ask(response 1)
    } else {
      app.ask(response 2)
    }
}


推荐答案

是正确的-您只能使用 app.ask()一次,因为这会将响应发送给用户。将响应发送给用户后,您必须等待用户答复后才能发送其他内容。

That is correct - you can only use app.ask() once since that will send the response to the user. Once you send the response to the user, you must wait for the user to reply before you can send something else.

您需要在循环中构建响应,然后然后将其发送给用户。

You would need to build your response in the loop and then send this to the user. Something like this

var response = '';
for(var i = 0; i < array.length; i++) {
    if (array == ##) {
      response += ' Message 1.';
    } else {
      response += ' Message 2.';
    }
}
app.ask( response );

这篇关于多次使用app.ask功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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