actions-on-google / dialogflow-transactions-nodejs

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

The agent returned an empty TTS on calling TransactionRequirements constructor #17

Closed MFR1 closed 5 years ago

MFR1 commented 5 years ago

I am always getting the following error on saying "check transaction with google payment":

"The agent returned an empty TTS"

Can you please let me know what is the issue?

tocie commented 5 years ago

Same here. And it returns "Could not request transactions check with Google payment" in Request

MFR1 commented 5 years ago

So did you get any solution for this? I think this is happening because of the unsupported countries: https://developers.google.com/actions/transactions/digital/dev-guide-digital

From where are you invoking your skill?

tocie commented 5 years ago

arg.resultType are returning OK when it is transaction_check_action Intent, But returning USER_ACTION_REQUIRED when it using transaction_check_google Intent.

transaction_check_complete Intent requires only 'OK' to process, https://github.com/actions-on-google/dialogflow-transactions-nodejs/blob/418ced27d8ea2c384358069917abcfd8084bd220/functions/index.js#L76

If it is not OK, then the code returns conversation close. This is why conversation is closed.

tocie commented 5 years ago

I'm not sure what kind of action should we or user do to change status "OK". https://developers.google.com/actions/reference/rest/Shared.Types/ResultType

tocie commented 5 years ago

Any updates? It is still returning USER_ACTION_REQUIRED and using Stripe for gateway.

app.intent('transaction_check_google', (conv) => {
  conv.ask(new TransactionRequirements({
    orderOptions: {
      requestDeliveryAddress: false,
    },
    paymentOptions: {
      googleProvidedOptions: {
        prepaidCardDisallowed: false,
        supportedCardNetworks: ['VISA', 'AMEX'],
        // Tokenization with Stripe
        tokenizationParameters: {
          parameters: {
            "gateway": "stripe",
            "stripe:publishableKey": 'pk_test_XXXXXXXXXXXXXXXXXXXXXXXX',
            "stripe:version": "2018-11-08"
          },
          tokenizationType: "PAYMENT_GATEWAY"
        },
      },
    },
  }));
});

app.intent('transaction_check_complete', (conv) => {
  const arg = conv.arguments.get('TRANSACTION_REQUIREMENTS_CHECK_RESULT');
  if (arg && arg.resultType ==='OK') {
    // Normally take the user through cart building flow
      conv.ask(`Looks like you're good to go! ` +
      `Try saying "confirm transaction.".`,
      new Suggestions(['Get Delivery Address', 'confirm transaction']));
  } else {
    conv.close('Transaction failed : ' + arg.resultType );    // Transaction failed : USER_ACTION_REQUIRED
  }
});

Pasted the code. https://gist.github.com/tocie/786fed3172d10822da6709d179ae505e

👇Response

  "raw": {
      "list": [
        {
          "extension": {
            "@type": "type.googleapis.com/google.actions.v2.TransactionRequirementsCheckResult",
            "resultType": "USER_ACTION_REQUIRED"
          },
          "name": "TRANSACTION_REQUIREMENTS_CHECK_RESULT"
        },
        {
          "name": "text"
        }
      ],
      "input": {
        "TRANSACTION_REQUIREMENTS_CHECK_RESULT": {
          "extension": {
            "@type": "type.googleapis.com/google.actions.v2.TransactionRequirementsCheckResult",
            "resultType": "USER_ACTION_REQUIRED"
          },
          "name": "TRANSACTION_REQUIREMENTS_CHECK_RESULT"
        },
        "text": {
          "name": "text"
        }
      }
    }
  },
aradwyr commented 5 years ago

Make sure you are testing out transactions on a mobile device -- testing transactions via the simulator isn't currently supported.

tocie commented 5 years ago

Hi thanks for answering! I confirmed using phone last time, it was returning as "TRANSACTION_REQUIREMENTS_CHECK_RESULT" but now it returning "OK".

aradwyr commented 5 years ago

The sample has been significantly updated recently so I recommend going through from the beginning with the latest changes.