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

messaging apiとLine Payで広がるLINE Botの世界

messaging apiとLine Payで広がるLINE Botの世界

プログラミング生放送勉強会 第55回@福岡

で発表する内容のスライドになります。

https://atnd.org/events/100847?fbclid=IwAR2UvS9keRk7VZZG1Gybp2MxawGVM16Fgv5Os8S6Nl9m-u2XBiYAV5Z5eE4

Yutaka Fujisaki

November 03, 2018
Tweet

More Decks by Yutaka Fujisaki

Other Decks in Technology

Transcript

  1. • ౻࡚ɹ༏ɹ • גࣜձࣾΦϧλʔϒʔεॴଐɹ • ۀ຿ࣥߦ໾һCOOɹ • ௚ۙͷλεΫɹ • ෱Ԭࢢૈେ͝ΈऩूLINEBot

    • JAWS-UG෱ԬίΞϝϯόʔ(#jawsugfuk) • ౰ॳ͸ϝΠϯاըͱ࢘ձˠ࠷ۙ͸ओ ʹձ৔ఏڙ܎ • ϰΟδϡΞϧܥͱWACKॴଐΞΠυϧ͕ ޷͖ Messaging APIͱLINE PayͰ޿͕ΔLINE Botͷੈք[2018೥11݄03೔ϩάϥϛϯάੜ์ૹษڧձ@Fukuoka Gtowth Next] 2
  2. ຊ೔ͷ಺༰ • LINE platformʹ͍ͭͯ • ຊ೔࢖͏ػೳ • LINE BotͰͷ։ൃʹ͍ͭͯ •

    αϯϓϧLINE Botͷத਎Λඥղ͖ͳ͕Β͓࿩͠·͢ • αϯϓϧ͸ express+node.js • https://github.com/y-fujisaki/pronama-linebot Messaging APIͱLINE PayͰ޿͕ΔLINE Botͷੈք[2018೥11݄03೔ϩάϥϛϯάੜ์ૹษڧձ@Fukuoka Gtowth Next] 4
  3. ར༻͢Δػೳ • ϝοηʔδ • ΫΠοΫϦϓϥΠ • LINE Front-end Framework(LIFF) •

    LINE pay Messaging APIͱLINE PayͰ޿͕ΔLINE Botͷੈք[2018೥11݄03೔ϩάϥϛϯάੜ์ૹษڧձ@Fukuoka Gtowth Next] 10
  4. LINEͰΞϓϦΛ࡞ΔϝϦοτ • Πϯετʔϧෆཁ • 7600ສਓͷϢʔβʹΞϓϩʔνՄೳ • UIͷ࡞ΓࠐΈෆཁ • ૢ࡞આ໌͕΄ͱΜͲ͍Βͳ͍ Messaging

    APIͱLINE PayͰ޿͕ΔLINE Botͷੈք[2018೥11݄03೔ϩάϥϛϯάੜ์ૹษڧձ@Fukuoka Gtowth Next] 12
  5. LINE Pay1 • LINEΞϓϦʹඪ४౥ࡌ͞ΕͨɺαʔόʔܕిࢠϚωʔΛத৺ ͱܾͨ͠ࡁαʔϏε 1 LINE Pay৘ใར׆༻ʹ͍ͭͯv5ΑΓ ϦϯΫ. Messaging

    APIͱLINE PayͰ޿͕ΔLINE Botͷੈք[2018೥11݄03೔ϩάϥϛϯάੜ์ૹษڧձ@Fukuoka Gtowth Next] 15
  6. SDK:ରԠݴޠ • ެࣜ • Java • PHP • Go •

    Perl • Python • Node.js • ίϛϡχςΟ • C# • ஫ҙɿ։ൃ؀ڥߏங౳ͷલ४උ͸লུ Messaging APIͱLINE PayͰ޿͕ΔLINE Botͷੈք[2018೥11݄03೔ϩάϥϛϯάੜ์ૹษڧձ@Fukuoka Gtowth Next] 18
  7. ։ൃࢀߟURL • node.js • 1࣌ؒͰLINE BOTΛ࡞ΔϋϯζΦϯ (ࢿྉ+Ϩϙʔτ) in NodeֶԂࡇ2017 #nodefest

    • https://qiita.com/n0bisuke/items/ceaa09ef8898bee8369d • C# • LINE ͷ Bot ։ൃ ௒ೖ໳ʢલฤʣ θϩ͔ΒԠ౴͕Ͱ͖Δ·Ͱ C# ฤ(@kenakam༷) • https://qiita.com/kenakamu/items/e0b194a82e4141b30c95 • LambdaͰ͸͡ΊͯͷLINE BotΛ࡞Δ(ʹΌʔ༷) • https://dev.classmethod.jp/etc/lambda-line-bot-tutorial/ Messaging APIͱLINE PayͰ޿͕ΔLINE Botͷੈք[2018೥11݄03೔ϩάϥϛϯάੜ์ૹษڧձ@Fukuoka Gtowth Next] 19
  8. ։ൃͷྲྀΕ (LINE Botલ४උ) • LINE Developers ίϯιʔϧͱ͍͏WebαΠτʹొ࿥Λߦ͍·͢ • ࢀߟɿhttps://qiita.com/nkjm/items/38808bbc97d6927837cd •

    LINE Developers ͰʮChannelʯΛ࡞੒͢Δ • Φ΢Ϝฦ͢͠ΔBotͷຊମϓϩάϥϜΛ։ൃ͠ɺΫϥ΢υ্ͷ࣮ߦ؀ڥ΁ͰσϓϩΠ • BotͷChannelͷઃఆͰWebhookΛઃఆɺϝοηʔδͳͲͷΠϕϯτ͕BotͰड͚औ ΕΔΑ͏ʹ͠·͢ Messaging APIͱLINE PayͰ޿͕ΔLINE Botͷੈք[2018೥11݄03೔ϩάϥϛϯάੜ์ૹษڧձ@Fukuoka Gtowth Next] 22
  9. ։ൃͷྲྀΕ:LINE pay ͷొ࿥ • LINE Pay DevelopersʹΞΫηε • https://pay.line.me/jp/ developers/techsupport/

    sandbox/creation?locale=ja_JP) • sandboxɺuserͷ࡞੒Λ࣮ࢪ • submitΛԡ͢ͱϝʔϧΞυϨεѼ ʹ؅ཧը໘ͷURL͕ඈΜͰ͖·͢ Messaging APIͱLINE PayͰ޿͕ΔLINE Botͷੈք[2018೥11݄03೔ϩάϥϛϯάੜ์ૹษڧձ@Fukuoka Gtowth Next] 23
  10. ։ൃͷྲྀΕ:LINE pay ͷొ࿥ • ొ࿥ͨ͠ϝʔϧΞυϨεʹuser_idͱ password͕ಧ͘ • ϝʔϧʹϩάΠϯ༻ͷURL͕ࢦఆ͞Ε͍ͯ ΔͷͰ͔ͦ͜ΒϩάΠϯ •

    ొ࿥࣌ɺॏෳϝΞυ͸ڐՄ͞Ε͍ͯ·ͤΜ • ܾࡁ࿈ಈ؅ཧ-࿈ಈΩʔ؅ཧʹ͋Δɺνϟϯ ωϧIDͱνϟϯωϧγʔΫϨοτΩʔΛऔಘ • Botଆͷ؀ڥม਺ʹηοτ͠·͢ Messaging APIͱLINE PayͰ޿͕ΔLINE Botͷੈք[2018೥11݄03೔ϩάϥϛϯάੜ์ૹษڧձ@Fukuoka Gtowth Next] 24
  11. ։ൃͷྲྀΕ(ϝοηʔδͷૹड৴ͷ৔ ߹) 1. ର࿩ετʔϦʔΛ࡞੒ 2. πʔϧͰର࿩༻ϝοηʔδςϯϓϨʔτΛ࡞Δ 3. ର࿩Λॲཧ͢ΔAPIΛ࡞੒ 4. ϩʔΧϧ؀ڥͰಈ࡞֬ೝ(ngrokར༻ͯ͠ϩʔΧϧΛެ։)

    5. Ϋϥ΢υ্ຊ൪σϓϩΠ Messaging APIͱLINE PayͰ޿͕ΔLINE Botͷੈք[2018೥11݄03೔ϩάϥϛϯάੜ์ૹษڧձ@Fukuoka Gtowth Next] 25
  12. ஫ҙࣄ߲ • LINE DevelopersͰొ࿥Ͱ͖Δ webhookAPI͸̍ͭͷΈ • ؅ཧը໘͔Βͷมߋ͕ඞཁ(APIͳ ͍͔ͳɾɾɾ) • ϩʔΧϧͰςετͯ͠ɺεςʔδ

    ϯάΛ੾Γସ͑Δࡍ໘౗ • ϩʔΧϧɺεςʔδϯάɺຊ൪ͱ ̏ͭͷνϟϯωϧΛ༻ҙͨ͠΄͏ ͕ྑͦ͞͏ Messaging APIͱLINE PayͰ޿͕ΔLINE Botͷੈք[2018೥11݄03೔ϩάϥϛϯάੜ์ૹษڧձ@Fukuoka Gtowth Next] 27
  13. ετʔϦʔ 1. ʮτοϓʯͱݴͬͨΒBotͷτοϓϝοηʔδΛදࣔ͢Δ 2. ʮ঎඼ҰཡʯͱݴͬͨΒ঎඼Λදࣔ͢Δ 3. ঎඼Ұཡ͸FlexϝοηʔδͷΧϧʔηϧͰදࣔ 4. LINE payࢧ෷͍ϘλϯԡԼͰɺLINE

    payͷܾࡁॲཧΛ࣮ࢪ 5. ൪֎ฤɿLIFFͰϓϩੜͪΌΜHPΛදࣔ Messaging APIͱLINE PayͰ޿͕ΔLINE Botͷੈք[2018೥11݄03೔ϩάϥϛϯάੜ์ૹษڧձ@Fukuoka Gtowth Next] 29
  14. ։ൃ͢Δ΋ͷ • ϝοηʔδςϯϓϨʔτ(FlexɺΫΠοΫϦϓϥΠ) • LIFFͷઃఆ • LINE botͱ΍ΓͱΓ͢ΔAPI(/webhook) • ϦϓϥΠϝοηʔδॲཧ

    • LINE pay΁঎඼৘ใͷҾ͖౉͠ • LINE payͷॲཧ݁ՌΛड͚औΔAPI(/pay/confirm) Messaging APIͱLINE PayͰ޿͕ΔLINE Botͷੈք[2018೥11݄03೔ϩάϥϛϯάੜ์ૹษڧձ@Fukuoka Gtowth Next] 31
  15. Flexϝοηʔδ • ςΩετɺը૾ɺϘλϯΛࣗ༝ʹϨ ΠΞ΢τͰ͖Δ • ϨΠΞ΢τ͸JSONͰهड़ • JSONͰهड़ͨ͠ϝοηʔδΛͦͷ· ·ૹ৴Ͱ͖Δ Messaging

    APIͱLINE PayͰ޿͕ΔLINE Botͷੈք[2018೥11݄03೔ϩάϥϛϯάੜ์ૹษڧձ@Fukuoka Gtowth Next] 32
  16. ϝοηʔδJSONͷ δΣωϨʔτ • FlexϝοηʔδγϡϛϨʔλ·ͨ͸ɺ LINE Bot Designer(࠷ۙରԠ) { "type": "bubble",

    // ᶃϝοηʔδશମͷType "body": { // ᶄϝοηʔδͷຊจ "type": "box", // ᶅຊจશମΛғΉBOXΛ഑ஔ "layout": "horizontal", "contents": [ { "type": "text", // ᶆίϯςϯπΛ഑ஔ(ςΩετͷ৔߹) "text": "ϓϩੜʂʂ" } ] } } Messaging APIͱLINE PayͰ޿͕ΔLINE Botͷੈք[2018೥11݄03೔ϩάϥϛϯάੜ์ૹษڧձ@Fukuoka Gtowth Next] 38
  17. LIFFͷઃఆ npm install -g liff liff init {LINE_ACCESS_TOKEN} liff add

    https://pronama.jp/ tall Messaging APIͱLINE PayͰ޿͕ΔLINE Botͷੈք[2018೥11݄03೔ϩάϥϛϯάੜ์ૹษڧձ@Fukuoka Gtowth Next] 39
  18. LINE botͱ΍ΓͱΓ͢ΔAPI • webhook • /pay/confirm https://github.com/y-fujisaki/pronama-linebot/blob/master/ server.js Messaging APIͱLINE

    PayͰ޿͕ΔLINE Botͷੈք[2018೥11݄03೔ϩάϥϛϯάੜ์ૹษڧձ@Fukuoka Gtowth Next] 41
  19. ௥Ճ͍ͨ͠΋ͷ • Ϧονϝχϡʔ • LINEϩάΠϯ • طଘͷECͱͷ࿈ܞ΋Ͱ͖Δ • ސ٬ͷച্ʹ͋ΘͤͯΫʔϙϯൃߦͱɾɾɾ •

    LIFFͷॆ࣮ • ސ٬৘ใೖΕͯ΋ΒͬͯϢʔβొ࿥ͱ͔ • Ξϯέʔτͱ͔ Messaging APIͱLINE PayͰ޿͕ΔLINE Botͷੈք[2018೥11݄03೔ϩάϥϛϯάੜ์ૹษڧձ@Fukuoka Gtowth Next] 43
  20. ·ͱΊ • LINE PayΛ௥Ճ͢Δ͜ͱͰɺ՝ۚΛLINE಺Ͱ׬݁Ͱ͖Δ • ECͰ͸େ͖ͳίετΛ͔͚Δ͜ͱͳ͘ɺ͋ΒͨͳνϟϯωϧΛ௥ ՃՄೳʂ • Ϗδωεͱͯ͠ऩӹ͕ੜ·ΕΔ΋ͷͱͳΔ •

    εςοϓ͕৑௕ʹͳΒͳ͍Α͏ʹ͖Λ͚͍ͭͨʢϢʔβʔͷҰಈ࡞͕ 3ΫϦοΫҎ಺͠ͳ͍ͱ཭ΕͪΌ͏ʣ • ଞͷ୅ସ͑खஈΑΓޮ཰త͔ʁͱ͍͏ࢹ఺େࣄ Messaging APIͱLINE PayͰ޿͕ΔLINE Botͷੈք[2018೥11݄03೔ϩάϥϛϯάੜ์ૹษڧձ@Fukuoka Gtowth Next] 44
  21. • ςΩετϝοηʔδ • ελϯϓϝοηʔδ • ը૾ϝοηʔδ • Ի੠ϝοηʔδ Messaging APIͱLINE

    PayͰ޿͕ΔLINE Botͷੈք[2018೥11݄03೔ϩάϥϛϯάੜ์ૹษڧձ@Fukuoka Gtowth Next] 52
  22. • Ґஔ৘ใϝοηʔδ • ΠϝʔδϚοϓϝοηʔδ • ςϯϓϨʔτϝοηʔδ • Flexϝοηʔδ • ΫΠοΫϦϓϥΠ

    Messaging APIͱLINE PayͰ޿͕ΔLINE Botͷੈք[2018೥11݄03೔ϩάϥϛϯάੜ์ૹษڧձ@Fukuoka Gtowth Next] 53
  23. messaging API ؔ࿈ϦϯΫ • ֓ཁυΩϡϝϯτ • https://developers.line.me/ja/docs/messaging-api/ • APIϦϑΝϨϯε •

    https://developers.line.me/ja/reference/messaging-api/ • ϦϦʔεϊʔτ • https://developers.line.me/ja/docs/messaging-api/release- notes/ Messaging APIͱLINE PayͰ޿͕ΔLINE Botͷੈք[2018೥11݄03೔ϩάϥϛϯάੜ์ૹษڧձ@Fukuoka Gtowth Next] 65
  24. πʔϧ • (ެࣜ)Bot Designer • (ެࣜ)Flex ϝοηʔδγϛϡϨʔλʔ • LIFF πʔϧ

    • LINE γϛϡϨʔλʔ • Rich Menus Manager Messaging APIͱLINE PayͰ޿͕ΔLINE Botͷੈք[2018೥11݄03೔ϩάϥϛϯάੜ์ૹษڧձ@Fukuoka Gtowth Next] 66
  25. Bot Designer • LINE Botͱͷձ࿩ΛϓϨϏϡʔ͢ΔͨΊͷΞϓϦέʔγϣϯ (ެࣜ) • ར༻ऀ΁ͷϓϨθϯςʔγϣϯ • ϝοηʔδJSONδΣωϨʔλʔ

    • ΠϝʔδϚοϓδΣωϨʔλʔ https://developers.line.me/ja/services/bot-designer/ Messaging APIͱLINE PayͰ޿͕ΔLINE Botͷੈք[2018೥11݄03೔ϩάϥϛϯάੜ์ૹษڧձ@Fukuoka Gtowth Next] 67
  26. Flex ϝοηʔδγϛϡϨʔλʔ • Flex Message ͷදࣔΛ֬ೝͰ͖ΔγϡϛϨʔλʔ(ެࣜ) • ϝοηʔδදࣔ֬ೝ • FlexϝοηʔδJSONδΣωϨʔλʔ

    https://developers.line.me/ja/services/bot-designer/ Messaging APIͱLINE PayͰ޿͕ΔLINE Botͷੈք[2018೥11݄03೔ϩάϥϛϯάੜ์ૹษڧձ@Fukuoka Gtowth Next] 68
  27. LIFFπʔϧ • LINE Front-end Framework Λ؆୯ʹૢ࡞Ͱ͖Δ cli πʔϧ -syoyaࢯ ࡞

    https://www.npmjs.com/package/liff Messaging APIͱLINE PayͰ޿͕ΔLINE Botͷੈք[2018೥11݄03೔ϩάϥϛϯάੜ์ૹษڧձ@Fukuoka Gtowth Next] 69
  28. LINE γϛϡϨʔλʔ • σόοά • ΠϯεϖΫλʔ • جຊػೳ/Ϧονϝχϡʔ౳ରԠ • POC

    Ϟʔυ https://github.com/kenakamu/LINESimulator/releases Messaging APIͱLINE PayͰ޿͕ΔLINE Botͷੈք[2018೥11݄03೔ϩάϥϛϯάੜ์ૹษڧձ@Fukuoka Gtowth Next] 70
  29. LINE γϛϡϨʔλʔ • σόοά • ΠϯεϖΫλʔ • جຊػೳ/Ϧονϝχϡʔ౳ରԠ • POC

    Ϟʔυ https://github.com/kenakamu/LINESimulator/releases Messaging APIͱLINE PayͰ޿͕ΔLINE Botͷੈք[2018೥11݄03೔ϩάϥϛϯάੜ์ૹษڧձ@Fukuoka Gtowth Next] 71