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

Actions Builderによるアクションのビジュアルプログラミング

Actions Builderによるアクションのビジュアルプログラミング

GDG DevFest 2020 でお話した内容の資料です。
デモンストレーションとセットですので、Youtubeの動画も合わせてご覧下さい。

Avatar for Daisuke Kobayashi

Daisuke Kobayashi

October 17, 2020
Tweet

More Decks by Daisuke Kobayashi

Other Decks in Programming

Transcript

  1. Scenesのライフサイクルとループ処理 Scenes A Conditions Slot filling Prompts Intent Transition Scenes

    B - Scenesがアクティブ化されたときに1回だけ実行され るステップ - Webhookをトリガーするか、シーンの1回限りのセッ トアップを行うようにユーザーに促すことができる On enter
  2. Scenesのライフサイクルとループ処理 Scenes A On enter Slot filling Prompts Intent Transition

    Scenes B Conditions - 次のステップに進める前に、パラメータが特定の値を 持っているかどうかに基づいて、ロジックを実行でき るステップ - ロジック次第では、別のシーンに移動したり、会話を 終了できたりする
  3. Scenesのライフサイクルとループ処理 Scenes A On enter Prompts Intent Transition Scenes B

    Conditions - ユーザーの入力を収集するためのステップ - Slotを埋めようと、Scenesのライフサイクルが動く Slot filling
  4. Scenesのライフサイクルとループ処理 Scenes A On enter Intent Transition Scenes B Conditions

    Slot filling - これまでのステップで集めたキューを元に、ユーザに 発話するステップ Prompts
  5. Scenesのライフサイクルとループ処理 Scenes A On enter Slot filling Prompts Transition Conditions

    Intent - Scenesのループを終了するための遷移基準を、定義で きるステップ - 遷移しない場合、ループは Conditions に戻る Scenes B
  6. VUI 設計 こんにちは、じゃんけんマ シーンです。 じゃんけんをしますか? じゃーんけーん はい グー 私はチョキ、あなたはグー。 あなたの勝ち!

    もう一回じゃんけんしますか? じゃーんけーん… はい OK Google じゃんけん マシーンにつないで : :
  7. Intents 概要 - アクションが理解できる、ユーザーの入力を定義できる - System intent と Custom intent

    がある - Training phrases - ユーザの入力の定義の例の事 - Assistant NLU(自然言語理解)エンジンは、 Training Phrasesを拡張して、 他の類似したフレーズを含めることができる
  8. // Custom Intent のイメージ { yes: ['はい', 'OK', 'YES', 'もちろん',

    'オッケー', ... ] } // Types のイメージ { meat : { beef: ['牛肉', 'ビーフ', 'ステーキ', ... ], pork: ['豚肉', 'ポーク', 'とんかつ', ... ], chicken: ['鶏肉', 'チキン', 'から揚げ', ... ], } }
  9. const { conversation } = require('@assistant/conversation'); const functions = require('firebase-functions');

    const app = conversation({debug: true}); const jankenTypeName = { gu: 'グー', tyoki: 'チョキ', pa: 'パー' }; const judgeMap = { gu: { gu: 'あいこ!', tyoki: 'あなたの勝ち!', pa: 'あなたの負け!' }, tyoki: { gu: 'あなたの負け!', tyoki: 'あいこ!', pa: 'あなたの勝ち!' }, pa: { gu: 'あなたの勝ち!', tyoki: 'あなたの負け!', pa: 'あいこ!' } }; 新しいライブラリに
  10. app.handle('janken', conv => { const actionChoice = ['gu', 'pa', 'tyoki'][Math.floor(Math.random()

    * 3)]; const message = judgeMap[conv.session.params.chosenJankenType][actionChoice]; conv.add(`私は${jankenTypeName[actionChoice]}、あなたは ${jankenTypeName[conv.session.params.chosenJankenType]}、${message}`); }); exports.ActionsOnGoogleFulfillment = functions.https.onRequest(app); intent から handle に ask から add に
  11. // Custom Intentでつくった「yes.yaml」 trainingPhrases: - そうだよ - そうです - もちろん

    - それで - よろしく - おねがい - "YES" - OK - うん - はい
  12. // Scenesでつくった「start.yaml」 intentEvents: - intent: "yes" transitionToScene: janken - handler:

    staticPrompt: candidates: - promptResponse: firstSimple: variants: - speech: では、さようなら intent: "no" transitionToScene: actions.scene.END_CONVERSATION onEnter: staticPrompt: candidates: - promptResponse: firstSimple: variants: - speech: じゃんけんをしますか?