ൃ ≒ We b h o o k A P I ࡞ • Alexa Service͕͛ͯ͘ΔJSON͔ΒɺϦΫΤετ༰ΛѲ • Alexa͕TTS (Text To Speech)͢ΔͨΊͷJSONΛreturn͢Δ • entrypoint̍ͭͷΈɺJSONͷσʔλͰ༰Λࣝผ͢Δ • ask sdk(Node.js / Python / Java)Λ͏͜ͱͰɺ؆୯ʹ࣮Ͱ͖Δ • ܕఆٛGitHubʹެ։͞Ε͍ͯΔͨΊɺൺֱత໎͍ʹ͍͘
৽ ͕ A l e x a ଆ ͷ ఆ ੴ • npm i -g ask-cliͰΠϯετʔϧ • ask delpoyͰAlexaεΩϧ + AWSϦιʔεΛσϓϩΠ • Lambda / IAM Role / CloudWatchͷϦιʔε͕࡞ΒΕΔ • IAMͷPolicyAWSLambdaBasicExecutionRole • DynamoDB / S3ͳͲΛ͏߹खಈͰIAM PolicyͷՃ͕ඞཁ
෦ 1 Ω ʔ ʹ ͍ Εͯ ͠ · ͏ dynamoDBDocumentClient.put({ TableName: 'TableName', Item: { [partitionKey]: userId, [attributesName]: { … } } }).promise() A S K - S D K AW S - S D K
ͱ ɺ ͜ ͏ ͠ ͨ ͍ dynamoDBDocumentClient.put({ TableName: 'TableName', Item: { [partitionKey]: userId, [attributesName]: { … } } }).promise() dynamoDBDocumentClient.put({ TableName: 'TableName', Item: { user_Id: attributesId, last_launched: attributes.last_launched, monthly_score: attributes.monthly_score, reminderTarget: attributes.reminder_target } }).promise() A S K - S D K AW S - S D K
ͯ͠ ѻ ͏ ࡍ ͷ T i p s • ask-sdk-dynamodb-persistence-adapter Λ͑؆୯ʹಋೖՄೳ • User ID / Device ID / Person IDεΩϧຖʹϢχʔΫ • ./ask-user-db/{custom_prefix}/{user_id}ͷΑ͏ͳύεͰϑΝΠϧੜ • prefixΛεΩϧ໊ʹઃఆ͢Δͱɺ̍όέοτʹूͰ͖Δ
o c s . a w s . a m a z o n . c o m / j a _ j p / l a m b d a / l a t e s t / d g / r u n n i n g - l a m b d a - c o d e . h t m l “ʮϒʔτετϥοϓʯ͕ඞཁͳͨΊɺ Lambda ؔΛݺͼग़ͨ͢ͼʹएׯͷϨΠςϯγʔ͕ൃੜ͠·͢ɻ ௨ৗɺ͜ͷԆ Lambda ؔΛॳΊͯݺͼग़ͨ͠ͱ͖ɺ ·ͨߋ৽͞Εͨͱ͖ʹൃੜ͠·͢ɻ Lambda ؔΛ࿈ଓͯ͠ݺͼग़͢߹ɺ AWS Lambda Ͱ͖ΔݶΓ࣮ߦίϯςΩετΛ࠶ར༻͠·͢ɻ” L a m b d a ʹ ί ʔ ϧ υ ελ ʔ τ ͕ ͋ Δ