3

我在这里拉我的头发。我有一个使用 Jovo 4 和 Google Actions Builder 构建的 Google Assistant 应用程序。

目标是创建一个 HelpScene,其中显示一些选项来解释应用程序在选择时的可能性/功能。这是我从 Webhook 返回的响应。(这是 Jovo 代码,但没关系,因为当助手调用 webhook 时它会返回 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 中的选项完美显示。但是,当我单击列表中的某个项目时,该应用程序就会停止工作。“YourApp 当前没有响应”。

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

任何想法我做错了什么?

提前致谢!

4

1 回答 1

0

好的,经过几天的搜索,我终于弄明白了。它确实与 Jovo 框架/设置和/或scene本机响应中的参数有关。

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

@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 和一个看起来像这样的 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,但首先给出有关所选选项的响应。

于 2022-02-23T15:32:12.703 回答