Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Alexa-SDK-V2基礎講座@大阪
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
chao2suke
October 19, 2018
Technology
1
110
Alexa-SDK-V2基礎講座@大阪
2018/10/17 Alexa Salon vol.3@大阪 登壇資料
chao2suke
October 19, 2018
Tweet
Share
More Decks by chao2suke
See All by chao2suke
天井カメラで捉えた人物をコンピュータビジョンで解析した3年間のトライアンドエラーとこれから
chao2suke
0
2.4k
結局普通のエンジニアが今SageMaker使うと何ができるのかわかるLT
chao2suke
0
1.7k
機械学習の知識ゼロでも動かせるAIツールキットの世界
chao2suke
0
1.8k
「今」のAI技術と「3年後」のAI技術のご紹介
chao2suke
0
1.1k
Alexaに詳しい人は普段Alexaをどう扱っているか
chao2suke
0
960
奥深きAPLの世界
chao2suke
0
130
Alexaスキル & レジレスCafeにおけるStripe活用の取り組み
chao2suke
0
2k
Alexa x 機械学習でスキルをよりリッチにする方法
chao2suke
0
1.7k
#AAJUG vol.2 APL ハンズオン
chao2suke
0
3k
Other Decks in Technology
See All in Technology
既存アプリの延命も,最新技術での新規開発も:WebSphereの最新情報
ktgrryt
0
110
Windows ファイル共有(SMB)を再確認する
murachiakira
PRO
0
220
【Λ(らむだ)】最近のアプデ情報 / RPALT20260318
lambda
0
150
ABEMAのバグバウンティの取り組み
kurochan
1
390
システム標準化PMOから ガバメントクラウドCoEへ
techniczna
1
160
ソフトバンク流!プラットフォームエンジニアリング実現へのアプローチ
sbtechnight
1
250
Agent Skill 是什麼?對軟體產業帶來的變化
appleboy
0
190
ReactのdangerouslySetInnerHTMLは“dangerously”だから危険 / Security.any #09 卒業したいセキュリティLT
flatt_security
0
440
AIエージェント×GitHubで実現するQAナレッジの資産化と業務活用 / QA Knowledge as Assets with AI Agents & GitHub
tknw_hitsuji
0
160
Kiro Powers 入門
k_adachi_01
0
130
2026年もソフトウェアサプライチェーンのリスクに立ち向かうために / Product Security Square #3
flatt_security
1
740
「通るまでRe-run」から卒業!落ちないテストを書く勘所
asumikam
2
450
Featured
See All Featured
BBQ
matthewcrist
89
10k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
1.8k
Exploring anti-patterns in Rails
aemeredith
2
290
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
64
54k
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.3k
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
1
150
Why You Should Never Use an ORM
jnunemaker
PRO
61
9.8k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
10
1.1k
Context Engineering - Making Every Token Count
addyosmani
9
770
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
430
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
270
The Cost Of JavaScript in 2023
addyosmani
55
9.8k
Transcript
Alexa-SDK V2 基礎講座 Alexa-SDK V2 Training course 1 Classmethod, Inc.
せーの
#AlexaSalon 2
!3 ( ) A I A l e x a
& V U I / O /
ί ϛ ϡ χ ς Ο [ A l e
x a S a l o n ] ओ ࠵ A m a z o n ެ ࣜ ϋ ϯ ζ Φ ϯ τ Ϩ ʔ χ ϯ ά ς Ϋ χ Χ ϧ α ϙ ʔ τ A m a z o n ެ ࣜ τ Ϩ ʔ χ ϯ άϖ ʔ δ ੍ ࡞ A l e x a S k i l l A w a r d s ެ ࣜ ϋ ο Χ ι ϯ : ς Ϋ χ Χ ϧ α ϙ ʔ τ ܾ উ ৹ ࠪ һ ॳ ৺ ऀ ͚ A l e x a ຊ ࣥ ච !4
Agenda • コードブロック概要 • Skill Builderについて • インストール⽅法 • Handlerについて
• Response Builderについて • Attribute Managerについて 5
コードブロック概要 6
Hello World 7 const MyHandler = { canHandle(handlerInput) { return
true; }, handle(handlerInput) { return handlerInput.responseBuilder .speak('͜Μʹͪ') .getResponse(); } };
8
9
10
Skill Builder 11
12 Skill Builderとは Skillインスタンスを作るもの
13 Skill Builder Standard Custom
14 Skill Builder Standard Custom 全部⼊り 欲しいところだけ
15 Skill Builder(Custom) Core 基本機能だけ動けばいい Model
16 Skill Builder(Custom) Core DB使いたい Model Persistant Adapter
17 Skill Builder(Custom) Core DBとAPI使いたい Model Persistant Adapter APIClient
18 Skill Builder(Custom) Customコンポーネント Core 基本機能 Model 定義情報 Dynamodb-persistance-adapter DynamoDBによる永続化
S3-peresistance-adapter S3による永続化 Api-client AlexaサービスAPIの使⽤
インストール 19
インストール 20 $ npm install --save ask-sdk
インストール(Coreのみ) 21 $ npm install --save ask-sdk-model $ npm install
--save ask-sdk-core
Customビルダーでの宣⾔ 22 ライブラリのインストール コード冒頭でrequired Skill Builderにメソッド追加
Ex.CustomでDynamoDBを使う 23 ライブラリのインストール $ npm install --save ask-sdk-dynamodb- persistence-adapter $
npm install --save ask-sdk-model $ npm install --save ask-sdk-core
Ex.CustomでDynamoDBを使う 24 'use strict'; const aws = require('aws-sdk-core'); const Adapter
= require('ask-sdk-dynamodb- persistence-adapter'); コード冒頭でrequired
Ex.CustomでDynamoDBを使う 25 const config = {tableName: 'alexa-salon-vol3', createTable: true}; const
DynamoDBAdapter = new Adapter.DynamoDbPersistenceAdapter(config); Skill Builderにメソッド追加
Ex.CustomでDynamoDBを使う 26 const skillBuilder = Alexa.SkillBuilders.custom(); exports.handler = skillBuilder .addRequestHandlers(
LaunchRequestHandler, ) .withPersistenceAdapter(DynamoDBAdapter) .addErrorHandlers(ErrorHandler) .lambda(); Skill Builderにメソッド追加
Handler 27
28 Handler CanHandle Handle
canHandle 29 このHandlerはどのIntentを処理するか True / False
canHandle • このハンドラーはどのIntentを処理するか 30 canHandle(handlerInput) { return handlerInput.requestEnvelope.request.type === 'IntentRequest'
&& handlerInput.requestEnvelope.request.intent.name === 'MenuIntent'; },
31 CanHandle Tips Handlerは登録した順番でCanHandleする exports.handler = skillBuilder .addRequestHandlers( LaunchRequestHandler, OrderProgressIntentHandler,
OrderCompletedIntentHandler, HelpIntentHandler, CancelAndStopIntentHandler, SessionEndedRequestHandler )
handle • 実際の処理内容 32 handle(handlerInput) { return setMenu(handlerInput, null); }
33 Handler Tips Handler-A: 郵便番号がSlotに⼊っている Handler-B: 住所がSlotに⼊っている Handler-C: 何も⼊っていない 近くの店舗をお知らせする
郵便番号を調べて確認する 郵便番号を聞く
Slotのとり⽅ 34 handlerInput.requestEnvelope.request.intent.slots.hand.value
35 Slot Tips requestまでは⼀緒なので変数化する handlerInput.requestEnvelope.request.intent.slots.hand.value var request = handlerInput.requestEnvelope.request; var
slot = request.intent.slots.hand.value;
Response 36
37 Response Builder Tips ResponseBuilderはチェーンで書く return handlerInput.responseBuilder .speak('͢Έ·ͤΜɺΑ͘ฉ͖औΕ·ͤΜͰͨ͠ɻ͏Ұݴͬͯ Β͑·͔͢?') .reprompt('͏ҰݴͬͯΒ͑·͔͢?')
.getResponse();
Response Builder 38 ଟ͗͢Δ
カテゴリに分けてみる。 39
Response Builder 40
Response Builder 41 発話系 speak/response カード系 withXXXcard Dialog Model系 delegate/ElicitXXX/addConfirmXXX
AudioPlayer系 addAudioPlayerXXX Display系 addRenderTemplateDirective Video系 addVideoAppLaunchDirective セッション管理系 withShouldEndSession
Ex.BodyTemplate 42 handlerInput.responseBuilder .speak(speechText) .reprompt(speechText) .addRenderTemplateDirective({ type: 'ListTemplate1', backButton: 'HIDDEN',
backgroundImage: logoImage, listItems: listitems, title: 'ϝχϡʔ', token : gToken, }) .getResponse();
43 Response Builder Tips ResponseBuilderはバラバラに書いて良い
44 Response Builder Tips handlerInput.responseBuilder .speak(‘͜Ε͚ͩͩͱ͚ͩ͢’); if (canReprompt) { .reprompt(‘͜Ε͕ೖΔͱ͍͔͚ʹͳΔ’);
} handlerInput.responseBuilder.getResponse();
Response Builder Tips • じゃんけんであいこの時だけ もう⼀度聞き直す • ディスプレイのついているデバイスからの リクエストのみDisplayRenderをつける 45
Attribute Manager 46
47 Alexa-SDK V2Ͱͷηογϣϯཧ AttributeManager RequestAttributes SessionAttributes PersistentAttributes
͍ํ let attributes = await handlerInput.attributesManager.getPersistentAttributes() handlerInput.attributesManager.setPersistentAttributes(a ttributes); await handlerInput.attributesManager.savePersistentAttributes(
);
͍ํ
͍ํ
None