为什么不触发`actions.intent.TRANSACTION_DECISION`?

时间:2018-05-17 10:48:02

标签: actions-on-google dialogflow

我想用Dialogflow和Google智能助理以及Google Transactions API创建一个聊天机器人,以便用户订购一些商品。现在我的代理包含以下四个意图:

  • Default Welcome Intent(文字回复:你好,你想买一个巧克力盒吗?)
  • Default Fallback Intent
  • Int3(培训短语:是的,我想要,履行:启用webhook)
  • Int4(事件:actions_intent_TRANSACTION_DECISION,履行:已启用webhook)

我使用Dialogflow Json而不是Node.js将我的代理与Transactions API连接起来。我想通过使用Google操作的actions.intent.TRANSACTION_DECISION操作最终使用用户满足交易要求,为用户构建购物车和订单。出于这个原因,在Google文档之后,当Int3被触发时,我正在使用webhook连接Google Assistant我的后端发送回以下json(触发actions.intent.TRANSACTION_DECISION):

{
  "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文档中复制粘贴jsons。

但是,Int4未触发,这意味着actions.intent.TRANSACTION_DECISION也未被触发。

我只接受Google智能助理(当Int3被触发并且上述json作为我的后端的响应发送时)以下消息/错误:

Sorry, something went wrong. Please try again later.

因此,我无法真正理解我的json有什么问题以及为什么actions.intent.TRANSACTION_DECISION没有被触发。

为什么actions.intent.TRANSACTION_DECISION未被触发?上面的json有没有未检测到的问题?

我不知道我的问题是否与此有关:Actions on Google returns in simulator "We're sorry, but something went wrong. Please try again."。但是,我从这个链接测试了所有可能的解决方案,到目前为止我没有任何帮助。 此外,请注意,我已经触发了Google Transactions API(actions.intent.TRANSACTION_REQUIREMENTS_CHECKactions.intent.DELIVERY_ADDRESSactions.intent.SIGN_IN)的所有其他内置意图,并且它们都能正常运行我的代理/应用。出于某种原因,只有actions.intent.TRANSACTION_DECISION会将此错误(Sorry, something went wrong. Please try again later.)返回给我。

1 个答案:

答案 0 :(得分:2)

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

但是,我不确切地知道为什么这只发生在actions.intent.TRANSACTION_DECISION,而与其他Google Transactions API内置意图(actions.intent.TRANSACTION_REQUIREMENTS_CHECKactions.intent.DELIVERY_ADDRESS完全无关, actions.intent.SIGN_IN)。

具体来说,在Google操作系统中,在我选择了我的项目并登录了我的Google帐户后,我在以下位置填写了所有必需的详细信息:

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

完成并保存后,actions.intent.TRANSACTION_DECISION被按预期触发,我正在获得预期的&#34;购物车预览&#34;在Google智能助理上(在手机上)。

相关问题