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

Alexaでお金を稼ごうとしてみた / alexa-salon-2018-10

Alexaでお金を稼ごうとしてみた / alexa-salon-2018-10

Alexa Salon SP @東京〜秋のNLT(Not LT)大会〜

Hidetaka Okamoto

November 15, 2018
Tweet

More Decks by Hidetaka Okamoto

Other Decks in Programming

Transcript

  1. A l e x a Ͱ ͓ ۚ Λ Ք

    ͝ ͏ ͱ ͯ͠ Έ ͨ A l e x a S a l o n S P @ ౦ ژ ʙ ळ ͷ N LT ʢ N o t LT ʣ େ ձ ʙ
  2. H i d e t a k a O k

    a m o t o • Digitalcube Co. Ltd. • Alexa Campions • AWS Samurai 2017 in Japan
  3. h t t p s : / / b i

    t . l y / 2 B 4 B p n D
  4. · ͱ Ί A g e n d a •

    AlexaεΩϧ࣮ͬͯ͸Ք͛ΔʢՔ͛Δͱ͸͍͍ͬͯͳ͍ʣ • εΩϧͰ͓ۚΛಘΔํ๏ • Getting Started In Skill Purchase Skill
  5. εΩϧ ։ ൃ ͬͯ ҙ ֎ ͱ ग़ අ ͕

    ͔ ͞ Ή • DynamoDB్͔ͭͬͯத཭୤ͯ͠΋࠶։Ͱ͖ΔΑ͏ʹ͠Α͏ʂ • ݕࡧͷਫ਼౓্͍͔͛ͨΒAmazon Elasticsearch Service͍ΕͯΈͨ • ʢ։ൃͯ͠Δ࣌ؒʹଞͷ͜ͱͨ͠ΒΞϑΟϦΤΠτ͍͚ͨͷͰ͸ʣ
  6. A W S ͷ ແ ྉ ར ༻ ࿮ Λ

    ೺ Ѳ ͯ͠ ͓ ͜͏ h t t p s : / / a w s . a m a z o n . c o m / j p / f re e /
  7. A W S ͷ ແ ྉ ར ༻ ࿮ Λ

    ೺ Ѳ ͯ͠ ͓ ͜͏ h t t p s : / / a w s . a m a z o n . c o m / j p / f re e /
  8. Vo i c e A p p s ͸ ແ

    ྉ ͔ Β ࢖ ͑Δ h t t p s : / / v o i c e a p p s . c o m
  9. S t o r y l i n e -

    > I n v o c a b l e h t t p s : / / w w w. i n v o c a b l e . c o m /
  10. – Va s i l i S h y n

    k a re n k a “We admire all the time, efforts and creativity that you’ve put into your Alexa skills. Your live skills will be functional forever. If you want to continue editing them, you’ll have to move them off the platform because our product for professionals will be different.”
  11. ແ ྉ α ʔ Ϗ ε Λ ݡ ͘ ࢖

    ͬͯ A l e x a εΩϧ Λ ࡞ Ζ ͏ ʂ
  12. εΩϧ Ͱ ͓ ۚ Λ ಘ Δ ํ ๏ •

    AWSͷΫʔϙϯΛ֫ಘ͢Δ • AlexaͷϓϩάϥϜͰ৆ۚΛ֫ಘ͢Δ • ࣗࣾαʔϏεͱ࿈ܞͤ͞Δ • ͦ͏ͩɺΞϓϦ՝ۚ΍Ζ͏
  13. εΩϧ Ͱ ͓ ۚ Λ ಘ Δ ํ ๏ •

    AWSͷΫʔϙϯΛ֫ಘ͢Δ • AlexaͷϓϩάϥϜͰ৆ۚΛ֫ಘ͢Δ • ࣗࣾαʔϏεͱ࿈ܞͤ͞Δ • ͦ͏ͩɺΞϓϦ՝ۚ΍Ζ͏
  14. A l e x a A W S ϓ ϩ

    Ϟ ʔ γ ϣ ϯ Ϋ Ϩ δ ο τ h t t p s : / / d e v e l o p e r. a m a z o n . c o m / j a / a l e x a - s k i l l s - k i t / a l e x a - a w s - c re d i t s
  15. E C 2 ΍ S 3 ΋ Ϋ ʔϙ ϯ

    ର ৅ h t t p s : / / d e v e l o p e r. a m a z o n . c o m / j a / a l e x a - s k i l l s - k i t / a l e x a - a w s - c re d i t s
  16. εΩϧ Ͱ ͓ ۚ Λ ಘ Δ ํ ๏ •

    AWSͷΫʔϙϯΛ֫ಘ͢Δ • AlexaͷϓϩάϥϜͰ৆ۚΛ֫ಘ͢Δ • ࣗࣾαʔϏεͱ࿈ܞͤ͞Δ • ͦ͏ͩɺΞϓϦ՝ۚ΍Ζ͏
  17. Ϣʔ βʔΤ ϯ ήʔ δϝ ϯ τ ͷ ߴ ͍

    εΩϧ ʹ Ϧ ϫ ʔ υ h t t p s : / / d e v e l o p e r. a m a z o n . c o m / j a / a l e x a - s k i l l s - k i t / re w a rd s
  18. ର ৅ ͸ ̔ Χ ς ΰ Ϧ • ڭҭɾϨϑΝϨϯε

    • ϑʔυɾυϦϯΫ • ήʔϜɾτϦϏΞɾΞΫηαϦ • ϔϧεɾϑΟοτωε • ࢠͲ΋޲͚ • ϥΠϑελΠϧ • ԻָɾΦʔσΟΦ • ࢓ࣄޮ཰Խ
  19. εΩϧ Ͱ ͓ ۚ Λ ಘ Δ ํ ๏ •

    AWSͷΫʔϙϯΛ֫ಘ͢Δ • AlexaͷϓϩάϥϜͰ৆ۚΛ֫ಘ͢Δ • ࣗࣾαʔϏεͱ࿈ܞͤ͞Δ • ͦ͏ͩɺΞϓϦ՝ۚ΍Ζ͏
  20. ͨ ͱ ͑ ͹ A m a z o n

    P a y h t t p s : / / d e v e l o p e r. a m a z o n . c o m / j a / a l e x a - s k i l l s - k i t / m a k e - m o n e y / a m a z o n - p a y
  21. Ξ Χ ΢ ϯ τ Ϧ ϯ Ϋ Ͱ ࣗ

    ࣾ α ʔ Ϗ ε ͱ ͭ ͳ ͍Ͱ ՝ ۚ • ࣗࣾαʔϏεͷΞΧ΢ϯτͱAlexaΛϦϯΫ • ࣗࣾαʔϏεଆͷܾࡁγεςϜΛAlexa -> Lambdaܦ༝Ͱίʔϧ͢Δ • ࣗࣾαʔϏεͷར༻ऀ޲͚ݶఆʹ͸ͳΔ͕ɺλονΛ૿΍ͤΔ
  22. εΩϧ Ͱ ͓ ۚ Λ ಘ Δ ํ ๏ •

    AWSͷΫʔϙϯΛ֫ಘ͢Δ • AlexaͷϓϩάϥϜͰ৆ۚΛ֫ಘ͢Δ • ࣗࣾαʔϏεͱ࿈ܞͤ͞Δ • ͦ͏ͩɺΞϓϦ՝ۚ΍Ζ͏
  23. U S / E U ޲ ͚ ͳ Β ՝

    ۚ εΩϧ ͕ ग़ ͤΔ h t t p s : / / w w w. a m a z o n . c o m / H i d e t a k a - O k a m o t o - To d a y - K a n j i / d p / B 0 7 J 5 P B Q N G
  24. Ξ ϓ Ϧ ʢ εΩϧ ʣ ಺ ՝ ۚ ͷ

    छ ྨ • Entitlementɿങ੾Γɻ1౓ߪೖͨ͠Βͣͬͱ༗ޮ • Subscriptionɿఆֹ՝ۚɻΩϟϯηϧ͢Δ·Ͱͣͬͱ՝ۚ • Consumableɿ౎౓ߪೖɻ
  25. I n - S k i l l P u

    rc h a s i n g O v e r v i e w h t t p s : / / d e v e l o p e r. a m a z o n . c o m / j a / d o c s / i n - s k i l l - p u rc h a s e / i s p - o v e r v i e w. h t m l
  26. η ο τΞ ο ϓ ͸ A S K C

    L I ͔ Β ͷ Έ # Πϯετʔϧ
 $ ask new -n isp-test # ఆٛϑΝΠϧͷ࡞੒ $ ask add isp --help Usage: ask-add-isp $ ask add isp [-i|--isp-id <isp-id>] [-f|--file <file-path>] [--isp-name <name>]
  27. ର ࿩ ܗ ࣜ Ͱ ঎ ඼ ఆ ٛ ϑ

    Ν Πϧ ͷ ॳ ظ ઃ ఆ $ ask add isp --isp-name my-example-product # Ͳͷ঎඼λΠϓʹ͢Δ͔ʁ ? List of in-skill product types you can choose (Use arrow keys) › Entitlement Subscription # ςϯϓϨʔτΛͳʹʹ͢Δ͔ʁ ? List of in-skill product templates you can choose (Use arrow keys) › Entitlement_Template In-skill product my-example-product is saved to ./isps/entitlement/my-example-product.json
  28. ঎ ඼ ໊ ΍ આ ໌ จ ɾ Ձ ֨

    Λ J S O N Ͱ ఆ ٛ h t t p s : / / w w w. a m a z o n . c o m / H i d e t a k a - O k a m o t o - To d a y - K a n j i / d p / B 0 7 J 5 P B Q N G
  29. ৄ ࡉ ͸ A l e x a ϒϩ ά

    ʢ ӳ ޠ ʣ Λ h t t p s : / / a m z n . t o / 2 P m W v 9 i
  30. ৽ ͠ ͘ ௥ Ճ ͕ ඞ ཁ ͳ Π

    ϯ ςϯ τ • ߪೖ • ঎඼ৄࡉͷ֬ೝ • Ωϟϯηϧ • -> ϏϧτΠϯΠϯςϯτ͸ͳ͍ͷͰ஫ҙ
  31. g e t M o n e t i z

    a t i o n S e r v i c e C l i e n t ( ) & a d d D i re c t i v e ( )
  32. n a m e ʹ ΞΫ γ ϣ ϯ ʢ

    B u y / C a n c e l ʣ return handlerInput.responseBuilder .addDirective({ 'type': 'Connections.SendRequest', 'name': 'Buy', 'payload': { 'InSkillProduct': { 'productId': productId } }, 'token': 'correlationToken' }) .getResponse()
  33. I S P ܥ ॲ ཧ ࣮ ૷ ͷ ϙΠ

    ϯ τ • addDirectiveʹΞΫγϣϯ໊ɾ঎඼IDΛೖΕΔ • ঎඼৘ใͷऔಘ͸getMonetizationServiceClient()Λར༻ • productIdΛऔಘͯ͠addDirectiveʹ٧ΊࠐΉ • type͸`Connections.SendRequest’`
  34. I S P ܥ ॲ ཧ ࣮ ૷ ͷ ϙΠ

    ϯ τ - ̎ • type͸`Connections.SendRequest’` • ࣮ߦ݁Ռ͸ .request.typeʹ’Connections.Response’Ͱϋϯυϧ • ’Connections.Response’ + request.name Λर͏ϋϯυϥʔΛ࣮૷͢Δ • request.status.codeʹHTTPίʔυ • request.payload.purchaseResult͕’ACCEPTED’ͳΒ੒ޭ
  35. I S P ܥ ॲ ཧ ࣮ ૷ ͷ ϙΠ

    ϯ τ - ̏ • ’Connections.Response’ + request.name Λर͏ϋϯυϥʔΛ࣮૷ • ͜ͷϋϯυϥʔͷॲཧͰ͸ɺηογϣϯ͕৽͘͠ͳΔ • ߪೖલͷΞΫγϣϯΛه࿥͢Δ৔߹͸DynamoDB / S3Ͱอଘ͢Δ • AWS-SDK׬શʹཧղͯ͠ΔͳΒɺTTLͰҰ࣌อଘͰ΋ྑͦ͞͏
  36. n p m i - S a s k -

    u t i l s h t t p s : / / a s k - u t i l s . g i t h u b . i o / a s k - u t i l s /
  37. · ͱ Ί • AWSΫʔϙϯɾϦϫʔυͳͲͷࢧԉPJ͸͍Ζ͍Ζ͋Δ • εΩϧ՝ۚʢISPʣ͸US / EUͷΈ2018/11࣌఺ •

    ϋϯυϥʔͱΠϯςϯτΛ̐ʙ̒ͭ௥Ճ͢Δඞཁ͕͋Γཁ஫ҙ • Connections.SendRequestͰηογϣϯ͕੾ΕΔͷʹཁ஫ҙ • αϯϓϧεΩϧ΋͋ΔͷͰɺΈΜͳͰUSD / GBPՔ͝͏ͥʂ • ʢརӹ͕ͰΔͱ͸ݴ͍ͬͯͳ͍ʣ
  38. h t t p s : / / b i

    t . l y / 2 B 4 B p n D