I want to create a chatbot with Dialogflow and Google Assistant along with Google Transactions API for enabling a user to order some items. For now my agent contains the following four intents:
Default Welcome Intent
(text response: Hello, do you want to buy a chocolate box?)Default Fallback Intent
Int3
(training phrase: Yes, I want, fulfilment: enabled webhook)Int4
(event:actions_intent_TRANSACTION_DECISION
, fulfilment: enabled webhook)
I am using Dialogflow Json instead of Node.js to connect my agent with Transactions API. I want to build a cart and an order for the user by using finally that the user meets the transaction requirements by using the actions.intent.TRANSACTION_DECISION
action of Google actions. For this reason, following Google docs, when Int3
is triggered I am using a webhook which connect Google Assistant my back-end which sends back the following json to trigger actions.intent.TRANSACTION_DECISION
.
As a result, the preview of the order is presented to the user on Google Assistant (on mobile phone). However, the delivery address details are not presented on this order preview as at the photo below.
Let me note that I have already gone to Google Assistant app
-> Settings
-> Payments
and there I filled in my address details. As a result, when I trigger the actions.intent.DELIVERY_ADDRESS
intent then as expected I get the delivery address of Google Assistant app
-> Settings
-> Payments
as this is shown at this image: Image. Therefore, it is not that I anticipated that my delivery address will appear on the order preview out of nowhere without having set it first of all.
I have the impression that this can be done by adding the extension object
to the whole structure of ProposedOrder object
which is the following:
{ "id": string,
"cart": {
object(Cart) },
"otherItems": [
{
object(LineItem)
} ], "image": {
object(Image) },
"termsOfServiceUrl": string,
"totalPrice": {
object(Price) },
"extension": {
"@type": string,
field1: ...,
... } }
So the whole json response through my webhook to trigger actions.intent.TRANSACTION_DECISION
is the following:
{
"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": []
},
"extension": {
"@type": "type.googleapis.com/google.actions.v2.orders.GenericExtension",
"locations": [
{
"location": {
"phoneNumber": "123456789",
"postalAddress": {
"recipients": [
"Me"
],
"regionCode": "USA"
}
},
"type": "DELIVERY"
}
]
},
"id": "<UNIQUE_ORDER_ID>",
"otherItems": [],
"totalPrice": {
"amount": {
"currencyCode": "USD",
"units": 31
},
"type": "ACTUAL"
}
}
},
"intent": "actions.intent.TRANSACTION_DECISION"
}
}
}
}
but then I am getting this error on the Google Assistant simulator:
Sorry, something went wrong. Please try again later.
So I cannot really understand if I am not doing something right regarding the type and the format of the extension object
.
The logs at Google Assistant in this case are the following:
2018-05-23 09:12:47.024 BST
Received response from agent with body: HTTP/1.1 200 OK Server: nginx/1.13.6 Date: Wed, 23 May 2018 08:12:46 GMT Content-Type: application/json;charset=UTF-8 Content-Length: 1782 X-Cloud-Trace-Context: **************************/**************************;o=1 Google-Actions-API-Version: 2 Via: 1.1 google Alt-Svc: clear {"conversationToken":"[\"more\"]","expectUserResponse":true,"expectedInputs":[{"inputPrompt":{"richInitialPrompt":{"items":[{"simpleResponse":{"textToSpeech":"This is your order preview:"}}]}},"possibleIntents":[{"intent":"actions.intent.TRANSACTION_DECISION","inputValueData":{"orderOptions":{"requestDeliveryAddress":true},"paymentOptions":{"actionProvidedOptions":{"displayName":"VISA **** **** **** 3235","paymentType":"PAYMENT_CARD"}},"@type":"type.googleapis.com/google.actions.v2.TransactionDecisionValueSpec","proposedOrder":{"extension":{"@type":"type.googleapis.com/google.actions.v2.orders.GenericExtension","locations":[{"location":{"phoneNumber":"123456789","postalAddress":{"regionCode":"USA","recipients":["Me"]}},"type":"DELIVERY"}]},"totalPrice":{"amount":{"nanos":0.0,"units":36.0,"currencyCode":"USD"},"type":"ACTUAL"},"id":"<UNIQUE_ORDER_ID>","otherItems":[{"price":{"amount":{"nanos":0.0,"units":31.0,"currencyCode":"USD"},"type":"ACTUAL"},"name":"Subtotal","id":"Subtotal","type":"SUBTOTAL"},{"price":{"amount":{"nanos":0.0,"units":5.0,"currencyCode":"USD"},"type":"ACTUAL"},"name":"Delivery fees","id":"Delivery fees","type":"FEE"}],"cart":{"lineItems":[{"quantity":2.0,"price":{"amount":{"nanos":0.0,"units":31.0,"currencyCode":"USD"},"type":"ACTUAL"},"name":"Book","description":"Book","id":"1","type":"REGULAR"}], "merchant":{"name":"Amazon","id":"Amazon"},"otherItems":[]}}}}],"speechBiasingHints":["$polar","$products"]}],"responseMetadata":{"status":{"message":"Success (200)"},"queryMatchInfo":{"queryMatched":true,"intent":"df9de4fe-fc2a-4735-a45e-f1688da93201","parameterNames":["polar"]}}}.
Expand all | Collapse all {
insertId: "**************************"
labels: {…}
logName: "**************************/logs/actions.googleapis.com%2Factions"
receiveTimestamp: "2018-05-23T08:12:47.035898145Z"
resource: {…}
severity: "DEBUG"
textPayload: "Received response from agent with body: HTTP/1.1 200 OK
Server: nginx/1.13.6
Date: Wed, 23 May 2018 08:12:46 GMT
Content-Type: application/json;charset=UTF-8
Content-Length: 1782
X-Cloud-Trace-Context: **************************/**************************;o=1
Google-Actions-API-Version: 2
Via: 1.1 google
Alt-Svc: clear
{"conversationToken":"[\"more\"]","expectUserResponse":true,"expectedInputs":[{"inputPrompt":{"richInitialPrompt":{"items":[{"simpleResponse":{"textToSpeech":"This is your order preview:"}}]}},"possibleIntents":[{"intent":"actions.intent.TRANSACTION_DECISION","inputValueData":{"orderOptions":{"requestDeliveryAddress":true},"paymentOptions":{"actionProvidedOptions":{"displayName":"VISA **** **** **** 3235","paymentType":"PAYMENT_CARD"}},"@type":"type.googleapis.com/google.actions.v2.TransactionDecisionValueSpec","proposedOrder":{"extension":{"@type":"type.googleapis.com/google.actions.v2.orders.GenericExtension","locations":[{"location":{"phoneNumber":"123456789","postalAddress":{"regionCode":"USA","recipients":["Me"]}},"type":"DELIVERY"}]},"totalPrice":{"amount":{"nanos":0.0,"units":36.0,"currencyCode":"USD"},"type":"ACTUAL"},"id":"<UNIQUE_ORDER_ID>","otherItems":[{"price":{"amount":{"nanos":0.0,"units":31.0,"currencyCode":"USD"},"type":"ACTUAL"},"name":"Subtotal","id":"Subtotal","type":"SUBTOTAL"},{"price":{"amount":{"nanos":0.0,"units":5.0,"currencyCode":"USD"},"type":"ACTUAL"},"name":"Delivery fees","id":"Delivery fees","type":"FEE"}],"cart":{"lineItems":[{"quantity":2.0,"price":{"amount":{"nanos":0.0,"units":31.0,"currencyCode":"USD"},"type":"ACTUAL"},"name":"Book","description":"Book","id":"1","type":"REGULAR"}],"merchant":{"name":"Amazon","id":"Amazon"},"otherItems":[]}}}}],"speechBiasingHints":["$polar","$products"]}],"responseMetadata":{"status":{"message":"Success (200)"},"queryMatchInfo":{"queryMatched":true,"intent":"df9de4fe-fc2a-4735-a45e-f1688da93201","parameterNames":["polar"]}}}."
timestamp: "2018-05-23T08:12:47.024908542Z"
trace: "**************************"
}
How to add the delivery address details to the order preview?
This is an example of an order preview from Google docs which includes delivery address details:
P.S. The object(Cart)
contains the "notes": string
which can add a section at the final order preview exactly where the Delivery address section is placed at the order preview at the photo above. Therefore, I can add
"notes": "Lola\n1950 Charleston Road\nMountain View, CA 94043\n415 789 8934"
or my personal address details to the object(Cart)
and then I can display the delivery details to the final order preview as it is shown at this image: Image.
However in this way the title of this section at the order preview is Notes
while I want obviously Delivery address
as the title as it it shown at the photo above.