Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Google Assistant 対応アプリを作ってみた

Google Assistant 対応アプリを作ってみた

Mobile Act NAGOYA 2018/4/26

Tiny Mouse

April 26, 2018
Tweet

More Decks by Tiny Mouse

Other Decks in Programming

Transcript

  1. 自己紹介  @tinymouse_jp  SI 企業 SE  日曜 

    二児 父  静岡県浜松市出身  東京都品川区在住 名古屋市在住  Windows 愛用 iPhone Android  Android 会浜松支部 Android 会 Tiny Mouse
  2. Fulfillment let intentMap = new Map; intentMap.set('hello', sayHello); const {WebhookClient}

    = require('dialogflow-fulfillment'); const agent = new WebhookClient({request, response}); function sayHello(agent) { agent.add(" "); } let actionMap = new Map; actionMap.set('hello_action', sayHello); const App = require('actions-on- google').DialogflowApp; const app = new App({request, response}); function sayHello(app) { app.tell(" "); } SDK v1 v2 移行 直後 自動生成
  3. 続 教 Fulfillment reqAbout •Training Phrase 教 •Parameters what @sys.any

    •Parameters what @sys.any $what •Fulfillment Enable webhook call intentMap.set('reqAbout', sayAbout); function sayAbout(agent) { var what = agent.parameters.what; agent.add(what + " "); } 入力内容 渡 入力内容 渡
  4. 続 今日 運勢 大吉 Fulfillment reqUnsei •Training Phrase 今日 運勢

    •Response •Fulfillment Enable webhook call intentMap.set('reqUnsei', sayUnsei); function sayUnsei(agent) { agent.add("大吉 "); }
  5. 続 今日 運勢 大吉 Fulfillment reqUnsei •Training Phrase 今日 運勢

    •Response •Fulfillment Enable webhook call intentMap.set('reqUnsei', sayUnsei); function sayUnsei(agent) { agent.setFollowupEvent({ name: 'say_unsei', parameters: { unsei: "大吉" } }); } 出力内容 渡 出力内容 渡 sayUnsei •Events say_unsei •Parameters unsei @sys.any #say_unsei.unsei •Response $unsei
  6. 作 忘 物 忘 物 reqCheck •Training Phrase 忘 物

    •Fulfillment Enable webhook call var list; var count; function startCheck(agent) { list = [ "携帯電話", "財布" ]; count = 0; agent.setFollowupEvent({ name: 'say_check', parameters: { item: list[cont] } }); } function sayCheck(agent) { count++; agent.setFollowupEvent({ .... 変数 値 保持 変数 値 保持 sayCheck •Events say_check •Parameters item @sys.any #say_check.item •Response $item 携帯電話 財布 sayCheck - yes •Training Phrase •Fulfillment Enable webhook call follow-up intent
  7. 作 忘 物 忘 物 reqCheck •Training Phrase 忘 物

    •Fulfillment Enable webhook call function startCheck(agent) { var list = [ "携帯電話", "財布" ]; var count = 0; agent.setContext({ name: 'list', parameters: { value: list, count: count, item: list[count] } }); agent.setFollowupEvent('say_check); } function sayCheck(agent) { var context = agent.getContext('list'); var list = context.parameters.list; var count = context.parameters.count; .... 値 保持 値 保持 sayCheck •Events say_check •Context list •Parameters item @sys.any #list.item •Response $item 携帯電話 財布 sayCheck - yes •Training Phrase •Fulfillment Enable webhook call follow-up intent
  8. 作 忘 物 忘 物 reqCheck •Training Phrase 忘 物

    •Fulfillment intentMap.set('reqCheck', startCheck); intentMap.set('startCheck - yes', sayCheck); intentMap.set('sayCheck - yes', sayCheck); function startCheck(agent) { ... agent.setFollowupEvent('start_check); } function sayCheck(agent) { ... agent.setFolloupEvent('say_check'); } startCheck •Events start_check 携帯電話 財布 startCheck - yes •Training Phrase •Fulfillment sayCheck •Events say_check sayCheck - yes •Training Phrase •Fulfillment 事前 名前 流 図 事前 名前 流 図