Google 从列表中选择可视项时,Actions Builder 停止执行

Google Actions Builder stops execution when selecting a visual item from a List

我在这里紧张不安。我有一个使用 Jovo 4 和 Google Actions Builder 构建的 Google 助手应用程序。

目标是创建一个 HelpScene,它显示了一些选项,这些选项解释了选择应用程序的 possibilities/features。 这是我 return 来自我的 Webhook 的响应。 (这是 Jovo 代码,但并不重要,因为当 Google 助理调用 webhook 时,return 是 JSON。)

@Handle(GoogleAssistantHandles.onScene('HelpScene'))
  showHelpList() {
    return this.$send({
      platforms: {
        googleAssistant: {
          nativeResponse: {
            scene: {
              name: this.jovo.$googleAssistant?.$request.scene?.name,
              slots: {},
              next: {
                name: 'MainScene',
              },
            },
            session: {
              id: 'session_id',
              languageCode: 'nl-BE',
              params: {},
              typeOverrides: [
                {
                  name: 'prompt_option',
                  synonym: {
                    entries: [
                      {
                        name: 'ITEM_1',
                        synonyms: ['Item 1', 'First item'],
                        display: {
                          title: 'Item #1',
                          description: 'Description of Item #1',
                          image: {
                            alt: 'Google Assistant logo',
                            height: 0,
                            url: 'https://developers.google.com/assistant/assistant_96.png',
                            width: 0,
                          },
                        },
                      },
                      {
                        name: 'ITEM_2',
                        synonyms: ['Item 2', 'Second item'],
                        display: {
                          title: 'Item #2',
                          description: 'Description of Item #2',
                          image: {
                            alt: 'Google Assistant logo',
                            height: 0,
                            url: 'https://developers.google.com/assistant/assistant_96.png',
                            width: 0,
                          },
                        },
                      },
                      {
                        name: 'ITEM_3',
                        synonyms: ['Item 3', 'Third item'],
                        display: {
                          title: 'Item #3',
                          description: 'Description of Item #3',
                          image: {
                            alt: 'Google Assistant logo',
                            height: 0,
                            url: 'https://developers.google.com/assistant/assistant_96.png',
                            width: 0,
                          },
                        },
                      },
                      {
                        name: 'ITEM_4',
                        synonyms: ['Item 4', 'Fourth item'],
                        display: {
                          title: 'Item #4',
                          description: 'Description of Item #4',
                          image: {
                            alt: 'Google Assistant logo',
                            height: 0,
                            url: 'https://developers.google.com/assistant/assistant_96.png',
                            width: 0,
                          },
                        },
                      },
                    ],
                  },
                  typeOverrideMode: 'TYPE_REPLACE',
                },
              ],
            },
            prompt: {
              override: false,
              content: {
                collection: {
                  items: [
                    {
                      key: 'ITEM_1',
                    },
                    {
                      key: 'ITEM_2',
                    },
                    {
                      key: 'ITEM_3',
                    },
                    {
                      key: 'ITEM_4',
                    },
                  ],
                  subtitle: 'List subtitle',
                  title: 'List title',
                },
              },
              firstSimple: {
                speech: 'This is a list.',
                text: 'This is a list.',
              },
            },
          },
        },
      },
    });

我创建了一个 HelpScene,它从我的 webhook 中提取我的选项。

在我的槽填中,是这样配置的。

当我使用模拟器时,我的 webhook 中的选项可以完美显示。 但是当我点击列表中的一个项目时,应用程序就停止工作了。 “您的应用目前没有响应”。

起初我认为这与我的 webhook 有关,所以我更改了“插槽已填充”条件的行为,它应该直接从 Google Actions Builder 提示一些东西,但是该行为仍然不是我们想要的:应用程序刚刚停止工作。

知道我做错了什么吗?

提前致谢!

好吧,找了几天,终于搞明白了。 它确实与本机响应中的 Jovo framework/setup and/or scene 参数有关。

这是我的组件,我在其中将新用户重定向到 HelpScene。此场景应在 list/collection/whatever 中显示多张卡片,用户可以点击卡片以接收有关应用程序功能的更多信息。

@Component()
export class WelcomeComponent extends BaseComponent {
  async START(): Promise<void> {
    const isNewUser = true;
    if (isNewUser && this.$device.supports(Capability.Screen)) {
      return this.$send(NextSceneOutput, {
        name: 'HelpScene',
        message: 'Hi, I noticed you are a new user, let me walk you through some options.',
      });
    }

    return this.$send('Welcome!');
  }

  @Handle(GoogleAssistantHandles.onScene('HelpScene'))
  help() {
    const sessionData = this.$request.getSession();
    if (sessionData && sessionData.prompt_option) {
      return this.$send(NextSceneOutput, {
        name: 'MainScene',
        message: `You picked option ${sessionData.prompt_option}. This is some info about it ... What do you want to do now?`,
      });
    }

    return this.$send({
      platforms: {
        googleAssistant: {
          nativeResponse: {
            session: {
              id: 'session_id',
              languageCode: '',
              params: {},
              typeOverrides: [
                {
                  name: 'HelpOptionType',
                  typeOverrideMode: 'TYPE_REPLACE',
                  synonym: {
                    entries: [
                      {
                        name: 'ITEM_1',
                        synonyms: ['Item 1', 'First item'],
                        display: {
                          title: 'Item #1',
                          description: 'Description of Item #1',
                          image: {
                            alt: 'Google Assistant logo',
                            height: 0,
                            url: 'https://developers.google.com/assistant/assistant_96.png',
                            width: 0,
                          },
                        },
                      },
                      {
                        name: 'ITEM_2',
                        synonyms: ['Item 2', 'Second item'],
                        display: {
                          title: 'Item #2',
                          description: 'Description of Item #2',
                          image: {
                            alt: 'Google Assistant logo',
                            height: 0,
                            url: 'https://developers.google.com/assistant/assistant_96.png',
                            width: 0,
                          },
                        },
                      },
                      {
                        name: 'ITEM_3',
                        synonyms: ['Item 3', 'Third item'],
                        display: {
                          title: 'Item #3',
                          description: 'Description of Item #3',
                          image: {
                            alt: 'Google Assistant logo',
                            height: 0,
                            url: 'https://developers.google.com/assistant/assistant_96.png',
                            width: 0,
                          },
                        },
                      },
                      {
                        name: 'ITEM_4',
                        synonyms: ['Item 4', 'Fourth item'],
                        display: {
                          title: 'Item #4',
                          description: 'Description of Item #4',
                          image: {
                            alt: 'Google Assistant logo',
                            height: 0,
                            url: 'https://developers.google.com/assistant/assistant_96.png',
                            width: 0,
                          },
                        },
                      },
                    ],
                  },
                },
              ],
            },
            prompt: {
              override: false,
              content: {
                list: {
                  items: [
                    {
                      key: 'ITEM_1',
                    },
                    {
                      key: 'ITEM_2',
                    },
                    {
                      key: 'ITEM_3',
                    },
                    {
                      key: 'ITEM_4',
                    },
                  ],
                  subtitle: 'List subtitle',
                  title: 'List title',
                },
              },
              firstSimple: {
                speech: 'This is a list.',
                text: 'This is a list.',
              },
            },
          },
        },
      },
    });
  }

  // ...other intents...

在 AoG 中,我制作了 2 个场景,1 个用户进入应用程序的 MainScene 和 1 个 HelpScene,看起来像这样(yaml 配置)。 HelpScene 的目标只是用于填充不同选项的插槽,然后用户应该返回 MainScene。

"conditionalEvents":
  - "condition": "scene.slots.status == \"FINAL\""
    "handler":
      "webhookHandler": "Jovo"
"slots":
  - "commitBehavior":
      "writeSessionParam": "prompt_option"
    "name": "prompt_option"
    "promptSettings":
      "initialPrompt":
        "webhookHandler": "Jovo"
    "required": true
    "type":
      "name": "HelpOptionType"

正如您在我的 help() 方法中看到的那样,我只检查会话参数是否已填写。如果是,我将用户重定向到 MainScene,但首先给出有关所选选项的响应。