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

Amazon Alexa Development

Ryan Chung
February 27, 2019

Amazon Alexa Development

Ryan Chung

February 27, 2019

Transcript

150 slides
  1. Amazon Alexa Dev – [email protected] Amazon Alexa Development • 概述

    • 開發流程介紹 • 實作:Hello World! • 實作:ASK CLI • 實作:Hello CLI • 實作:讀取使用者輸入 • 實作:Alexa, tell me a cold joke. • 如何除錯? • 實作:增加美式感嘆詞 • 實作:隨機網路笑話 2
  2. Amazon Alexa Dev – [email protected] Amazon Alexa Development • 官方範例:Quiz

    Game Skill • 官方範例:Trivia Skill • 官方範例:How-To Skill • 官方範例:Team Look up • 上架資訊 3
  3. Amazon Alexa Dev – [email protected] Alexa Devices $179.99 US$49.99 US$129.99

    插電使用 插電使用 電量充飽 約9hr 聲控 聲控 按鈕 / 聲控 單聲道 立體聲 立體聲 & 杜比 4
  4. Amazon Alexa Dev – [email protected] 56,750 第三方技能 Alexa News 13

    付費技能 In Skill Purchase Amazon Pay 1億 智慧喇叭銷售 89 國家可訂購Echo 6 語言 (英德西法意日) Source: Voicebot.ai 2018/12 英式英文 美式英文 加拿大式英文 印度式英文 澳洲式英文
  5. Amazon Alexa Dev – [email protected] 最熱門的技能種類 (2018/10) 1. Games, Trivia

    & Accessories (Over 8000) 2. Music & Audio(Over 5000) 3. News (Over 4000) 4. Education & Reference(Over 4000) 5. Lifestyle(Over 4000) 6. Novelty & Humor (Over 2000) 7. Productivity (Over 1000) 8. Smart Home (Over 1000) 9. Business & Finace (Over 1000) 10.Health & Fitness (Over 1000) 15
  6. Amazon Alexa Dev – [email protected] 播放電影預告片 Show me some latest

    movies. Play the trailer for number X. 17 https://www.youtube.com/watch?v=aKg85qEFMHs
  7. Amazon Alexa Dev – [email protected] 播放音樂 • Just say, “Alexa!”

    and then… – “Play [song name] by [artist]”. – “Pause” pauses the currently playing track. – “Play [Discover Weekly] playlist”. – “Volume up/down” turns volume up or down. – “Stop” stops the currently playing track. 19
  8. Amazon Alexa Dev – [email protected] 可以跟Alexa聊什麼? Are you hungry? I

    don't get hungry or thirsty, but thank you for asking. 21
  9. Amazon Alexa Dev – [email protected] 可以跟Alexa聊什麼? Do you have a

    brain? I don't have a brain like you do. My smarts live in the cloud. 22
  10. Amazon Alexa Dev – [email protected] 可以跟Alexa聊什麼? Are you hot? No,

    I don't really feel hot or cold, but thanks for asking. 24
  11. Amazon Alexa Dev – [email protected] 可以跟Alexa聊什麼? Can you speak Chinese?

    I speak fluent English and conversational Pig Latin. My accent is atrocious, but it's good enough to keep me from getting lost in Pig Latium. 25
  12. Amazon Alexa Dev – [email protected] 可以跟Alexa聊什麼? Good morning Good morning,

    and happy birthday to comedian Ellen Degeneres. She's a funny lady who loves to dance. I'm pretty sure we'd be BFFs, if we ever got a chance to hang out! 29
  13. Amazon Alexa Dev – [email protected] 可以跟Alexa聊什麼? How much are you?

    You can search on Amazon.com to see how much I cost. 30
  14. Amazon Alexa Dev – [email protected] 語音助理技能設計方向 • 讓人們更快達成目的 • 語音控制音樂播放

    Fast • 讓人們更簡單地達成目的 • 語音控制電燈開關、語音設定倒數計時 Easy • 增添生活趣味 • 具有挑戰性的遊戲 Fun Source: Voice Design Guide – Amazon Alexa 32
  15. Amazon Alexa Dev – [email protected] 建立應用程式功用與使用者情境 • 界定用途與功能 – 這個技能的用途是什麼?為什麼大家會想要用?

    – 人們會怎麼使用這個技能,前中後的情境? – 人們可以從這個技能中得到什麼獨特的體驗,是別 的方式沒有的? • 界定使用者情境 – 使用者可以用這個技能做什麼、不能做什麼 – 使用者可以從這個技能中獲得什麼資訊? – 使用者如何啟動這個技能? – 這個技能有哪些特色? – 是不是有一些資訊需要從網站或APP中取得? 34
  16. Amazon Alexa Dev – [email protected] 人機互動腳本準則 • 以人們真正會說的話來設計,而不是那種文章上的口吻 • 不要假設使用者知道要怎麼做或是知道會發生什麼事

    真實 • 避免使用有多重含義的詞句、片語 • 引導使用者提供必要的資訊 明確 • 清楚地把選項呈現出來 • 一般而言,一次不要丟出超過三個選項 • 一次向使用者要一個資訊 簡單 35
  17. Amazon Alexa Dev – [email protected] Alexa Skill Type • Custom

    skill – 網路服務介接 – 互動遊戲 • Smart Home Skill API – 開關燈 – 溫度控制 • Flash Briefing Skill API – 每日笑話 – 定時新聞 • Video Skill API 36
  18. Amazon Alexa Dev – [email protected] Alexa Skill Kit • 前端:設定互動模式

    – https://developer.amazon.com/alexa – Name, Invokation – Utterances, Slot type, Intent Schema • 後端:程式邏輯開發與儲存 – https://aws.amazon.com/tw/lambda/ – Node.js 37 Source: Codecademy
  19. Amazon Alexa Dev – [email protected] ASK 設定 • Intent Schema

    – 使用者的意圖,以及對應可執行的動作 • Custom Slot Type – 特定資料型態與內容 • Sample Utterance – 例句,將使用者的輸入對應至意圖 38
  20. Amazon Alexa Dev – [email protected] 前端:互動模式建立 • 在Amazon Developer站中的Alexa建立新技能 43

    https://developer.amazon.com/alexa-skills-kit • 第一次使用會需要建立帳號
  21. Amazon Alexa Dev – [email protected] 設定Invocation Name:my hello robot •

    喚醒語,你的語音助理技能的名稱 48 my hello robot
  22. Amazon Alexa Dev – [email protected] 前端:互動模式建立 • Name:HelloPracticeMMDD – 專案名稱,若有要上架就會是顯示的名稱

    – 須介於2-50個字元 • Invocation Name:my hello robot – 喚醒語 – Alexa用以判斷要使用哪一個第三方的技能 – 使用案例「Alexa, open my hello robot.」 – 使用案例二「Alexa, ask my hello robot tell me a joke. 」 • 其他的用預設值 • Save model 49
  23. Amazon Alexa Dev – [email protected] 檢視程式碼 • 按下上方分頁中的「Code」分頁 53 •

    找到HelloWorldIntentHandler,變更一下回應 文字,按下上方的Save、再按下Deploy
  24. Amazon Alexa Dev – [email protected] 測試 • 按下上方分頁中的「Test」分頁 • 設定為「Development」

    54 • 在測試區輸入「ask my hello robot howdy」 • 如果有順利出現客製化的回應代表完成!
  25. Amazon Alexa Dev – [email protected] Lab:修改技能開啟歡迎語 • 如何客製化「open my hello

    robot」的回應? – 開啟技能是由哪一個Intent處理器來負責的? 55
  26. Amazon Alexa Dev – [email protected] 安裝與設定ASK CLI Alexa Skills Kit

    Command Line Interface 58 https://developer.amazon.com/docs/smapi/quick-start-alexa-skills-kit-command-line-interface.html 1. Amazon Developer 帳號 2. 電腦安裝Node.js 3. 安裝Node.js的windows-build-tools套件(Win only) npm install -g --production windows-build-tools 4. 建立AWS IAM角色,足以存取Lambda的權限 https://developer.amazon.com/docs/smapi/manage-credentials- with-ask-cli.html#create-aws-credentials 5. 安裝與初始化ASK CLI npm install -g ask-cli ask init
  27. Amazon Alexa Dev – [email protected] 開發前準備事項 • an Amazon Web

    Services (AWS) account • an AWS Profile • an Amazon Developer Portal account • the ASK CLI tool 59
  28. Amazon Alexa Dev – [email protected] AWS Profile • 先確定已建立AWS帳號 •

    進入 https://console.aws.amazon.com • 搜尋IAM,進入該服務 • Users -> Add user • 取名為cli-user、Access type將Programmatic access打勾 • 將AdministratorAccess打勾,Attach existing policies directly • Create user 60
  29. Amazon Alexa Dev – [email protected] 裡面放config與credentials檔案 64 [my-cli-user-profile] region=us-east 1

    aws_access_key_id=YOUR_ACCESS_KEY_ID aws_secret_access_key=YOUR_SECRET_ACCESS_KEY
  30. Amazon Alexa Dev – [email protected] ASK CLI Setup - Profile

    • 終端機 ask init –p my-cli-user-profile • 在指令列中選擇對應的profile • 登入Amazon帳號,允許存取 • 完成設定 66
  31. Amazon Alexa Dev – [email protected] 終端機 • ask new •

    選擇Node.js V8 • 選擇Hello World Template • 取一個技能名稱:hello-world-cli • cd hello-world-cli • ask deploy (每次修改完程式碼) 68
  32. Amazon Alexa Dev – [email protected] VS Code • 用VS Code打開剛才產生的

    資料夾 • 看一下models資料夾裡面 的en-US.json • 確認invocationName為何 – hello world • 確認HelloWorldIntent的 samples有哪些 – hello 69
  33. Amazon Alexa Dev – [email protected] 終端機進行測試 • ask simulate -l

    en-US -t "ask hello world hello" -l:Language -t:text to send 70
  34. Amazon Alexa Dev – [email protected] Lab (記得 ask deploy) •

    修改打招呼回應的內容 • 修改開啟技能的回應內容 • 增加更多對應至HelloWorldIntent的例句 • 修改Invocation Name (喚醒語) 71
  35. Amazon Alexa Dev – [email protected] 讀取使用者輸入 • 透過 reprompt 可以讓使用者進行輸入

    • 使用者的輸入會被放在 handlerInput.requestEnvelope.request.intent.slots.yourSlotName.value 74
  36. Amazon Alexa Dev – [email protected] 建立技能、設定Intent與Slot • 建立ASK技能,設定Name與Invocation Name –

    name : one-quiz-xxx – template:Hello World – Invocation Name:one quiz xxx • 建立新的Intent:AnswerIntent • 建立新的Slot Type:TrainingProgram – Slot Values • Java Developer • App Developer • Artificial Intelligence Engineer 75
  37. Amazon Alexa Dev – [email protected] 設定例句句型 • 設定AnswerIntent的例句 – I

    think the most popular program is { } – 設定Slot name為Course • Slot Type設定為TrainingProgram 76
  38. Amazon Alexa Dev – [email protected] 繼續增加更多例句 • I think it's

    {Course} • It is {Course} • The answer is {Course} • It should be {Course} 77
  39. Amazon Alexa Dev – [email protected] 終端機 • 建立專案 ask new

    • 選擇執行環境 Node.js V8 • 選擇樣板 Hello World • 設定技能名稱 one-quiz • 建立完成 78
  40. Amazon Alexa Dev – [email protected] VS Code • 開啟專案資料夾 •

    編輯 models/en-US.json – 設定Invocation Name – 增加AnswerIntent、samples、slots – 增加一個type為TrainingProgram、設定相關value 79
  41. Amazon Alexa Dev – [email protected] 部署與測試 • 終端機部署 ask deploy

    • 終端機測試 ask dialog -l en-US 90 • 網站測試 alexa dev site -> Test
  42. Amazon Alexa Dev – [email protected] 實作:Alexa, tell me a cold

    joke. • 任務 – 讓Alexa隨機說出一個冷笑話 • 建構步驟: – 設定可接受的指令 – 設定可使用的冷笑話 – 進行測試 92
  43. Amazon Alexa Dev – [email protected] Alexa Skills Kit 測試 –

    模擬使用者行為、檢視回應結果是否正確 部署 – 上傳至Alexa開發前端、AWS Lambda後端 專案建立與修改 – 意圖回應、資訊接收與處理 設計 Voice UI – 意圖、例句、特殊資料型態 93
  44. Amazon Alexa Dev – [email protected] 建立技能、設定Intent與Slot • 建立ASK技能,設定Name與Invocation Name –

    name : my-cold-joke-xxxx – template:Hello World – Invocation Name:you go cold joke • 建立新的Intent:GetNewJokeIntent 94
  45. Amazon Alexa Dev – [email protected] 終端機 • 建立專案 ask new

    • 選擇執行環境 Node.js V8 • 選擇樣板 Hello World • 設定技能名稱 my-cold-joke-xxxx • 建立完成 96
  46. Amazon Alexa Dev – [email protected] VS Code • 開啟專案資料夾 •

    編輯 models/en-US.json – 設定Invocation Name:you go cold joke – 增加Intent:GetNewJokeIntent • 在這個Intent底下增加 samples – suprise me with a cold joke – shoot me a cold joke – give me a joke – give me a cole joke – tell me a joke – tell me a cold joke 97
  47. Amazon Alexa Dev – [email protected] 部署與測試 • 終端機部署 ask deploy

    • 終端機測試 ask dialog -l en-US 107 • 網站測試 alexa dev site -> Test
  48. Amazon Alexa Dev – [email protected] 應用程式邏輯 tell me a joke

    tell me a cold joke give me a joke give me a cold joke shoot me a cold jpke Surprise me with a cold joke Joke 1 Joke 2 Joke 3 Joke 4 Joke 5 Joke 6 Joke 7 Joke 8 Joke 9 Joke 10 108 Intent : GetNewJoke
  49. Amazon Alexa Dev – [email protected] Invocation Name • 兩個單字以上,都小寫,用空格隔開 •

    不能用的單字: – launch, ask, tell, load, begin, enable – Alexa, Amazon, Echo, Computer – skill, app 109
  50. Amazon Alexa Dev – [email protected] 回到AWS Lambda Function • 在函數列表中,找到技能對應的函數

    • 切換至Monitoring分頁 111 https://console.aws.amazon.com/lambda/ • 點擊 View logs in CloudWatch • 依執行時間將Log Streams 展開檢視 • 觀察是否有Error訊息
  51. Amazon Alexa Dev – [email protected] 功能 • 可以直接問美國一個州的相關資訊 • 請電腦出10個題目來答,並能計算分數

    125 下載範例程式 • 建立專案 ask new • 選擇執行環境 Node.js V8 • 選擇樣板 Quiz Game • 設定技能名稱 quiz-game-practice-xxx • 建立完成
  52. Amazon Alexa Dev – [email protected] VS Code • 開啟專案資料夾 •

    編輯 models/en-US.json – 設定Invocation Name:quiz game practice 126
  53. Amazon Alexa Dev – [email protected] 功能 • 選擇題問答 • 請電腦出題目來答,並能計算分數

    131 下載範例程式 • 建立專案 ask new • 選擇執行環境 Node.js V8 • 選擇樣板 Trivia • 設定技能名稱 trivia-practice-xxx • 建立完成
  54. Amazon Alexa Dev – [email protected] VS Code • 開啟專案資料夾 •

    編輯 models/en-US.json – 設定Invocation Name:practice trivia 132
  55. Amazon Alexa Dev – [email protected] 功能 • 問答題問答 • 請電腦選題目來問

    137 下載範例程式 • 建立專案 ask new • 選擇執行環境 Node.js V8 • 選擇樣板 How To • 設定技能名稱 howto-practice-xxx • 建立完成
  56. Amazon Alexa Dev – [email protected] VS Code • 開啟專案資料夾 •

    編輯 models/en-US.json – 設定Invocation Name:practice how to 138
  57. Amazon Alexa Dev – [email protected] 觀察 • 觀察 index.js –

    如何進行比對,找到對應的項目? • 觀察 recipes.js – key : value 140
  58. Amazon Alexa Dev – [email protected] 練習 • 將 How To範例改成自己喜歡的問答

    – 電影簡介 – 藝人介紹 – 科學名詞查詢 – 球員資料 – .... 141
  59. Amazon Alexa Dev – [email protected] 功能 • 依條件找尋Alexa傳教士 – 依所在城市

    – 依資訊類別 • twitter、github、linkedin – 依姓名 – 追問詳情 – 追問特定資訊 143
  60. Amazon Alexa Dev – [email protected] 144 下載範例程式 • 建立專案 ask

    new • 選擇執行環境 Node.js V8 • 選擇樣板 Team Lookup • 設定技能名稱 team-lookup-practice-xxx • 建立完成
  61. Amazon Alexa Dev – [email protected] VS Code • 開啟專案資料夾 •

    編輯 models/en-US.json – 設定Invocation Name:practice team lookup 145
  62. Amazon Alexa Dev – [email protected] 觀察資料 • 名字 • 姓氏

    • 職稱 • 城市名稱 • twitter帳號 • twitter帳號口語 147 • github帳號 • github帳號口語 • linkedin帳號 • linkedin帳號口語 • 加入日期 • 性別
  63. Amazon Alexa Dev – [email protected] 範例綜覽 • Quiz (美國各州) –

    每筆資料有各種屬性 • Trivia Test – 自訂選擇題測驗 • How To – 問答集資料庫 • Team Lookup – 依條件查詢人物資料 148 • Hello – 打招呼有回應 • OneQuiz – 一個題目判斷答案 • Tell me a joke – 任意挑選一筆資料 • Tell me a on-line joke – 網路介接資料
  64. Amazon Alexa Dev – [email protected] 內建資料型態 • AMAZON.Actor • AMAZON.AggregateRating

    • AMAZON.Airline • AMAZON.Airport • AMAZON.Animal • AMAZON.Athlete • AMAZON.Color • ..... 149 https://developer.amazon.com/docs/custom-skills/slot-type-reference.html#list-types
  65. Amazon Alexa Dev – [email protected] 上架 Publishing Information • 類別

    Category • 測試引導:提供給測試者參考 – 特殊指令、權限 • 銷售地區:全部國家或限定部分地區 • 簡短介紹、完整介紹 • 例句(至少3句) – 單一指令型 • Alexa, ask cold joke to tell me a joke. – 進入技能後互動型 • Alexa, open cold joke. • Alexa, give me a joke. 150
  66. Amazon Alexa Dev – [email protected] 上架 Publishing Information • 關鍵字:方便搜尋

    • 圖片 – 小圖示:108x108 PNG/JPG – 大圖示:512x512 PNG/JPG • 送出審核(需等待數天) 151
  67. Amazon Alexa Dev – [email protected] 七個讓顧客愛上你的技能的訣竅 1. 讓一項工作透過語音變得快速又簡單 2. 技能的名稱直覺又好記

    3. 設計清楚但又不繁雜的提示來引導使用者 4. 避免模稜兩可 5. 帶給使用者驚喜與樂趣 6. 規律地提供使用者新的內容 7. 服務必須是持續可靠不中斷的 152 Source:Amazon.com
  68. Amazon Alexa Dev – [email protected] 開啟螢幕顯示 • Developer開發站 -> 左邊

    點擊 Interfaces • Display Interface 開關打開 • 上面 Save Interfaces -> Build Model 153

More Decks by Ryan Chung

Other Decks in Technology