actions-on-google / dialogflow-transactions-nodejs

Physical transactions sample (using Dialogflow) in Node.js
Apache License 2.0
67 stars 43 forks source link

Sample app does not respond after "confirm transaction" #15

Closed patjackson52 closed 6 years ago

patjackson52 commented 6 years ago

Running the sample action causes an error message after "confirm transaction", and we get the response "Sorry, something went wrong. Please try again later."

No error message is in the simulator. The bug happens on simulator and device. This is with an account with transactions enabled and transactions are enabled for the action.

Response JSON:

{
  "payload": {
    "google": {
      "expectUserResponse": true,
      "richResponse": {
        "items": [
          {
            "simpleResponse": {
              "textToSpeech": "PLACEHOLDER"
            }
          }
        ]
      },
      "userStorage": "{\"data\":{}}",
      "systemIntent": {
        "intent": "actions.intent.TRANSACTION_DECISION",
        "data": {
          "@type": "type.googleapis.com/google.actions.v2.TransactionDecisionValueSpec",
          "orderOptions": {
            "requestDeliveryAddress": true
          },
          "paymentOptions": {
            "actionProvidedOptions": {
              "paymentType": "PAYMENT_CARD",
              "displayName": "VISA-1234"
            }
          },
          "proposedOrder": {
            "id": "<UNIQUE_ORDER_ID>",
            "cart": {
              "merchant": {
                "id": "book_store_1",
                "name": "Book Store"
              },
              "lineItems": [
                {
                  "name": "My Memoirs",
                  "id": "memoirs_1",
                  "price": {
                    "amount": {
                      "currencyCode": "USD",
                      "nanos": 990000000,
                      "units": 3
                    },
                    "type": "ACTUAL"
                  },
                  "quantity": 1,
                  "subLines": [
                    {
                      "note": "Note from the author"
                    }
                  ],
                  "type": "REGULAR"
                },
                {
                  "name": "Memoirs of a person",
                  "id": "memoirs_2",
                  "price": {
                    "amount": {
                      "currencyCode": "USD",
                      "nanos": 990000000,
                      "units": 5
                    },
                    "type": "ACTUAL"
                  },
                  "quantity": 1,
                  "subLines": [
                    {
                      "note": "Special introduction by author"
                    }
                  ],
                  "type": "REGULAR"
                },
                {
                  "name": "Their memoirs",
                  "id": "memoirs_3",
                  "price": {
                    "amount": {
                      "currencyCode": "USD",
                      "nanos": 750000000,
                      "units": 15
                    },
                    "type": "ACTUAL"
                  },
                  "quantity": 1,
                  "subLines": [
                    {
                      "lineItem": {
                        "name": "Special memoir epilogue",
                        "id": "memoirs_epilogue",
                        "price": {
                          "amount": {
                            "currencyCode": "USD",
                            "nanos": 990000000,
                            "units": 3
                          },
                          "type": "ACTUAL"
                        },
                        "quantity": 1,
                        "type": "REGULAR"
                      }
                    }
                  ],
                  "type": "REGULAR"
                },
                {
                  "name": "Our memoirs",
                  "id": "memoirs_4",
                  "price": {
                    "amount": {
                      "currencyCode": "USD",
                      "nanos": 490000000,
                      "units": 6
                    },
                    "type": "ACTUAL"
                  },
                  "quantity": 1,
                  "subLines": [
                    {
                      "note": "Special introduction by author"
                    }
                  ],
                  "type": "REGULAR"
                }
              ],
              "notes": "The Memoir collection",
              "otherItems": [
                {
                  "name": "Subtotal",
                  "id": "subtotal",
                  "price": {
                    "amount": {
                      "currencyCode": "USD",
                      "nanos": 220000000,
                      "units": 32
                    },
                    "type": "ESTIMATE"
                  },
                  "type": "SUBTOTAL"
                },
                {
                  "name": "Tax",
                  "id": "tax",
                  "price": {
                    "amount": {
                      "currencyCode": "USD",
                      "nanos": 780000000,
                      "units": 2
                    },
                    "type": "ESTIMATE"
                  },
                  "type": "TAX"
                }
              ]
            },
            "otherItems": [],
            "totalPrice": {
              "amount": {
                "currencyCode": "USD",
                "nanos": 0,
                "units": 35
              },
              "type": "ESTIMATE"
            },
            "extension": {
              "@type": "type.googleapis.com/google.actions.v2.orders.GenericExtension",
              "locations": [
                {
                  "type": "DELIVERY",
                  "location": {
                    "postalAddress": {
                      "regionCode": "US",
                      "recipients": [
                        "Patrick Jackson"
                      ],
                      "postalCode": "27525",
                      "locality": "FRANKLINTON",
                      "addressLines": [
                        "165 SUTHERLAND DR"
                      ],
                      "administrativeArea": "NC"
                    }
                  }
                }
              ]
            }
          }
        }
      }
    }
  },
  "outputContexts": [
    {
      "name": "projects/df-v2-transactions/agent/sessions/1531419984314/contexts/_actions_on_google",
      "lifespanCount": 99,
      "parameters": {
        "data": "{\"deliveryAddress\":{\"zipCode\":\"27525\",\"postalAddress\":{\"regionCode\":\"US\",\"recipients\":[\"Patrick Jackson\"],\"postalCode\":\"27525\",\"locality\":\"FRANKLINTON\",\"addressLines\":[\"165 SUTHERLAND DR\"],\"administrativeArea\":\"NC\"},\"phoneNumber\":\"9196076160\",\"city\":\"FRANKLINTON\",\"coordinates\":{\"latitude\":36.080033,\"longitude\":-78.507623}}}"
      }
    }
  ]
}
taycaldwell commented 6 years ago

I assume you are using action provided payments rather than google provided payments based on the JSON.

Can you do me a favor and re-run the sample, providing a unique order ID in place of ?

fengwen2013 commented 6 years ago

@taycaldwell Got the same issue and replacing the "UNIQUE_ORDER_ID" with a unique order ID(112233) does't work. No errors shown in the simulator but got this message "Sorry, something went wrong. Please try again later"

{
  "conversationToken": "[\"_actions_on_google\"]",
  "expectUserResponse": true,
  "expectedInputs": [
    {
      "inputPrompt": {
        "richInitialPrompt": {
          "items": [
            {
              "simpleResponse": {
                "textToSpeech": "PLACEHOLDER"
              }
            }
          ]
        }
      },
      "possibleIntents": [
        {
          "intent": "actions.intent.TRANSACTION_DECISION",
          "inputValueData": {
            "orderOptions": {
              "requestDeliveryAddress": true
            },
            "paymentOptions": {
              "actionProvidedOptions": {
                "displayName": "VISA-1234",
                "paymentType": "PAYMENT_CARD"
              }
            },
            "@type": "type.googleapis.com/google.actions.v2.TransactionDecisionValueSpec",
            "proposedOrder": {
              "extension": {
                "@type": "type.googleapis.com/google.actions.v2.orders.GenericExtension",
                "locations": [
                  {
                    "location": {
                      "postalAddress": {
                        "regionCode": "US",
                        "recipients": [
                          "Feng Wen"
                        ],
                        "postalCode": "94015",
                        "locality": "DALY CITY",
                        "addressLines": [
                          "1580 EDGEWORTH AVE"
                        ],
                        "administrativeArea": "CA"
                      }
                    },
                    "type": "DELIVERY"
                  }
                ]
              },
              "totalPrice": {
                "amount": {
                  "nanos": 0,
                  "units": 35,
                  "currencyCode": "USD"
                },
                "type": "ESTIMATE"
              },
              "id": "112233",
              "otherItems": [],
              "cart": {
                "lineItems": [
                  {
                    "quantity": 1,
                    "subLines": [
                      {
                        "note": "Note from the author"
                      }
                    ],
                    "price": {
                      "amount": {
                        "nanos": 990000000,
                        "units": 3,
                        "currencyCode": "USD"
                      },
                      "type": "ACTUAL"
                    },
                    "name": "My Memoirs",
                    "id": "memoirs_1",
                    "type": "REGULAR"
                  },
                  {
                    "quantity": 1,
                    "subLines": [
                      {
                        "note": "Special introduction by author"
                      }
                    ],
                    "price": {
                      "amount": {
                        "nanos": 990000000,
                        "units": 5,
                        "currencyCode": "USD"
                      },
                      "type": "ACTUAL"
                    },
                    "name": "Memoirs of a person",
                    "id": "memoirs_2",
                    "type": "REGULAR"
                  },
                  {
                    "quantity": 1,
                    "subLines": [
                      {
                        "lineItem": {
                          "quantity": 1,
                          "price": {
                            "amount": {
                              "nanos": 990000000,
                              "units": 3,
                              "currencyCode": "USD"
                            },
                            "type": "ACTUAL"
                          },
                          "name": "Special memoir epilogue",
                          "id": "memoirs_epilogue",
                          "type": "REGULAR"
                        }
                      }
                    ],
                    "price": {
                      "amount": {
                        "nanos": 750000000,
                        "units": 15,
                        "currencyCode": "USD"
                      },
                      "type": "ACTUAL"
                    },
                    "name": "Their memoirs",
                    "id": "memoirs_3",
                    "type": "REGULAR"
                  },
                  {
                    "quantity": 1,
                    "subLines": [
                      {
                        "note": "Special introduction by author"
                      }
                    ],
                    "price": {
                      "amount": {
                        "nanos": 490000000,
                        "units": 6,
                        "currencyCode": "USD"
                      },
                      "type": "ACTUAL"
                    },
                    "name": "Our memoirs",
                    "id": "memoirs_4",
                    "type": "REGULAR"
                  }
                ],
                "notes": "The Memoir collection",
                "merchant": {
                  "name": "Book Store",
                  "id": "book_store_1"
                },
                "otherItems": [
                  {
                    "price": {
                      "amount": {
                        "nanos": 220000000,
                        "units": 32,
                        "currencyCode": "USD"
                      },
                      "type": "ESTIMATE"
                    },
                    "name": "Subtotal",
                    "id": "subtotal",
                    "type": "SUBTOTAL"
                  },
                  {
                    "price": {
                      "amount": {
                        "nanos": 780000000,
                        "units": 2,
                        "currencyCode": "USD"
                      },
                      "type": "ESTIMATE"
                    },
                    "name": "Tax",
                    "id": "tax",
                    "type": "TAX"
                  }
                ]
              }
            }
          }
        }
      ]
    }
  ],
  "responseMetadata": {
    "status": {
      "message": "Success (200)"
    },
    "queryMatchInfo": {
      "queryMatched": true,
      "intent": "b3e24235-436f-45d0-8b27-f5a11934ad75"
    }
  },
  "userStorage": "{\"data\":{}}"
}
fengwen2013 commented 6 years ago

Updating the privacy policy link in Directory Information solved the problem..... It would be nice if the root cause of the error is also caught in simulator console.

taycaldwell commented 6 years ago

@patjackson52,

As mentioned in the README, you will need to fill in the Directory Information for your Action before running the sample. This includes images, a contact email and privacy policy.

Please re-run the sample will this information completely filled out.