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

SIer IoT LT 女子部 vol2

SIer IoT LT 女子部 vol2

3121962b8025dc2f8ecf6a8ada10a33d?s=128

kanaaoki

July 28, 2018
Tweet

Transcript

  1. Copyright (C) KDDI Web Communications Inc. All Rights Reserved Non

    ΤϯδχΞͰ΋TwilioͰIoTͰ͖Δ͔ͳ ~IoTΊͬͪΌେมͩͬͨ͸ͳ͠~ 1 KDDI΢Σϒίϛϡχέʔγϣϯζ ੨໦Ճಸ
  2. ੨໦Ճಸ େࡕग़਎ 2017೥10݄ɹKDDI Web Communications ৽ଔೖࣾ Twilioࣄۀ෦ɹϚʔέςΟϯά෦ॴଐ 2 ࣮͸ ඒज़େֶଔ

  3. Twilioͱ͸ 3 ̎̌̌̔೥αʔϏε։࢝ɻຊࣾ͸αϯϑϥϯγείɻ Ի੠ి࿩΍SMSͳͲͷίϛϡχέʔγϣϯνϟωϧΛఏڙ͍ͯ͠ΔΫϥ΢υαʔϏεɻ

  4. ීஈ͍ͯ͠Δ͜ͱ ɾηϛφʔͷاը ɾࣄྫ঺հͳͲͷHPίϯϯςϯπ ͷߋ৽ ͱ͔ͱ͔ɻɻɻ ͭ·ΓɹΊͬͪΌϚʔέͯ͠·͢ 4

  5. Ͱ΋Θͨ͠ɺࢥͬͨΜͰ͢ɻ Ϛʔέ͚ͩͲɺTwilioͷ͜ͱશવ஌Βͳ͍ 5

  6. ͱΓ͋͑ͣԿ͔࡞ͬͯΈΑ͏ 6

  7. ΜͰɺ࡞Δ͔Βʹ͸ Կ͔Ͱൃද͠Α͏ 7

  8. 8 ɹ͔ͨ˓͠͞ΜɺԿ͔࡞ͬͯొஃ͍ͨ͠Ͱ͢ ͦ͏ͳΜ͔ɺ͡Ό͋͜Εିͨ͠ΔΘʂɹ .̑45"$, Θͨ͠ ฐࣾΤό

  9. 9 མͱͯ͠յ͢ Ϙλϯԡͤͳ͘ͳΔ

  10. 10 ൵͠ΉΤόϯδΣϦετ

  11. ࠷ۙ຋༁ͨ͠ϒϩά(ۙ೔ެ։) 11

  12. 12 ͜Ε͘Β͍࡞Εͦ͏͡Όͳ͍ʁ

  13. 13

  14. 14 ίϐϖ ͱ͔ ి࿩ൃ৴ ɹˣ ࣗಈԠ౴ ɹˣ SMSૹ৴

  15. ͱ͍͏͜ͱͰ࡞ͬͯΈͨ 15

  16. ᶃAWSϘλϯͷઃఆ 16 ͳΜͱ͔ DONE!! Ϙλϯಧ͘ʢ΍ͬͨʔʂʣ ↓ ΞϓϦΛΠϯετʔϧ ʢ؆୯ʂʂʣ ↓ σόΠεͷొ࿥

    ʢ͙͢Ͱ͖Δʂʣ
  17. 17 DONE!! Studio͍͢͝ʂ ຊ౰ʹίʔσΟϯά͍Βͳ͍ɺɺɺ Ͱ΋͔͔̎࣌ؒͬͨ ※࣮ࡍͷϑϩʔ

  18. ᶅAWSͷηοςΟϯά 18 ΞΧ΢ϯτ࡞ΔˠϩάΠϯ͢Δ ͦͯ͠ࢥͬͨ LambdaͬͯԿ

  19. ᶅAWSͷηοςΟϯά ؀ڥม਺ͷઃఆ ɾTwilioͷREST APIͷURL͕https ʢϒϩά͸httpʣˠͲ͜ΛͲ͏ม͑Ε͹͍͍ͷ͔Θ͔Βͳ͍ ɾGet͡Όͳͯ͘Post͡Όͳ͍ͱಈ͔ͳ͍ʁ ɾPython? Node?ͲͬͪͰ։ൃ͢Ε͹͍͍ͷʁ ໰୊ग़͖ͯ·͘Γ ͳʹ͜ΕɺΊͬͪΌ೉͍͠ɻ݁ہɺ

    19
  20. ΤϯδχΞͷਓʹ͓ئ͍͢Δ 20

  21. ࣮ࡍͷίʔυʢNode.jsʣ const https = require('https'); const querystring = require('querystring'); const

    TWILIO_ACCOUNT_SID = process.env.TWILIO_ACCOUNT_SID; const TWILIO_AUTH_TOEKN = process.env.TWILIO_AUTH_TOKEN; const TWILIO_STUDIO_REST_API_PATH = process.env.TWILIO_STUDIO_REST_API_PATH; const TWILIO_STUDIO_TO = process.env.TWILIO_STUDIO_TO; const TWILIO_STUDIO_FROM = process.env.TWILIO_STUDIO_FROM; exports.handler = function(event, context, callback) { const postData = querystring.stringify({ 'To' : TWILIO_STUDIO_TO, 'From': TWILIO_STUDIO_FROM }); const options = { hostname: 'studio.twilio.com', port: 443, path: TWILIO_STUDIO_REST_API_PATH, method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded', 'Content-Length': postData.length }, "auth" : `${TWILIO_ACCOUNT_SID}:${TWILIO_AUTH_TOEKN}` }; const req = https.request(options, (res) => { res.on('data', (chunk) => { console.log(`BODY: ${chunk}`); }); res.on('end', () => { console.log('No more data in response.'); callback(null, "request completed"); }); }); req.on('error', (e) => { console.error(`problem with request: ${e.message}`); }); req.write(postData); req.end(); } 21
  22. DEMO 22

  23. ·ͱΊʢ౰ͨΓલͷ͜ͱʣ ɾAWSͷαʔόʔϨε؀ڥ͍͢͝͠ɺ͍ͬͺ͍ػೳ͋Δ͚Ͳ ݁ہίϐϖ͚ͩ͡Όͪΐͬͱແཧ͋Δ͔΋ʢ૊Έ߹Θͤͯ ࡞ͬͯΈͯ΋ʣ ɾTwilio Studio͍͢͝ ʢຊ౰ʹίʔσΟϯά͍Βͳ͍ɻͰ΋ઃఆ߲໨͕ણࡉɻؾ Λൈ͍ͨΒಈ͔ͳ͍ʣ 23

  24. ·ͱΊʢ౰ͨΓલͷ͜ͱʣ 2೔͔͚ͯ࡞Δ༧ఆ͕ Ұि͔͔ؒΔ ΤϯδχΞ͞Μ͍͢͝ 24

  25. Twilio Ϗδωεηϛφʔ Vol.53 kintone Twilio 25 × ݄̔̎̏೔ʢ໦ʣ̍̒ɿ̌̌ʙ Ϋϩείʔϓ੨ࢁɹ̕Fʢେʣ