iT邦幫忙

2019 iT 邦幫忙鐵人賽

DAY 24
0

大部份APP都會設計到個人化的應用,而Voice App在應用時,有時候也會有這個需求,而在Google Assistant上,要實現個人化的目標,目前有兩種做法:

  1. Account linking with Google Sign-In 
  2. Account linking with OAuth and Google Sign-In 

本篇直接先用研究用 Google Sign-In來做看看
https://developers.google.com/actions/assistant/helpers#account_sign-in

https://github.com/actions-on-google/dialogflow-helper-intents-nodejs


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

module.exports = {

  'ask_for_sign_in': (conv) => {
    conv.ask(new SignIn());
  },

  'ask_for_sign_in_confirmation': (conv, params, signin) => {
    if (signin.status !== 'OK') {
      return conv.ask('You need to sign in before using the app.');
    }
    // const access = conv.user.access.token;
    // possibly do something with access token
    return conv.ask('Great! Thanks for signing in.');
  },

};

取出 SignIn 這個Object 然後在詢問,看使用者有無同意。


上一篇
actions-on-google 建置 Google Home App #22 notifications 主動推播
下一篇
actions-on-google 建置 Google Home App #24 Transactions 交易
系列文
Voice App 開發實務:使用Diagflow+firebase開發Google home App (google assistant action)31

尚未有邦友留言

立即登入留言