actions-on-google / actions-on-google-nodejs

Node.js client library for Actions on Google
https://actions-on-google.github.io/actions-on-google-nodejs
Apache License 2.0
900 stars 197 forks source link

account link success but action response error #428

Open zltl opened 2 years ago

zltl commented 2 years ago

I follow steps below to create account link account link tutorial.

OAuth steps works ok, but test emulator response error:

Great, your my tv controller account is now linked to Google.Sorry, my tv controller isn't responding right now. Please try again soon.

My fulfillment code show below:

const express = require('express')
const bodyParser = require('body-parser')

const {
  actionssdk,
} = require('actions-on-google');

const servePort = 4000;
console.log("listening on ", servePort)

const expressApp = express().use(bodyParser.json())

const app = actionssdk({ debug: true });

app.intent('', (conv: any) => {
  conv.add('link success');

  conv.user.params = {
    uid: '14711'
  };
});

app.intent('actions.intent.MAIN', (conv: any) => {
  conv.add('ok');
});

app.intent('actions.intent.TEXT', (conv: any) => {
  conv.add('OK');
});

expressApp.post('/fulfillment', app);
expressApp.listen(servePort);

fulfillment's logs:

Request {
  "handler": {
    "name": "create_user"
  },
  "intent": {
    "name": "",
    "params": {
      "AccountLinkingSlot": {
        "original": "",
        "resolved": "LINKED"
      }
    },
    "query": ""
  },
  "scene": {
    "name": "AccountLinkingOrigin_AccountLinking",
    "slotFillingStatus": "FINAL",
    "slots": {
      "AccountLinkingSlot": {
        "mode": "REQUIRED",
        "status": "SLOT_UNSPECIFIED",
        "updated": true,
        "value": "LINKED"
      }
    },
    "next": {
      "name": "AccountLinkingOrigin"
    }
  },
  "session": {
    "id": "ABwppHH8ogdBaYUxMXNyOEvqCmT2FXCl82OEE7Bo7M7tq7I4oL2PQMW0PqWE-J7iNlOLHUPe0QUu3xNPAEID9Raj0g",
    "params": {
      "AccountLinkingSlot": "LINKED"
    },
    "typeOverrides": [],
    "languageCode": ""
  },
  "user": {
    "locale": "en-US",
    "params": {},
    "accountLinkingStatus": "LINKED",
    "verificationStatus": "VERIFIED",
    "packageEntitlements": [],
    "gaiamint": "",
    "permissions": [],
    "lastSeenTime": "2021-08-17T03:40:26Z"
  },
  "home": {
    "params": {}
  },
  "device": {
    "capabilities": [
      "SPEECH",
      "RICH_RESPONSE",
      "WEB_LINK",
      "LONG_FORM_AUDIO"
    ],
    "timeZone": {
      "id": "America/Los_Angeles",
      "version": ""
    }
  }
}
Headers {
  "host": "8b53b5ef85ab.ngrok.io",
  "user-agent": "Google-ActionsOnGoogle/1.0",
  "content-length": "907",
  "accept-encoding": "gzip, deflate, br",
  "authorization": "Bearer 7a9e5aa1d41f4d010b1139dea0057f77bcfa53c7",
  "content-type": "application/json;charset=UTF-8",
  "google-actions-api-version": "3",
  "google-assistant-signature": "eyJhbGciOiJSUzI1NiIsImtpZCI6IjQ2Mjk0OTE3NGYxZWVkZjRmOWY5NDM0ODc3YmU0ODNiMzI0MTQwZjUiLCJ0eXAiOiJKV1QifQ.eyJpc3MiOiJodHRwczovL2FjY291bnRzLmdvb2dsZS5jb20iLCJhdWQiOiJ0di1jb250cm9sbGVyLWMzNDM2IiwibmJmIjoxNjI5MTcxNTQyLCJpYXQiOjE2MjkxNzE4NDIsImV4cCI6MTYyOTE3MTk2MiwianRpIjoiY2E3MTQ0NzkzZWMwNTAzYjZlNjUzYjQ5Mzg0MWI0NmEwMjE3YzI4YSJ9.NPJ1tkkwelKtTEl1Uky1UjuXLKbF14fRssULvcW9jZGV-yLORZOSCEnJq5rKcSNuKCxuPuzxwN4c5I3QCRkVN1kEd8w3COzVIK75aUw5XiBqcJlOdjyV6P8c9lMEupJ7snmuYeLSwmzfh42bwze5tryxWRh1D0DiL5NgIyN2DR2f4swJL7eX_JLi_0neTLcEMPHSEx25vwGnadcp7xlaalBMiTbQr5s1Hys4Yq09YraHOqLeWB57gFTR7QtjP5L9LW0EN4cacMizU7Asc-9Rdnlcg7V0PfUoFY3Q63e7ZiSRonH1BNgf-TVmi49sAjSRkSe77UGy0kD99E5-NExqkA",
  "x-forwarded-for": "66.249.84.240",
  "x-forwarded-proto": "https"
}
Conversation {
  "responses": [],
  "expectUserResponse": true,
  "digested": false,
  "noInputs": [],
  "speechBiasing": [],
  "_responded": false,
  "_ordersv3": false,
  "request": "[Excluded]",
  "headers": "[Excluded]",
  "_init": {},
  "sandbox": false,
  "input": {},
  "surface": {
    "capabilities": {
      "list": []
    }
  },
  "available": {
    "surfaces": {
      "list": [],
      "capabilities": {
        "surfaces": []
      }
    }
  },
  "user": {
    "raw": {
      "locale": "en-US",
      "params": {},
      "accountLinkingStatus": "LINKED",
      "verificationStatus": "VERIFIED",
      "packageEntitlements": [],
      "gaiamint": "",
      "permissions": [],
      "lastSeenTime": "2021-08-17T03:40:26Z"
    },
    "storage": {},
    "locale": "en-US",
    "permissions": [],
    "last": {},
    "name": {},
    "entitlements": [],
    "access": {},
    "profile": {}
  },
  "arguments": {
    "parsed": {
      "input": {},
      "list": []
    },
    "status": {
      "input": {},
      "list": []
    },
    "raw": {
      "list": [],
      "input": {}
    }
  },
  "device": {},
  "canvas": {},
  "screen": false,
  "body": "[Excluded]",
  "intent": "",
  "data": {}
}
Response {
  "status": 200,
  "headers": {
    "content-type": "application/json;charset=utf-8"
  },
  "body": {
    "expectUserResponse": true,
    "expectedInputs": [
      {
        "possibleIntents": [
          {
            "intent": "actions.intent.TEXT"
          }
        ],
        "inputPrompt": {
          "richInitialPrompt": {
            "items": [
              {
                "simpleResponse": {
                  "textToSpeech": "link success"
                }
              }
            ]
          }
        }
      }
    ]
  }
}
Request {
  "handler": {
    "name": "create_user"
  },
  "intent": {
    "name": "",
    "params": {
      "AccountLinkingSlot": {
        "original": "",
        "resolved": "LINKED"
      }
    },
    "query": ""
  },
  "scene": {
    "name": "AccountLinkingOrigin_AccountLinking",
    "slotFillingStatus": "FINAL",
    "slots": {
      "AccountLinkingSlot": {
        "mode": "REQUIRED",
        "status": "SLOT_UNSPECIFIED",
        "updated": false,
        "value": "LINKED"
      }
    },
    "next": {
      "name": "AccountLinkingOrigin"
    }
  },
  "session": {
    "id": "ABwppHH8ogdBaYUxMXNyOEvqCmT2FXCl82OEE7Bo7M7tq7I4oL2PQMW0PqWE-J7iNlOLHUPe0QUu3xNPAEID9Raj0g",
    "params": {
      "AccountLinkingSlot": "LINKED"
    },
    "typeOverrides": [],
    "languageCode": ""
  },
  "user": {
    "locale": "en-US",
    "params": {},
    "accountLinkingStatus": "LINKED",
    "verificationStatus": "VERIFIED",
    "packageEntitlements": [],
    "gaiamint": "",
    "permissions": [],
    "lastSeenTime": "2021-08-17T03:40:26Z"
  },
  "home": {
    "params": {}
  },
  "device": {
    "capabilities": [
      "SPEECH",
      "RICH_RESPONSE",
      "WEB_LINK",
      "LONG_FORM_AUDIO"
    ],
    "timeZone": {
      "id": "America/Los_Angeles",
      "version": ""
    }
  }
}
Headers {
  "host": "8b53b5ef85ab.ngrok.io",
  "user-agent": "Google-ActionsOnGoogle/1.0",
  "content-length": "908",
  "accept-encoding": "gzip, deflate, br",
  "authorization": "Bearer 7a9e5aa1d41f4d010b1139dea0057f77bcfa53c7",
  "content-type": "application/json;charset=UTF-8",
  "google-actions-api-version": "3",
  "google-assistant-signature": "eyJhbGciOiJSUzI1NiIsImtpZCI6IjQ2Mjk0OTE3NGYxZWVkZjRmOWY5NDM0ODc3YmU0ODNiMzI0MTQwZjUiLCJ0eXAiOiJKV1QifQ.eyJpc3MiOiJodHRwczovL2FjY291bnRzLmdvb2dsZS5jb20iLCJhdWQiOiJ0di1jb250cm9sbGVyLWMzNDM2IiwibmJmIjoxNjI5MTcxNTQzLCJpYXQiOjE2MjkxNzE4NDMsImV4cCI6MTYyOTE3MTk2MywianRpIjoiYTA3YzUxY2MyNWIxNjMxZmU1YTI0MGJmMWQ5MDUxODJhODk2NDNhOSJ9.qI-NFewINGqk7p0FHG5SK2V1ghmCZgG0525shDCuHagT0vlclq53LGoc37qvlFBIzJvBFk1Xgv7o0EQIcuyXWKiv1hwlkNx1izZTpTuW_JS3Mag0EuJRvvxjytw0oBRn8vjmY4UrEfPOcUIQ6srNq_WAYZPfOZQHb0LF194RkSc_qRcfsw1sTrV8OQoAfpRGvsVwg-dBxK7cMcBsuB4aADe23KTBHb41OO2efrPzbDv60YbTnDNUkkx72l1eCl9E-DUtCGnkqTGVVjCOZpZKbBArDei96MhMMLfETkxpiR9CYiB9aaNzCzIqicVLil5dJ7104SwJRxN0xhCY964I6A",
  "x-forwarded-for": "66.249.84.225",
  "x-forwarded-proto": "https"
}
Conversation {
  "responses": [],
  "expectUserResponse": true,
  "digested": false,
  "noInputs": [],
  "speechBiasing": [],
  "_responded": false,
  "_ordersv3": false,
  "request": "[Excluded]",
  "headers": "[Excluded]",
  "_init": {},
  "sandbox": false,
  "input": {},
  "surface": {
    "capabilities": {
      "list": []
    }
  },
  "available": {
    "surfaces": {
      "list": [],
      "capabilities": {
        "surfaces": []
      }
    }
  },
  "user": {
    "raw": {
      "locale": "en-US",
      "params": {},
      "accountLinkingStatus": "LINKED",
      "verificationStatus": "VERIFIED",
      "packageEntitlements": [],
      "gaiamint": "",
      "permissions": [],
      "lastSeenTime": "2021-08-17T03:40:26Z"
    },
    "storage": {},
    "locale": "en-US",
    "permissions": [],
    "last": {},
    "name": {},
    "entitlements": [],
    "access": {},
    "profile": {}
  },
  "arguments": {
    "parsed": {
      "input": {},
      "list": []
    },
    "status": {
      "input": {},
      "list": []
    },
    "raw": {
      "list": [],
      "input": {}
    }
  },
  "device": {},
  "canvas": {},
  "screen": false,
  "body": "[Excluded]",
  "intent": "",
  "data": {}
}
Response {
  "status": 200,
  "headers": {
    "content-type": "application/json;charset=utf-8"
  },
  "body": {
    "expectUserResponse": true,
    "expectedInputs": [
      {
        "possibleIntents": [
          {
            "intent": "actions.intent.TEXT"
          }
        ],
        "inputPrompt": {
          "richInitialPrompt": {
            "items": [
              {
                "simpleResponse": {
                  "textToSpeech": "link success"
                }
              }
            ]
          }
        }
      }
    ]
  }
}