0

我有一个可以在 AWS 控制台中完美运行的机器人。

我试图让它在使用 AWS MobileHub 的移动应用程序中运行,但效果不佳,我不知道为什么我完全被卡住了。

描述:我提出一个项目名称的请求,以获取该项目的任务列表。但首先我必须连接。“连接”请求从我的后端获取一个令牌并将其放入sessionAttributes中。其他请求必须在sessionAttributes中包含此令牌,否则机器人将要求进行身份验证。

该工作流程适用于 AWS 控制台机器人:

  1. 请求“项目 123 的任务” -> 回答“您必须进行身份验证”
  2. 请求“连接” -> 回答“您现在已连接”
  3. 请求“项目 123 的任务” -> 回答“项目 123 的任务是 4、8、11。选择一个任务以获取详细信息。”

现在应用程序会发生什么,在文本模式下:

  1. 请求“项目 123 的任务” -> 回答“您必须进行身份验证”
  2. 请求“连接” -> 无应答
  3. 请求“项目 123的任务”-> 应用程序崩溃

在第 3 步登录 Android Studio(崩溃):

06-28 11:05:58.942 1719-1719/com.amazon.mysampleapp E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.amazon.mysampleapp, PID: 1719
Theme: themes:{default=overlay:com.cyngn.hexo, iconPack:com.cyngn.hexo, fontPkg:com.cyngn.hexo, com.android.systemui=overlay:com.cyngn.hexo, com.android.systemui.navbar=overlay:com.cyngn.hexo}
java.lang.NullPointerException: Attempt to invoke virtual method 'void com.amazonaws.mobileconnectors.lex.interactionkit.continuations.LexServiceContinuation.continueWithTextInForTextOut(java.lang.String)' on a null object reference
at com.mysampleapp.demo.bots.ConversationalBotTextFragment.textEntered(ConversationalBotTextFragment.java:135)
at com.mysampleapp.demo.bots.ConversationalBotTextFragment.access$000(ConversationalBotTextFragment.java:42)
at com.mysampleapp.demo.bots.ConversationalBotTextFragment$1.onKey(ConversationalBotTextFragment.java:86)
at android.view.View.dispatchKeyEvent(View.java:9236)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1640)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1640)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1640)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1640)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1640)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1640)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1640)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1640)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1640)
at com.android.internal.policy.PhoneWindow$DecorView.superDispatchKeyEvent(PhoneWindow.java:2651)
at com.android.internal.policy.PhoneWindow.superDispatchKeyEvent(PhoneWindow.java:1777)
at android.app.Activity.dispatchKeyEvent(Activity.java:2731)
at android.support.v7.app.AppCompatActivity.dispatchKeyEvent(AppCompatActivity.java:543)
at android.support.v7.view.WindowCallbackWrapper.dispatchKeyEvent(WindowCallbackWrapper.java:53)
at android.support.v7.app.AppCompatDelegateImplBase$AppCompatWindowCallbackBase.dispatchKeyEvent(AppCompatDelegateImplBase.java:312)
at android.support.v7.view.WindowCallbackWrapper.dispatchKeyEvent(WindowCallbackWrapper.java:53)
at com.android.internal.policy.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:2363)
at android.view.ViewRootImpl$ViewPostImeInputStage.processKeyEvent(ViewRootImpl.java:4135)
at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4097)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3650)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3703)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3669)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3795)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3677)
at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3852)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3650)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3703)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3669)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3677)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3650)
at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:5932)
at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:5906)
at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:5867)
at android.view.ViewRootImpl$ViewRootHandler.handleMessage(ViewRootImpl.java:3442)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5461)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
06-28 11:05:58.944 789-3750/? W/ActivityManager: Force finishing activity com.amazon.mysampleapp/com.mysampleapp.MainActivity

在这里使用移动应用程序上的语音:

  1. 请求“项目 123 的任务” -> 回答“您必须进行身份验证”
  2. 请求“连接” -> 回答“您现在已连接”
  3. 请求“项目 123 的任务” -> 回答“您必须进行身份验证”

在第 1 步和第 3 步登录 Android Studio:

06-28 11:24:15.227 4265-4265/com.amazon.mysampleapp E/Lex: InteractiveVoiceViewAdapter: Interaction error
com.amazonaws.mobileconnectors.lex.interactionkit.exceptions.DialogFailedException: Failed to fulfill current request.
at com.amazonaws.mobileconnectors.lex.interactionkit.InteractionClient$8.run(InteractionClient.java:593)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5461)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
06-28 11:24:15.227 4265-4265/com.amazon.mysampleapp E/ConversationalBotVoice: Error: You must authenticate.
com.amazonaws.mobileconnectors.lex.interactionkit.exceptions.DialogFailedException: Failed to fulfill current request.
at com.amazonaws.mobileconnectors.lex.interactionkit.InteractionClient$8.run(InteractionClient.java:593)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5461)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

所以我尝试更改 lambda,所以我不需要连接部分(但它仍然使用请求的令牌,我只是在 lambda 中编写了令牌,而不是从后端获取它)。

  • 在 AWS 控制台中,我得到了任务列表
  • 在带有文本的移动设备上,我得到了任务列表
  • 手机有语音不行

最后一种情况的日志:

06-28 11:38:40.619 7655-7655/com.amazon.mysampleapp E/Lex: InteractiveVoiceViewAdapter: Interaction error
com.amazonaws.services.lexrts.model.DependencyFailedException: Received error response from Lambda: Handled (Service: AmazonLexRuntime; Status Code: 424; Error Code: DependencyFailedException; Request ID: 8f30ae21-5be5-11e7-bc7b-8d61d03f20da)
at com.amazonaws.http.AmazonHttpClient.handleErrorResponse(AmazonHttpClient.java:729)
at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:405)
at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:212)
at com.amazonaws.services.lexrts.AmazonLexRuntimeClient.invoke(AmazonLexRuntimeClient.java:651)
at com.amazonaws.services.lexrts.AmazonLexRuntimeClient.postContent(AmazonLexRuntimeClient.java:450)
at com.amazonaws.mobileconnectors.lex.interactionkit.InteractionClient$2.run(InteractionClient.java:375)
at java.lang.Thread.run(Thread.java:818)
06-28 11:38:40.620 7655-7655/com.amazon.mysampleapp E/ConversationalBotVoice: Error: Error from Bot
com.amazonaws.services.lexrts.model.DependencyFailedException: Received error response from Lambda: Handled (Service: AmazonLexRuntime; Status Code: 424; Error Code: DependencyFailedException; Request ID: 8f30ae21-5be5-11e7-bc7b-8d61d03f20da)
at com.amazonaws.http.AmazonHttpClient.handleErrorResponse(AmazonHttpClient.java:729)
at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:405)
at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:212)
at com.amazonaws.services.lexrts.AmazonLexRuntimeClient.invoke(AmazonLexRuntimeClient.java:651)
at com.amazonaws.services.lexrts.AmazonLexRuntimeClient.postContent(AmazonLexRuntimeClient.java:450)
at com.amazonaws.mobileconnectors.lex.interactionkit.InteractionClient$2.run(InteractionClient.java:375)
at java.lang.Thread.run(Thread.java:818)

我不知道该怎么做,我什至不知道如何记录事情,如何检查从应用程序发送到 Lex 的内容以及 Lex 发回的内容。谢谢你的帮助。

4

0 回答 0