防止Amazon Echo在程序流程中启动

时间:2018-01-31 15:05:30

标签: amazon-web-services alexa alexa-skills-kit

我做了一个测验技巧,首先提示用户Alexa的回复,询问他们是否准备好继续。从那里,用户必须说是或否分别激活相应的AMAZON.YesIntentAMAZON.NoIntent。然后测验开始,用户说出答案信,然后是每个问题的答案。我使用服务器来模拟我的技能状态。

通常我会说:

开始我的技能
  

“Alexa,开始测验技巧”

但是,我发现使用服务器模拟状态并不能为Echo提供非常强大的语音界面。如果用户说:

  

“Alexa,问Quiz技能是的”

当亚马逊检测到AMAZON.YesIntent时,该技能将跳转到我设置的任何触发器。这不是我想要的!我希望用户遵循我设定的技能流程。

有没有办法控制什么时候可以激活意图?我的想法是使用属性来基本设置接下来可以调用的意图。

2 个答案:

答案 0 :(得分:1)

每个Alexa请求都有一个session object。该会话对象具有20180201 09:04:12.499 [restartedMain] INFO c.k.a.Application - Log info On 20180201 09:04:12.499 [restartedMain] WARN c.k.a.Application - Log warn On 20180201 09:04:12.499 [restartedMain] ERROR c.k.a.Application - Log error On 20180201 09:04:15.628 [RMI TCP Connection(9)-10.10.20.187] WARN o.s.b.a.h.ElasticsearchHealthIndicator - Health check failed org.elasticsearch.ElasticsearchTimeoutException: java.util.concurrent.TimeoutException: Timeout waiting for task. at org.elasticsearch.action.support.AdapterActionFuture.actionGet(AdapterActionFuture.java:71) at org.elasticsearch.action.support.AdapterActionFuture.actionGet(AdapterActionFuture.java:58) at org.springframework.boot.actuate.health.ElasticsearchHealthIndicator.doHealthCheck(ElasticsearchHealthIndicator.java:52) at org.springframework.boot.actuate.health.AbstractHealthIndicator.health(AbstractHealthIndicator.java:43) at org.springframework.boot.actuate.health.CompositeHealthIndicator.health(CompositeHealthIndicator.java:68) at org.springframework.boot.actuate.endpoint.HealthEndpoint.invoke(HealthEndpoint.java:85) at org.springframework.boot.actuate.endpoint.HealthEndpoint.invoke(HealthEndpoint.java:35) at org.springframework.boot.actuate.endpoint.jmx.DataEndpointMBean.getData(DataEndpointMBean.java:46) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:71) at sun.reflect.GeneratedMethodAccessor178.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:275) at javax.management.modelmbean.RequiredModelMBean$4.run(RequiredModelMBean.java:1252) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80) at javax.management.modelmbean.RequiredModelMBean.invokeMethod(RequiredModelMBean.java:1246) at javax.management.modelmbean.RequiredModelMBean.invoke(RequiredModelMBean.java:1085) at org.springframework.jmx.export.SpringModelMBean.invoke(SpringModelMBean.java:90) at javax.management.modelmbean.RequiredModelMBean.getAttribute(RequiredModelMBean.java:1562) at org.springframework.jmx.export.SpringModelMBean.getAttribute(SpringModelMBean.java:109) at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.getAttribute(DefaultMBeanServerInterceptor.java:647) at com.sun.jmx.mbeanserver.JmxMBeanServer.getAttribute(JmxMBeanServer.java:678) at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1445) at javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:76) at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1309) at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1401) at javax.management.remote.rmi.RMIConnectionImpl.getAttribute(RMIConnectionImpl.java:639) at sun.reflect.GeneratedMethodAccessor49.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:346) at sun.rmi.transport.Transport$1.run(Transport.java:200) at sun.rmi.transport.Transport$1.run(Transport.java:197) at java.security.AccessController.doPrivileged(Native Method) at sun.rmi.transport.Transport.serviceCall(Transport.java:196) at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:568) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:826) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:683) at java.security.AccessController.doPrivileged(Native Method) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:682) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) Caused by: java.util.concurrent.TimeoutException: Timeout waiting for task. at org.elasticsearch.common.util.concurrent.BaseFuture$Sync.get(BaseFuture.java:232) at org.elasticsearch.common.util.concurrent.BaseFuture.get(BaseFuture.java:67) at org.elasticsearch.action.support.AdapterActionFuture.actionGet(AdapterActionFuture.java:69) ... 47 common frames omitted 属性,该属性为true或false,具体取决于它是否是您的技能的全新会话。

如果您正在使用alexa-sdk节点模块来构建您的技能,您还可以使用new处理程序来捕获新会话并将流转移到您希望交互开始的事件/意图。有关状态处理程序的更多信息,请参见github页面here

答案 1 :(得分:1)

虽然我认为不可能启用/禁用意图,但您可以确定更改它们的响应方式。使用会话对象可以很容易地跟踪最后所说的内容。然后,您的意图处理程序可以读取会话对象,以查看先前的响应是什么,以便选择如何响应。

在上面的示例中,您可以将最后一个问题编号保存到会话对象中。如果“是”根据之前(或缺少)问题没有意义,那么你的YesIntent处理程序可以回答“我很抱歉,我不知道该怎么做”,甚至可能只是忽略它并从头开始对话。