Skypeã¯ã顧客ãšã®å¹ççãªã³ãã¥ãã±ãŒã·ã§ã³ã®ããã®åªãããã£ã³ãã«ã§ãã 誰ãããããæã¡ãäžå¿ èŠãªãžã§ã¹ãã£ãŒãè²»çšãªãã§è¿ éãªã©ã€ãéä¿¡ãæäŸããŸãïŒããšãã°ãé»è©±éä¿¡ïŒã ãã ãã顧客ã®æ°ãæ°å人ã«éãããšãSkypeã®å©ç¹ã¯æ¬ ç¹ã«å€ããå§ããŸãã ãã®èšäºã§ã¯ãSkypeãããã«ã€ããŠèª¬æããŸããSkypeãããã¯ã20äžçŽåé ã«é»è©±ãªãã¬ãŒã¿ãŒã®åœ¹å²ãæ¬è³ªçã«æãããŸããã¯ã©ã€ã¢ã³ããç¡æã®ãããŒãžã£ãŒã«æ¥ç¶ããåé¡ã解決ãããŸã§ãã®æ¥ç¶ãç¶æããŸãã
Skyeng Schoolã¯ãã¡ãã»ã³ãžã£ãŒãšãŠãŒã¶ãŒãµããŒããªãã¬ãŒã¿ãŒã®éã«äŸ¿å©ãªã³ãã¥ãã±ãŒã·ã§ã³ãã£ãã«ãäœæãããšãã課é¡ã«åžžã«çŽé¢ããŠããŸãã çŸåšãæãå€ãã®ã¢ããªã±ãŒã·ã§ã³ãåãå ¥ããŠããã¡ãã»ã³ãžã£ãŒã¯Skypeã§ãã Skypeã®é£çµ¡å ã®æ°ãæ°åã«ã®ãŒããšãSkypeã¯ã©ã€ã¢ã³ããä»ããçŽæ¥ã®éä¿¡ã«åé¡ãçããŸãã ãŸãããã®ãããªäœæ¥äžã®ãã®ã¯ã©ã€ã¢ã³ãã®ããã©ãŒãã³ã¹ã¯ã»ãŒãŒãã«äœäžããé£çµ¡å ãªã¹ãã¯éåžžã«é·ãããŒããããŸãã 第äºã«ãå€ãã®å Žåãè€æ°ã®ãªãã¬ãŒã¿ãŒããŠãŒã¶ãŒãšäžŠåéä¿¡ãè¡ãå¿ èŠããããŸãã è€æ°ã®ããã€ã¹ã§1ã€ã®Skypeã¢ã«ãŠã³ãã䜿çšããããšã¯å¯èœã§ããããã¹ãŠã®ãã€ã¢ãã°ããã®çä¿¡ã¡ãã»ãŒãžã¯ãã¹ãŠã®ãªãã¬ãŒã¿ãŒã«è¡šç€ºããããããäœæ¥ã劚ããããŸãã ããã«ãSkypeã§ã®ãã¹ãŠã®éä¿¡ã¯Skypeèªäœã«æ®ããã³ããŒã¢ã³ãããŒã¹ããåŠçããå¿ èŠã®ããå éšCRMãŸãã¯HelpDeskã·ã¹ãã ã«ããããæœåºããŸãã
ãããã®åé¡ã«ããããµããŒããµãŒãã¹ãžã®ã¡ãã»ãŒãžã®ãšã³ããªãã€ã³ããšããŠæ©èœãããã£ããããããäœæããããšã«ãªããŸãã ã ãã£ãããããã®ããŒãã¯æè¿éåžžã«äººæ°ããããMicrosoftã¯Skype REST APIãžã®ã¢ã¯ã»ã¹ãæäŸããŸãããSkypeREST APIã«ã¯ãCïŒããã³Node.jsã®ãµã³ãã«ãå«ãSDKãä»å±ããŠããŸã ã
å®å šãªãã«ããã£ãã«éä¿¡ã§ã¯ãã¡ãã»ãŒãžãåä¿¡ããã ãã§ã¯ååã§ã¯ãªãããªãã¬ãŒã¿ãŒãã¡ãã»ãŒãžãèªã¿åããå Žæã«é ä¿¡ããå¿ èŠããããŸãã ç§ãã¡ã®åŠæ ¡ã¯å éšã³ãã¥ãã±ãŒã·ã§ã³ã§Slackãç©æ¥µçã«äœ¿çšããŠããããã®ã¡ãã»ã³ãžã£ãŒã¯ãã£ãã«ã®æŠå¿µãååã«ãµããŒãããŠãããããçä¿¡ã¡ãã»ãŒãžãããã«è»¢éããããšã«ããŸããã
ãã®çµæããšã³ããªãã€ã³ããšåºå£ãã€ã³ããåããã¢ãã«ãäœæãããã®å éšã§ããŒã¿ãããŒãå®å šã«å¶åŸ¡ã§ããŸãã
建ç¯
ã·ã¹ãã ã¯ãµãŒããŒäžã®è€éãªèšç®ãæå³ããŸããã ãã®äž»ãªã¿ã¹ã¯ã¯ãããŒã¿ã®åä¿¡ãä¿åãã«ãŒãã£ã³ã°ã§ãã ãã®ããããã®ãããªã¿ã¹ã¯ã«é©ããNode.jsãã¡ã€ã³ãã©ãããã©ãŒã ãšããŠéžæãããŸããã 圌ãã¯ããããžã§ã¯ãã®éå§æã«å©çšå¯èœãªææ°ã®LTSããŒãžã§ã³ã§ãã6.3.0ã䜿çšããŸããã node.greenã«ãããšã 6ã€ã¯ES 2015ã®95ïŒ ãã«ããŒããŠãããããã¯éåžžã«çŽ æŽãããããšã§ãããŸãã nodesourceããã°ã¯ 2018幎4æãŸã§æ©èœãçŽæãããã®åŸã¡ã³ããã³ã¹ãã§ãŒãºãéå§ãããŸãã è¯ãã
ããŒã¿ããŒã¹ã«ã¯ç¹å¥ãªèŠä»¶ã¯ãªãããã PostgreSQLã®åœ¢åŒã§å€å žçãªä¿¡é Œã§ãããªã¬ãŒã·ã§ãã«ã䜿çšããŸããã
ååã«é«ããã©ãŒã«ããã¬ã©ã³ã¹ãã¹ã±ãŒã©ããªãã£ãããã³äœãã³ã³ããŒãã³ãæ¥ç¶æ§ã確ä¿ããããã«ãã·ã¹ãã ã¢ãžã¥ãŒã«éã®ããŒã¿äº€æã®ããã«RabbitMQã®åœ¢åŒã§ã¢ãŒããã¯ãã£ã¡ãã»ãŒãžãã¥ãŒã«å«ããããšã決å®ãããŸããã
ãã®çµæã次ã®äœæ¥ã¹ããŒã ãåŸãããŸããã
ãã®ã·ã¹ãã ã¯ã 3ã€ã®äž»èŠãªãµãŒãã¹ ïŒSkypeãµãŒãã¹ãLogicãµãŒãã¹ãSlackãµãŒãã¹ïŒãšè¿œå ã®ãã€ã¯ããµãŒãã¹Slackã¡ãã»ãŒãžã³ã°ãã€ã¯ããµãŒãã¹ã§æ§æãããŠããŸãã SlackãµãŒãã¹ã®äž»ãªç®çã¯ããšã³ããã€ã³ããSkypeãããã«å¯ŸããŠæ©èœããã¡ãã»ãŒãžãSkypeã«éä¿¡ããããšãä¿èšŒããããšã§ãã ããžãã¯ãµãŒãã¹ã¯ãã¡ãã»ãŒãžã®ã«ãŒãã£ã³ã°ãã¡ãã»ãŒãžã®ä¿åãã³ãã³ãã®åŠçãåŠæ ¡ã®å éšãµãŒãã¹ãšã®çµ±åã®ããã®APIã®æäŸãæ åœããŸãã SlackãµãŒãã¹ã«ã¯Slack RTMãžã®ãµãã¹ã¯ãªãã·ã§ã³ãããã Slackã®ãµããŒããªãã¬ãŒã¿ãŒããã®ã³ãã³ããåãå ¥ãããšã³ããã€ã³ããæ åœããŸãã
Slack APIã®å¶éãè¶ ããæããªããã¡ãã»ãŒãžãèªä¿¡ãæã£ãŠSlackã«éä¿¡ããã«ã¯ãè¿œå ã®Slackã¡ãã»ãŒãžã³ã°ãã€ã¯ããµãŒãã¹ãå¿ èŠã§ããããã®ãããã¡ãã»ãŒãžã¯ãRabbitMQããã¿ã€ããŒã§é·æéããŒãªã³ã°ããŠéä¿¡ããSlackã«éä¿¡ããŸãã
ãã¬ãã¥ãŒãä¿¡é Œã§ããŸããïŒ Microsoft Bot Frameworkãžã®ç§»è¡
ããŒã«ã®ãã¬ãã¥ãŒããŒãžã§ã³ã®äœ¿çšã«ã¯ãåžžã«ç¹å®ã®ãªã¹ã¯ã䌎ããŸããããã¯ããªãªãŒã¹æã«é倧ãªå€æŽãçºçããå¯èœæ§ããããããã«æªãããšã«ããã®ãªãªãŒã¹ããŸã£ããè¡ãããªãããã§ãã ããã¯ãŸãã«ãSkypeããããéçºããããã®SDKã«ãŸã€ããéåœã§ãããã¬ãã¥ãŒãã©ãŒã ã«ç»å Žããåããã©ãŒã ã§å€ããªã£ãïŒéæšå¥šã®ã¹ããŒã¿ã¹ãåãåããŸããïŒã ãã®åŸãSkypeå°çšã®æ°ãããããã®äœæãäžå¯èœã«ãªããMicrosoft Bot Frameworkãžã®ãªãã€ã¬ã¯ããšãè¿ãå°æ¥ã«ç§»è¡ããå¿ èŠæ§ã«é¢ããèŠåã衚瀺ãããŸããã
Microsoft Bot Frameworkã¯ã1ã€ã®ããŒã«ã§å€ãã®éä¿¡ãã£ãã«ãã«ããŒããããã®Microsoftã®è©Šã¿ã§ãã çŸåšãµããŒããããŠããã®ã¯ïŒFacebook MessengerãKikãSlackãTelegramãSkypeãããã«ã¯é»åã¡ãŒã«ãTwilioïŒSMSïŒãDirect Lineãªã©ã®ãã£ãã«ã§ãã ããã¯ãã¹ãŠèå³æ·±ãããšã§ããããã®æ®µéã§ã¯Skypeã«ã®ã¿èå³ããããŸããïŒãã¡ãããè¯ãã¹ã¿ãŒãã§ããããåŸã®æéãçããŠä»ã®ã€ã³ã¹ã¿ã³ãã¡ãã»ã³ãžã£ãŒã®ãµããŒããè¿œå ã§ããŸãïŒã
åŸ ããã«ããã«ç§»è¡ããŸããã Microsoft Bot Frameworkã«æ°ããããããç»é²ããã®ã¯ç°¡åã§ãMicrosoftã¢ã«ãŠã³ããæã£ãŠããã ãã§ãã
ã¢ã«ãŽãªãºã ã¯æ¬¡ã®ãšããã§ãã
- ãªã³ã¯ããã©ã£ãŠãã ãã ã
- ãã¹ãŠã®ãã£ãŒã«ãã«ã¢ã¹ã¿ãªã¹ã¯ãå ¥åããŸãã
- [Microsoftã¢ããªIDãšãã¹ã¯ãŒãã®äœæ]ãã¯ãªãã¯ããŸãã
- æ°ããããŒãžãéããŸãããã®ããŒãžã§ãã¢ããªã±ãŒã·ã§ã³ã®ååïŒTestBotAppãªã©ïŒãå ¥åããå¿ èŠããããŸãã
- ããã«ãã¿ã³ãã¹ã¯ãŒããçæããŠç¶è¡ããŸãã
- çæããããã¹ã¯ãŒãã¯å衚瀺ã§ããªããããã©ããã«ä¿åããå¿ èŠããããŸããããã¬ãŒã ã¯ãŒã¯ãšã¢ããªIDãæäœããããã«å¿ èŠã§ãã
- 次ã«ã[å®äºããŠããããã¬ãŒã ã¯ãŒã¯ã«æ»ã]ãã¿ã³ãã¯ãªãã¯ããŸãã
- ç»é²ããŒãžã§å¥çŽã«åæããŠ[ç»é²]ãã¯ãªãã¯ããå¿ èŠããããŸãããã®åŸãMicrosoft Bot Frameworkçšã®æ¢è£œã®ç»é²æžã¿ãããããããŸãã
ç»é²ããŒãžã«ã¯ã¡ãã»ãŒãžã³ã°ãšã³ããã€ã³ããã£ãŒã«ãããããç»é²ã«ã¯å¿ èŠãããŸãããããããã®ãšã³ããªãã€ã³ãã§ãããããããªãã§ã¯æ©èœããŸããã ãšã³ããã€ã³ãã®äž»ãªèŠä»¶ã¯ãæ©èœããHTTPSãªã³ã¯ã§ãªããã°ãªããŸããã
ã³ãŒãã®ç§»è¡ã«é¢ããŠã¯ãããããã§ããã®ã¯ã¡ãã»ãŒãžã®éåä¿¡ã ããªã®ã§ã倧ããªå€æŽãå ããå¿ èŠã¯ãããŸããã§ããã ããã§ããåãæ©èœã®ã³ãŒãã¯å€§ãããªããŸããã
bot.send( '8:skype.username', 'message from bot to user', true, // escape (error) => console.log(error) );
ã«ãªã£ã
bot.send( new builder.Message() .address({ channelId: "skype", user: { id: "29:some-long-hash-here", name: "User Display Name" }, bot: { id: "28:bot-uuid", name: "Bot Name" }, serviceUrl: "https://skype.botframework.com", useAuth: true }) .text('Message from bot to user'), (err) => console.log(err) );
ãããŠãã¡ãã»ãŒãžåä¿¡ã®å°ããªå€åïŒ
bot.on('personalMessage', (bot, data) => { console.log('Got message from user'); });
ããããã¬ãŒã ã¯ãŒã¯ã«ã¯ãã€ã¢ãã°ãªã©ã®æŠå¿µããããŸãããã¡ãã»ãŒãžãåä¿¡ããã ãã§ããã®ã§ãã¹ã©ãã·ã¥ã§è¡šãããæãäžè¬çãªãã€ã¢ãã°ã«ãµãã¹ã¯ã©ã€ãããŸããã ãã¹ãŠã®çä¿¡ã¡ãã»ãŒãžãåãå ¥ããŸãïŒ
bot.dialog("/", [ (session) => { console.log("Got message from bot", session.message); } ]);
äžèšã®ãããã¹ããããã§ã¯ãSkypeã®å ŽåãBot SDKã¯BotServiceã¯ã©ã¹ã®ã€ã³ã¹ã¿ã³ã¹ã§ãããBot Frameworkã§ã¯ãã§ã«UniversalBotã§ãã
ãŸããSkype Bot SDKã§ãŠãŒã¶ãŒIDã䜿ã£ãŠèª°ãæ±ã£ãŠãããã倧ãŸãã«ç解ã§ããããã«ãããå ŽåãMicrosoft Bot Frameworkã§ã¯ãã¹ãŠã®ãŠãŒã¶ãŒãé·ãããã·ã¥ã®åœ¢åŒã§è¡šç€ºããã察話è ãå¿åã«ãªããŸãã ã¢ã€ãã³ãã£ãã£ã決å®ããã¿ã¹ã¯ã¯ããŠãŒã¶ãŒãšã®ã©ã€ãã®å¯Ÿè©±ã§ã®ã¿è§£æ±ºã§ããŸãã
ãã1ã€ã®èå³æ·±ãç¹ã¯ããããããéä¿¡ãããã¡ãã»ãŒãžãç·šéããããšã§ãã äžéšã®githubãŠãŒã¶ãŒãèšãããã«ãSkype Bot SDKã«ã¯ãã®ãããªæ©äŒããããŸããããMicrosoft Bot Frameworkã«ã¯Skypeçšã§ã¯ãããŸããïŒä»ã®ãã©ãããã©ãŒã ãç¹ã«TelegramãšSlackã§ã¯å¯èœã§ããïŒã
ããã«ãããããããMicrosoft Bot Frameworkã¯ãããŸããŸãªéä¿¡ãã£ãã«ã®ãããéçºãã©ãããã©ãŒã ã®çµ±åã«åããè¯ãäžæ©ã§ãã Microsoftããã®è£œåã®éçºãç¶ç¶ããäžè¶³ããŠããæ©èœãSkypeãããã«ä»ããè¿œå ããããšãæãŸããŸãã
Slackã§ã¡ãã»ãŒãžã«äŒããŸã
ãã«ããã£ãã«ã®ã¡ãã»ãŒãžåä¿¡ãæŽçããããã«ããã©ã€ããŒããã£ãã«ãªã©ã®SlackããŒã«ã䜿çšããŸããã Slack APIã®çšèªã§ã¯ããããã¯ã°ã«ãŒãã§ãã
æåã¯ãã¡ãã»ãŒãžãSlackã«éä¿¡ãããã¹ãŠã®æ©èœãã«ããŒããã«ã¹ã¿ã ãããã1ã€äœæããã ãã§ååã§ãããšæåŸ ããŠããŸãããããã§ãã©ã€ããŒããã£ãã«ãäœæããããã«ãªãã¬ãŒã¿ãŒãè¿œå ããŠããããã·éä¿¡ãæäŸãç¶ããŸãã ãã ããSlackã®ãããã¯ãã©ã€ããŒããã£ãã«ã®äœæãèš±å¯ãããŠããŸããã§ããã
ãããã£ãŠã Slack RTMã«æ¥ç¶ãããApiã«ã¹ã¿ã ãããã«å ããŠãéåžžã®SlackãŠãŒã¶ãŒã«ä»£ãã£ãŠãã©ã€ããŒããã£ãã«ãäœæãããªãã¬ãŒã¿ãŒãæåŸ ããSlackã¢ããªã±ãŒã·ã§ã³ãäœæããŸããã
Slack APIã¯éåžžã«å®å®ããŠãããååã«ææžåãããŠãããã¡ãœããåŒã³åºãã確èªã§ãããªã³ã©ã€ã³ãã¹ã¿ãŒãå«ãŸããŠããããã幞ããªããšã«ä»ã«é©ãã¯ãããŸããã§ããã ããã䜿çšããããã«ããã®éåžžã«åçŽãªnpmããã±ãŒãžã䜿çšããŸãã ãããã¯ããã®ã¡ãœããã®ã»ãšãã©ãåãååã®Slack APIã¡ãœãããç¹°ãè¿ãããã䟿å©ã§ãã
ããã»ã©åçŽã§ã¯ãããŸããïŒ
ããããæ©èœããããã«ã¯ãMicrosoftã«ãã£ãŠæ¿èªãããå¿ èŠããããŸãã åçŽãªåœ¢åŒã®ããã«èŠããŸãããå€ãã®æéãšåŽåãããããŸããã ç§ãã¡ãèžã¿èŸŒãã ã¬ãŒãã«ã€ããŠèª¬æããŸãããããã¯ããªããä»ã®äººãèžãŸãªããšããæå³ã§ã¯ãããŸããã ããã®æºåãããªããã
ãããã£ãŠãæåã®éä¿¡ãã2é±éåŸã次ã®ããã«ãªããŸããã
説æïŒãããã®ã³ã³ãã³ãã¯ãã·ã¢èªã§ãã çŸæç¹ã§ã¯ãSkypeãããã¯è±èªãŠãŒã¶ãŒã®ã¿ããµããŒãããŠããŸãã ãŠãŒã¶ãŒãè±èªã§ããããèªãã§äœ¿çšããããã®ç¿»èš³ãŸãã¯ä»£æ¿ãªãã·ã§ã³ãæäŸããŠãã ããïŒããããã¯ãã·ã¢èªã§ããããŠãŒã¶ãŒã¯è±èªã§éä¿¡ã§ããå¿ èŠããããŸããïŒã çµå±ã®ãšããããã®åé¡ã解決ããã«ã¯ãè±èªã®å©çšèŠçŽãšãã©ã€ãã·ãŒããªã·ãŒãããã°ååã§ãã OKãæžã蟌ã¿ã æçš¿ ãæ°ããã¢ããªã±ãŒã·ã§ã³ãéä¿¡ããŸããã
ä»åã¯ããããšãéããªããŸããïŒ
ãããã¯ãã¯ã©ã€ã¢ã³ããšãªãã¬ãŒã¿ãŒãæ¥ç¶ããããšã®ã¿ãç®çãšããŠããŸãã Microsoftã«ãããšãããã§ã¯ååã§ã¯ãããŸããã ããããç¬ç«ããŠå¿çã§ããããã€ãã®ã³ãã³ãïŒhelpãšlessons-countïŒãæå°éã®æ©èœã«çããå¿ èŠããããŸããã
ãããã®èŠä»¶ãæºãããŠããéã«ãæ°ããããšãç»å ŽããŸããããããã¯ãå©çšèŠçŽãšãã©ã€ãã·ãŒããªã·ãŒãã³ãã³ãã§çºè¡ã§ããå¿ èŠããããŸãïŒãµã€ãäžã«ãããã眮ãã ãã§ã¯äžååã§ãïŒã ããŠãããããã£ãã ããã§ã¯ååã§ã¯ãªãããšãå€æããŸãããåã¡ãã»ãŒãžã«æ¡ä»¶ãååšããå¿ èŠããããŸãã ããã äžæ¹ããã€ã¯ããœããã®ãã³ãã³ãªãã£ã¹ã§ã¯ã倧èŠæš¡ãªæ¹é ãå§ãŸããŸããããã®ãããæ¿èªãäœåºŠãäœåºŠã延æãããŸããã
ããããæçµçã«ãåŸ æã®upruãåŸãŸããã
ãããã®äžæ£è¡çºã¯ãã¹ãŠãç§ãã¡ããèšå€§ãªæéãèŠããäºæãã¬ãæã«ã¯èª¬æã§ããªãé 延ã«åããŠãã ããã
ãããã«
ãã®çµæãçä¿¡ã¡ãã»ãŒãžã«å¯ŸããŠé«éã§é«å質ã®å¿çãæäŸãããçããŠãããã®ããã«ãã¯ã©ã€ã¢ã³ããšäŒè©±ããSkypeããããååŸããŸããïŒãªãã¬ãŒã¿ãŒãå¶åŸ¡ããŠããããšãèãããšãããã¯é©ãããšã§ã¯ãããŸããïŒã ééã£ããã£ã³ãã«ãžã®åçãçä¿¡ããé£çµ¡å ãèŠéããããšã¯éå»ã®ãã®ã§ãã ãããªãã®è³ªåã¯ç§ãã¡ã«ãšã£ãŠéåžžã«éèŠã§ãã-空ã®èšèã§ã¯ãªããä»ã§ã¯åäžã®ã¡ãã»ãŒãžã倱ãããããšã¯ãªããäŒè©±ãç§ãã¡ã®ããã§è¡°éããããšã¯ãããŸããã åæã«ãéåžžã®Skypeã®åé¡ã¯è§£æ±ºãããéä¿¡ã¯æ§é åããã圢åŒã«ãªãã瀟å ã®ãŠãŒã¶ãŒãµããŒããµãŒãã¹ã«çµ±åãããŸããã ãããŠããã¹ãŠã®ãéæ³ãã¯ãç°ãªããã©ãããã©ãŒã éã§ã¡ãã»ãŒãžãã«ãŒãã£ã³ã°ããåçŽãªã¢ãŒããã¯ãã£ã«ãããŸãã
PSç§ãã¡ã®ãã¢ã¯æ§ã ãªæèœããã¹ãã·ã£ãªã¹ãã«éãããŠããããšãæãåºãããŠãã ããïŒ