【发布时间】:2018-05-22 12:29:13
【问题描述】:
我想用 Dialogflow 和 Google Assistant 以及 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 操作最终用户满足交易要求来为用户构建购物车和订单。出于这个原因,按照谷歌文档,当Int3被触发时,我正在使用一个连接谷歌助手我的后端的网络钩子,它发回以下json(触发actions.intent.TRANSACTION_DECISION):
{
"fulfillmentText": "This is your order preview:",
"payload": {
"google": {
"expectUserResponse": true,
"isSsml": false,
"noInputPrompts": [],
"systemIntent": {
"data": {
"@type": "type.googleapis.com/google.actions.v2.TransactionDecisionValueSpec",
"orderOptions": {
"requestDeliveryAddress": true
},
"paymentOptions": {
"actionProvidedOptions": {
"displayName": "VISA **** **** **** 3235",
"paymentType": "PAYMENT_CARD"
}
},
"proposedOrder": {
"cart": {
"lineItems": [
{
"description": "Book",
"id": "1",
"name": "Book",
"price": {
"amount": {
"currencyCode": "USD",
"nanos": 0,
"units": 31
},
"type": "ACTUAL"
},
"quantity": 2,
"subLines": [],
"type": "REGULAR"
}
],
"merchant": {
"id": "Amazon",
"name": "Amazon"
},
"otherItems": []
},
"id": "<UNIQUE_ORDER_ID>",
"otherItems": [
{
"id": "Subtotal",
"name": "Subtotal",
"price": {
"amount": {
"currencyCode": "USD",
"nanos": 0,
"units": 62
},
"type": "ACTUAL"
},
"type": "SUBTOTAL"
},
{
"id": "Delivery fees",
"name": "Delivery fees",
"price": {
"amount": {
"currencyCode": "USD",
"nanos": 0,
"units": 10
},
"type": "ACTUAL"
},
"type": "FEE"
}
],
"totalPrice": {
"amount": {
"currencyCode": "USD",
"units": 72
},
"type": "ACTUAL"
}
}
},
"intent": "actions.intent.TRANSACTION_DECISION"
}
}
}
}
但是,我在 Google 助理模拟器上收到以下错误:
MalformedResponse
expected_inputs[0].possible_intents[0].input_value_data.transaction_decision_value_spec.proposed_order: subtotal price is not sum of regular lineItems. Expected-> Sum of line item price: units: 31 nanos: 0 currency: USD Actual-> Provided total price: units: 62 nanos: 0 currency: USD.
MalformedResponse
expected_inputs[0].possible_intents[0].input_value_data.transaction_decision_value_spec.proposed_order: total price is not sum of lineItems and otherItems. Expected-> Sum of line item price: units: 42 nanos: 0 currency: USD Actual-> Provided total price: units: 72 nanos: 0 currency: USD.
为什么我在相应的 lineItem 中指定了 "quantity": 2 后收到此错误?
很明显,小计应该是units: 62,因为我订购了"quantity": 2的产品,每个units: 31的价格...
最终的订单预览如下所示(这是从 Google 文档示例中借用的):
【问题讨论】:
标签: actions-on-google dialogflow-es