代码之家  ›  专栏  ›  技术社区  ›  Outcast

为什么要采取行动。意图是否未触发事务\u决策?

  •  0
  • Outcast  · 技术社区  · 7 年前

    我想创建一个带有Dialogflow和Google Assistant以及Google Transactions API的聊天机器人,让用户能够订购一些物品。目前,我的代理包含以下四个意图:

    • Default Welcome Intent (短信回复:你好,你想买巧克力盒吗?)
    • Default Fallback Intent
    • Int3 (培训短语:Yes,I want,performation:enabled webhook)
    • Int4 (事件: actions_intent_TRANSACTION_DECISION ,实现:启用webhook)

    我使用的是Dialogflow Json,而不是Node。js将我的代理与事务API连接起来。我想通过使用finally为用户构建购物车和订单,以确保用户通过使用 actions.intent.TRANSACTION_DECISION 谷歌行动的行动。因此,在谷歌文档之后 Int3 我正在使用一个webhook连接Google Assistant我的后端,它会发回以下json(用于触发 行动。意图交易决策 ) :

    {
      "payload": {
        "google": {
          "expectUserResponse": true,
          "isSsml": false,
          "noInputPrompts": [],
          "systemIntent": {
            "data": {
              "@type": "type.googleapis.com/google.actions.v2.TransactionDecisionValueSpec",
              "orderOptions": {
                "requestDeliveryAddress": false
              },
              "paymentOptions": {
                "actionProvidedOptions": {
                  "displayName": "VISA-1234",
                  "paymentType": "PAYMENT_CARD"
                }
              },
              "proposedOrder": {
                "cart": {
                  "lineItems": [
                    {
                      "id": "My Memoirs",
                      "name": "memoirs_1",
                      "price": {
                        "amount": {
                          "currencyCode": "USD",
                          "nanos": 990000000,
                          "units": 3
                        },
                        "type": "ACTUAL"
                      },
                      "quantity": 1,
                      "subLines": [
                        {
                          "note": "Note from the author"
                        }
                      ],
                      "type": "REGULAR"
                    },
                    {
                      "id": "Memoirs of a person",
                      "name": "memoirs_2",
                      "price": {
                        "amount": {
                          "currencyCode": "USD",
                          "nanos": 990000000,
                          "units": 5
                        },
                        "type": "ACTUAL"
                      },
                      "quantity": 1,
                      "subLines": [
                        {
                          "note": "Special introduction by author"
                        }
                      ],
                      "type": "REGULAR"
                    },
                    {
                      "id": "Their memoirs",
                      "name": "memoirs_3",
                      "price": {
                        "amount": {
                          "currencyCode": "USD",
                          "nanos": 750000000,
                          "units": 15
                        },
                        "type": "ACTUAL"
                      },
                      "quantity": 1,
                      "type": "REGULAR"
                    },
                    {
                      "id": "Our memoirs",
                      "name": "memoirs_4",
                      "price": {
                        "amount": {
                          "currencyCode": "USD",
                          "nanos": 490000000,
                          "units": 6
                        },
                        "type": "ACTUAL"
                      },
                      "quantity": 1,
                      "type": "REGULAR"
                    }
                  ],
                  "merchant": {
                    "id": "book_store_1",
                    "name": "Book Store"
                  },
                  "notes": "The Memoir collection",
                  "otherItems": []
                },
                "id": "<UNIQUE_ORDER_ID>",
                "otherItems": [
                  {
                    "id": "Subtotal",
                    "name": "subtotal",
                    "price": {
                      "amount": {
                        "currencyCode": "USD",
                        "nanos": 220000000,
                        "units": 32
                      },
                      "type": "ESTIMATE"
                    },
                    "type": "SUBTOTAL"
                  },
                  {
                    "id": "Tax",
                    "name": "tax",
                    "price": {
                      "amount": {
                        "currencyCode": "USD",
                        "nanos": 780000000,
                        "units": 2
                      },
                      "type": "ESTIMATE"
                    },
                    "type": "TAX"
                  }
                ],
                "totalPrice": {
                  "amount": {
                    "currencyCode": "USD",
                    "nanos": 0,
                    "units": 35
                  },
                  "type": "ESTIMATE"
                }
              }
            },
            "intent": "actions.intent.TRANSACTION_DECISION"
          }
        }
      }
    }
    

    请注意,我实际上是在复制粘贴Google文档中的JSON。

    然而 Int4 未触发,这意味着 行动。意图交易决策 也不会触发。

    我只在谷歌助手(当 Int3 触发,并从我的后端将上述json作为响应发送)以下消息/错误:

    Sorry, something went wrong. Please try again later.
    

    因此,我无法真正理解json中的错误及其原因 行动。意图交易决策 未触发。

    为什么? 行动。意图交易决策 是否未触发?上面的json是否有未发现的问题?

    我不知道我的问题是否与此有关: Actions on Google returns in simulator "We're sorry, but something went wrong. Please try again." .然而,我测试了此链接中所有可能的解决方案,到目前为止,没有任何解决方案真正适合我。 另外,请记住,我已经触发了Google Transactions API的所有其他内置意图( actions.intent.TRANSACTION_REQUIREMENTS_CHECK ,则, actions.intent.DELIVERY_ADDRESS ,则, actions.intent.SIGN_IN )它们都可以与我的代理/应用程序配合使用。只是出于某种原因 行动。意图交易决策 返回此错误( Sorry, something went wrong. Please try again later. )对我来说。

    1 回复  |  直到 7 年前
        1
  •  1
  •   Outcast    7 年前

    最后我解决了这个问题。从某种意义上说,这与我上面帖子的最后一段有关。我的意思是,它与测试这个应用程序所需的一些配置/权限有关,而不是与我的json等有关。

    然而,我不知道为什么只有 actions.intent.TRANSACTION_DECISION 与谷歌交易API的其他内置意图完全不同( actions.intent.TRANSACTION_REQUIREMENTS_CHECK ,则, actions.intent.DELIVERY_ADDRESS ,则, actions.intent.SIGN_IN ).

    具体而言,在Google Actions,在我选择我的项目并登录我的Google帐户后,我在以下位置填写了所有必需的详细信息:

    left sidebar -> DEPLOY -> Directory information -> (Details, Image, Contact Details, Privacy and consent, Additional Information)
    

    在我完成并保存此 行动。意图交易决策 按预期触发,我在谷歌助手(手机上)上获得了预期的“购物车预览”。

    推荐文章