ããã«ã¡ã¯ãHabrïŒ æè¿ã§ã¯ããã«ã¬ã¹ããšã¯ã«ãŒãžã¥ã®éçºè
åãã®ããã«ãœã³ãå®æœããŸããã Kluzhaã°ã«ãŒãã®äž»ãªã¿ã¹ã¯ã¯ãEndavaããµããŒãããMicrosoft GraphãšQïŒA Makerã䜿çšããŠå¹æçãªãã£ããããã°ã©ã ãäœæããããšã§ããã æ¬æ¥ã¯ããã®ãããžã§ã¯ãã«ã€ããŠèª¬æããŸãããã®ãããžã§ã¯ãã¯ãä»»æã®ãã£ãã«ãä»ããŠããããããã°ã©ã ãšå¯Ÿè©±ããããã®èªèšŒç®¡çãQïŒA Makerã®çµ±åãããã³Microsoft GraphãšSharePointã®çµã¿åããã«åœ±é¿ããŸãã 詳现ã¯ãã¡ãïŒ
ã¯ããã«
ãã®ãããžã§ã¯ãã¯ãéçºè
EndavaãšMicrosoftã®éå
¬éããã«ãœã³ã§äœæãããŸããã ãã®ããã«ãœã³ã¯ã¯ã«ãŒãžã¥ãšãã«ã¬ã¹ãïŒã«ãŒããã¢ïŒã®éœåžã§éå¬ãããŸããã åå è
ã®äž»ãªã¿ã¹ã¯ã¯ãITãµããŒãã«äœ¿çšãããEndava Webã¢ããªã±ãŒã·ã§ã³ãæ¹åããAIã³ã³ããŒãã³ãã®ãããã¿ã€ããäœæããããšã§ããïŒããšãã°ããŠãŒã¶ãŒãèªç¶èšèªãã£ãããããããšã¡ãã»ãŒãžã亀æããããæ©æ¢°åŠç¿æè¡ã䜿çšããŠé話管çãæé©åãããã§ããŸãïŒ ã
ãã®ããã«ãœã³ã¯2018幎1æ30æ¥ãã2æ2æ¥ãŸã§éå¬ãããŸããããã®GitHubããŒãžã§ã¯ãã¯ã«ãŒãžã¥ã§3æ¥éè¡ãããäœæ¥ã®äžéšã玹ä»ããŠããŸãã éçºããŒã ã«ã¯ä»¥äžãå«ãŸããŸãã
- Corina Ciocaneaãéçºè
ïŒEndavaïŒ
- Alexandru Marchisãéçºè
ïŒEndavaïŒ
- ãã¥ãŒããŒã ã¬ãµã³ãéçºè
ïŒEndavaïŒ
- Laurent Ellerbachãæè¡çŠé³äž»çŸ©è
ãããŒã ãªãŒããŒïŒãã€ã¯ããœããïŒ
ãããžã§ã¯ãã®èª¬æ
Kluzhaã°ã«ãŒãã®äž»ãªã¿ã¹ã¯ã¯ãããã€ãã®æ©èœããµããŒãããå¹æçãªãã£ããããã°ã©ã ãäœæããããšã§ããã
- Endavaã³ãŒã«ç®¡çã·ã¹ãã ã§çŽæ¥ãªã¯ãšã¹ããäœæããã®ã«äŸ¿å©ã§ãïŒãŠãŒã¶ãŒã«ãšã£ãŠïŒã
- Microsoft Graphãä»ããŠSharePointãžã®ã¢ã¯ã»ã¹ãèŠæ±ããããããããã°ã©ã ã®å®éšããŒãžã§ã³ãäœæããSharePointã®ææè
ã«çŽæ¥é»åã¡ãŒã«ãéä¿¡ããããService NowãšããäŒç€Ÿã®å°çšã¢ããªã±ãŒã·ã§ã³ã§ã¢ããªã±ãŒã·ã§ã³ãäœæããèŠæ±ãæºåããŸãã
- QïŒAã¡ãŒã«ãŒã䜿çšããŠãEndavaããŒãžã§è³ªåãžã®åçãå«ãã«ã¹ã¿ã 質åãžã®åçãèŠã€ããŸãã
- ãã¹ãŠã®èªèšŒæäœã¯ãEndava Active Directoryãšã®çµ±åãéããŠå®è¡ããå¿
èŠããããŸãã
- ãŠãŒã¶ãŒã®å€§å€æ°ã以åã¯é»åã¡ãŒã«ãéä¿¡ããŠåŒã³åºããäœæããŠããããããœãªã¥ãŒã·ã§ã³ã¯é»åã¡ãŒã«ã®åŠçããµããŒãããå¿
èŠããããŸãã
ãã®ããã¥ã¡ã³ãã«å«ãŸããæ
å ±ïŒ
- é»åã¡ãŒã«ãå«ãä»»æã®ãã£ãã«ãä»ããŠããããããã°ã©ã ãšå¯Ÿè©±ããããã®èªèšŒã管çããæ¹æ³ã
- QïŒA Makerãããããããã°ã©ã ãšçµ±åããæ¹æ³ïŒQïŒA Makerããããããã°ã©ã ã®äœæã¯ããã§ã¯èæ
®ãããŸããïŒã
- Microsoft GraphãSharePointãšçµã¿åãããŠäœ¿çšââããé»åã¡ãŒã«ãéä¿¡ããŸãã ããã«ç€ºãã³ãŒãã¯ã3æ¥éã§éçºãããããè€éãªãœãªã¥ãŒã·ã§ã³ã®äžéšã§ãã
ãœãªã¥ãŒã·ã§ã³ã®ã¢ãŒããã¯ãã£ã¹ããŒã ïŒ
䜿çšæè¡
ãã®ãœãªã¥ãŒã·ã§ã³ã®ã³ãŒãã¯ã次ã®ãã¯ãããžãŒã䜿çšããŸãã
èªèšŒ
ç§ãã¡ã®ã¢ã€ãã¢ã¯ãããããããã°ã©ã ã«ç¹å®ã®ãŠãŒã¶ãŒïŒSharePointãµã€ããªã©ïŒã«é¢ããæ
å ±ãå«ãã³ã³ããã¹ããžã®ã¢ã¯ã»ã¹ãšé»åã¡ãŒã«ãéä¿¡ããæ©èœãæäŸããããšã§ããã ãã®ãããããããããã°ã©ã ã¯å®å
šã§ãåŸæ¥å¡ã®ã¿ãã¢ã¯ã»ã¹ã§ããå¿
èŠããããŸããã
ãããã®åé¡ã解決ããã«ã¯ãèªèšŒãå¿
èŠã§ããã ãã®å®è£
ã«ã¯å€ãã®å°é£ã䌎ããŸãããããšãã°ãããããããã°ã©ã ã¯é»åã¡ãŒã«ãåŠçã§ããªããã°ãªããããããã£ãŠå
éšèªèšŒæé ããªããŠããŠãŒã¶ãŒãèªèšŒã§ããªããã°ãªããŸããã Endava Azure Active Directoryã¯AADãµãŒãã¹ããŒãžã§ã³1ã§ãããããã¡ã€ã³ããããããã°ã©ã ã®ãã©ãããã©ãŒã ãšããŠAAD 1ã䜿çšããŸãããèªèšŒãå®è£
ããå Žåã¯ã以äžãèæ
®ããããšããå§ãããŸãã
- AuthBotã®äŸã®ã³ãŒãã䜿çšããå Žåããã®ã¡ã«ããºã ãå¿
ãä¿åïŒã³ããŒïŒããŠãã ããã ããã¯ã»ãã¥ãªãã£äžã®çç±ããéèŠã§ãã ãã£ãããããããšãã©ãŠã¶ã¯ç°ãªãã³ã³ããã¹ãã«ãããããã€ãã®æ»æãã¯ãã«ããããã¯ããŸãã
- ç¹å®ã®ã¢ããªã±ãŒã·ã§ã³ãèš±å¯ããããã«AADãµãŒãã¹ãæ§æããŸãã ã¯ã©ã€ã¢ã³ãIDãšã·ãŒã¯ã¬ãããåãåããŸãããããã¯web.configãã¡ã€ã«ã®å¿
èŠãªéšåã«å
¥åããå¿
èŠããããŸãã
- ã¢ããªã±ãŒã·ã§ã³æ§æãã¡ã€ã«ã«æ£ããæ»ãURLãæå®ãããŠããããšã確èªããŠãã ããã ãã®ãããªã¢ãã¬ã¹ãããã€ãäœæããããšãã§ããŸãïŒããšãã°ããããã°çšããã³äœæ¥ããŒãžã§ã³çšïŒããããã¯ãã¹ãŠãªãã€ã¬ã¯ãURLãšå®å
šã«äžèŽããå¿
èŠãããããããããã³ã«ïŒhttps / httpïŒãå«ãå®å
šãªãã¹ãæå®ããå¿
èŠããããŸãã
- ç¹å®ã®ããŒã«ïŒSites.Read.AllãMail.ReadWriteãUser.ReadãPeople.ReadãDirectory.AccessAsUser.Allãªã©ïŒã®ã¢ããªã±ãŒã·ã§ã³ã®AADèšå®ã§æ£ããæ¿èªãã©ã¡ãŒã¿ãŒãæå®ãããŠããããšã確èªããŠãã ããã
å®æãããããžã§ã¯ãã®èªèšŒãã»ãã¥ãªãã£ãããã³æ¿èªã¯ã次ã®ããã«ç·šæãããŠããŸãã
ã芧ã®ãšãããã¡ã€ã³ã³ã³ããã¹ãã¯AADã®èªèšŒã«äŸåããŠããŸãã 次ã®ã³ã³ããŒãã³ãã¯ãAADã«åºã¥ããŠæ©èœããŸãã
- ããã§ã¯èæ
®ããªãå
éšService NowãµãŒãã¹ã
- ããããããã°ã©ã ã®ã³ã¢ãWebã¢ããªã±ãŒã·ã§ã³ã¯ãã®äžéšã§ãã ããã§ã¯ãã¯ã©ã·ãã¯IDãšã¯ã©ã€ã¢ã³ãããŒã䜿çšãããŸãã
- ããããããã°ã©ã èªäœãšLUISèªç¥ãµãŒãã¹ã ããã§ã¯ãã¯ã©ã·ãã¯IDãšã¯ã©ã€ã¢ã³ãããŒã䜿çšãããŸãã
- ããããããã°ã©ã ãšQïŒAã¡ãŒã«ãŒãµãŒãã¹ã ããã§ã¯ãã¯ã©ã·ãã¯IDãšã¯ã©ã€ã¢ã³ãããŒã䜿çšãããŸãã
ãã¹ãŠã®ãµãŒãã¹ã«ã¢ã¯ã»ã¹ããããã®ããŒãšIDãæ§æãã
AADãæ§æãã
ããã§ãå¿
èŠãªç°å¢ãã»ããã¢ããããåŸãweb.configãã¡ã€ã«ã«ä»¥äžã«ãªã¹ããããŠãããã©ã¡ãŒã¿ãŒã®æ£ããå€ãå
¥åããå¿
èŠããããŸãã
- Tenantãã©ã¡ãŒã¿ãŒã¯ãAADã®ãã¡ã€ã³åãšäžèŽããŸãã ããã¯ãæ§æã«å¿ããŠã第2ã¬ãã«ãã¡ã€ã³ïŒyourdomain.comïŒãŸãã¯ç¬¬3ã¬ãã«ïŒyourdomain.onmicrosoft.comïŒã«ãªããŸãã
- ã¢ããªã±ãŒã·ã§ã³ã®ã»ããã¢ããæã«ååŸããClientIdïŒã¯ã©ã€ã¢ã³ãIDïŒãšClientSecretïŒã·ãŒã¯ã¬ããïŒã®èšå®ã
- RedirectURLïŒãªãã€ã¬ã¯ãURLïŒ-ããããããã°ã©ã ãå±éãããURLã ãã®äŸã§ã¯ãããã¯ããŒã«ã«ããŒãã§ãã ã·ã¹ãã ã®äœæ¥ããŒãžã§ã³ã§ã¯ãURLã¯ç°ãªããŸãã ã¢ããªã±ãŒã·ã§ã³ãæ§æãããšãã«ãèãããããã¹ãŠã®ã±ãŒã¹ã«å¯ŸããŠè€æ°ã®URLãèšå®ã§ããããšãæãåºããŠãã ããã
<!-- AAD Auth v1--> <add key="ActiveDirectory.Mode" value="v1" /> <add key="ActiveDirectory.ResourceId" value="https://graph.microsoft.com/" /> <add key="ActiveDirectory.EndpointUrl" value="https://login.microsoftonline.com" /> <add key="ActiveDirectory.Tenant" value="YOUR_DOMAIN.COM" /> <add key="ActiveDirectory.ClientId" value="client_ID" /> <add key="ActiveDirectory.ClientSecret" value="super_secret" /> <add key="ActiveDirectory.RedirectUrl" value="http://localhost:3979/api/OAuthCallback" />
ãã®ã»ããã¢ããã¯ç°¡åãªäœæ¥ã§ã¯ãããŸããã èªèšŒãšã©ãŒã®å Žåãã·ã¹ãã ã¯çç±ã調ã¹ãå Žæãç解ããã®ã«åœ¹ç«ã€ã¡ãã»ãŒãžã衚瀺ããŸãã ãããã®ã¡ãã»ãŒãžã¯éåžžã«è©³çŽ°ã§ããããã©ãã«ã·ã¥ãŒãã£ã³ã°ã«éåžžã«åœ¹ç«ã¡ãŸãã äžè¬ã«ããã®ã»ããã¢ããã¯éåžžã«è€éã«ãªãå¯èœæ§ããããŸãã ç¹å®ã®ã¢ã¯ã»ã¹æš©ãååŸããã«ã¯ããã¡ã€ã³ç®¡çè
ã«é£çµ¡ããå¿
èŠãããå ŽåããããŸãã ãã®ã¹ãããã«ååãªæéãå²ãåœãŠãããšã匷ããå§ãããŸãã 幞ããªããšã«ããã®ã³ã³ããŒãã³ããæ©èœããããèšå®ã«æ»ãå¿
èŠã¯ãããŸããã
ããããããã°ã©ã ã®ã»ããã¢ãã
ããããããã°ã©ã ã®
äœæããã³ç»é²ã®æ®µéã§
ãããããããã°ã©ã ã®ååãIDãããã³ã¯ã©ã€ã¢ã³ãããŒãçæãããŸãã ãããã®å€ã¯ãweb.configãã¡ã€ã«ã®æ¬¡ã®è¡ã«è¿œå ããå¿
èŠããããŸãã
<add key="BotId" value="YourBotId" /> <add key="MicrosoftAppId" value="" /> <add key="MicrosoftAppPassword" value="" />
QïŒA Makerã»ããã¢ãã
QïŒAã¡ãŒã«ãŒãäœæãããšãIDãšããŒãåãåããŸãã ãµãŒãã¹ã«é£çµ¡ããŠæšå¥šäºé
ãåãåãã«ã¯ã圌ããå¿
èŠã«ãªããŸãã web.configãã¡ã€ã«ã®æ¬¡ã®è¡ã«é©åãªããŒãå
¥åããŸãã
<!-- QnaMaker --> <add key="QnaMaker.KbId" value="QAMaker_ID" /> <add key="QnaMaker.KbKey" value="QAMaker_Key" />
LUISãæ§æãã
LUIS㯠ãSharePointãã€ã¢ãã°ã§ãã¢ã¯ã»ã¹ããSharePointãªãœãŒã¹ã®URLãŸãã¯ååãããã³ã¢ã¯ã»ã¹ã®çš®é¡ãååŸããããã«äœ¿çšãããŸãã ãã®ãµãŒãã¹ïŒä»ã®ã»ãšãã©ã®ãµãŒãã¹ãšåæ§ïŒãäœæããŠæ§æãããšãIDãšã·ãŒã¯ã¬ãããååŸãããŸãã ã¡ã€ã³ãã€ã¢ãã°ã¯ã©ã¹ãLUISå±æ§ã§ããŒã¯ããå¿
èŠããããŸãã
[LuisModel("Key-with-dash", "secret")] public class SpDialog : LuisDialog<object>
ã³ãŒãèªèšŒç®¡ç
ã³ãŒãã«ã¯ãããŸããŸãªèªèšŒæäœããããã«ç°ãªãæ¹æ³ã§å®è£
ãããŠããŸãã äž»ãªèªèšŒæé ã¯ãAADãµãŒãã¹ã«ã¢ã¯ã»ã¹ããããšã§ãããã®å Žåããœãªã¥ãŒã·ã§ã³ã¯ãMicrosoft Graphãžã®åŸç¶ã®åŒã³åºãã®ããã«ããŒã¯ã³ãåãåããŸãã
AADã§ã®èªèšŒ
ãã®ã¡ã«ããºã ã¯æ¬¡ã®ããã«æ©èœããŸãã
ã»ãšãã©ã®ã³ãŒãã¯AuthBotã³ã³ããŒãã³ãã«é¢é£ããŠããŸãã ãã§ã«èª¬æããããã«ãç¹å®ã®æ»æãã¯ãã«ããããã¯ããã«ã¯ãã³ãŒããå€æŽããã«è»¢éããããšãéèŠã§ãã ããŒã¯ã³ã«ã¯ããŸããŸãªæ
å ±ã«ã¢ã¯ã»ã¹ããããã«å¿
èŠãªãã¹ãŠã®è³æ Œæ
å ±ãå«ãŸããŠããããïŒãã®å ŽåããŠãŒã¶ãŒã®ã¢ãã¬ã¹ããé»åã¡ãŒã«ãéä¿¡ããããïŒãããŒã¯ã³ã¯éåžžã«éèŠã§ãã ã»ãã¥ãªãã£ã·ã¹ãã ã䜿çšãããšãã¯ãåŽåãç¯çŽããªãã§ãã ããã ä¿è·ã«ã¯æ倧éã®æ³šæãæãå¿
èŠããããŸãã
AADãä»ããèªèšŒãé»åã¡ãŒã«ã«å¯ŸããŠæ©èœããŸãã 泚ïŒèªèšŒã¯ãããããããã°ã©ã ãå®çšŒåç°å¢ã§å®è¡ãããŠããå Žåã«ãé»åã¡ãŒã«ã§ããåãããå Žåã«ã®ã¿æ€èšŒã§ããŸãã é»åã¡ãŒã«ã¯Office 365ã¢ã«ãŠã³ãããåä¿¡ãããçŽ___åããšã«åŠçãããŸãã
ãŠãŒã¶ãŒã«ãšã£ãŠãé»åã¡ãŒã«ãä»ããã·ã¹ãã ãšã®ããåãã¯ãä»ã®ãã£ãã«ãšã»ãšãã©å€ãããŸããã ãŠãŒã¶ãŒã¯é»åã¡ãŒã«ãéä¿¡ããããããããã°ã©ã ã¯ã·ã¹ãã ãžã®æåŸ
ãéä¿¡ããŸããããã«å¿ããŠããŠãŒã¶ãŒã¯ã³ãŒããéä¿¡ããå¿
èŠããããŸãã åºæ¬ã®AuthBotã³ãŒãã¯ã察話ããã䟿å©ã«ããããã«å€æŽãããŸããïŒç¹ã«ãéä¿¡ãããé»åã¡ãŒã«ã®æ°ãæžãããã³ãŒãæœåºãç°¡çŽ åããŸãïŒã
æåã®æåã«å¿çããŠãããããããã°ã©ã ã¯ãŠãŒã¶ãŒã«ã¡ãã»ãŒãžãéä¿¡ããèªèšŒã®ããã«ãªã³ã¯ããã©ãèŠæ±ãéä¿¡ããŸãã ãã®åŸããŠãŒã¶ãŒã¯ã³ãŒããéä¿¡ããå¿
èŠããããŸãã
ãããåä¿¡ããåŸãããããããã°ã©ã ã¯èªèšŒã®æåã«é¢ããã¡ãã»ãŒãžãéä¿¡ããŸãã ãŠãŒã¶ãŒãéä¿¡ããä»ã®ãã¹ãŠã®ã¡ãã»ãŒãžã¯ããã®ãŠãŒã¶ãŒã®ã³ã³ããã¹ããèæ
®ããŠãããããããã°ã©ã ã®ãµãŒãã¹ããã»ã¹ã«ãã£ãŠåŠçãããŸãã éä¿¡ãã£ãã«ïŒããŒã ãŸãã¯ãã®ä»ïŒã«é¢ä¿ãªãããŠãŒã¶ãŒã¯åãæäœãå®è¡ã§ããŸãã ãã ããé»åã¡ãŒã«ãã£ãã«ã¯ä»ã®ãã£ãã«ãšã¯å°ãç°ãªããŸããç¹ã«ããŠãŒã¶ãŒã«éä¿¡ãããé»åã¡ãŒã«ã®éãå¶éããããã€ãã®è¿œå ã®åææ¡ä»¶ãèæ
®ãã䟡å€ããããŸãã 詳现ã«ã€ããŠã¯ã以äžãã芧ãã ããã
AuthBotã®è©³çŽ°ã«ã€ããŠã¯ã察å¿ãã
GitHubããŒãžãã芧ãã ãã ã
ããããããã°ã©ã ãšå¯Ÿè©±ããããã®èªèšŒ
èªèšŒã®å Žåãããããããã°ã©ã ãšå¯Ÿè©±ãããšããSDKã®ã³ã³ããŒãã³ãã䜿çšããŠãã®ãããªããã°ã©ã ãéçºããŸãã ã¡ã€ã³ã³ã³ãããŒã©ãŒãBotAuthenticationå±æ§ã§ããŒã¯ãããŠããå Žåãåã®ã»ã¯ã·ã§ã³ïŒæ§æã«é¢ããéšåã§ïŒã§èª¬æããããŒãšã·ãŒã¯ã¬ããã䜿çšããèªèšŒã¡ã«ããºã ã䜿çšãããŸãã ããã¯å®å
šã«ééçã§ãããããã2ã€ã®èŠçŽ ããšã©ãŒãªãã§web.configãã¡ã€ã«ã«ã³ããŒãããšãæ£åžžã«æ©èœããŸãã ãããã°ã¢ãŒãã§ãIDãšã·ãŒã¯ã¬ãããå¿
èŠã§ãã ãšãã¥ã¬ãŒã¿ã¯ãã®ã¡ã«ããºã ããµããŒãããŠããããã¢ãæ©èœããŠãããã©ããã確èªããã®ã«æé©ã§ãã
namespace BotToQuerySharepoint { [BotAuthentication] public class MessagesController : ApiController {
QïŒA Makerã§ã®èªèšŒ
ããŒã¯REST APIã«ã¢ã¯ã»ã¹ããããã«äœ¿çšãããŸãã äœæ¥ã¯ã·ã³ãã«ã§æçœãªæ¹æ³ã§æ§æãããŠããŸãã ã³ãŒãã¹ããããã¯æ¬¡ã®ãšããã§ãã
public virtual async Task MessageReceivedAsync(IDialogContext context, IAwaitable<IMessageActivity> item) { var message = await item; { string kbId = ConfigurationManager.AppSettings["QnaMaker.KbId"]; string kbKey = ConfigurationManager.AppSettings["QnaMaker.KbKey"]; string qnaUrl = $"https://westus.api.cognitive.microsoft.com/qnamaker/v2.0/knowledgebases/{kbId}/generateAnswer"; HttpClient client = new HttpClient(); var json = new { question = strtosend, top = 3 }; var content = new StringContent(JsonConvert.SerializeObject(json), Encoding.UTF8, "application/json"); content.Headers.Add("Ocp-Apim-Subscription-Key", kbKey); HttpResponseMessage response = await client.PostAsync(qnaUrl, content); if (response.StatusCode == HttpStatusCode.OK) {
APIã¯éåžžã«åçŽã§ãã ããã¥ã¡ã³ãã¯
ãã¡ãããå
¥æã§ã
ãŸã ã å質åã«å¯ŸããŠ3ã€ä»¥äžã®åçãè¿ãAPIã®1ã€ã®ã¿ã䜿çšããŸãã
LUISèªèšŒ
åã®ã»ã¯ã·ã§ã³ã§èª¬æããããã«ãèªèšŒãæå¹ã«ããããã«ãåã«ã¯ã©ã¹å±æ§ãæå®ããŸããã ãã®ã¡ã«ããºã ã¯å®å
šã«ééçã§ãã
ã¡ãŒã«ãã£ã³ãã«
æ¢ã«è¿°ã¹ãããã«ãé»åã¡ãŒã«ãã£ãã«ïŒSMSãã£ãã«ãªã©ïŒã«ã¯ç¹å®ã®æ©èœããããŸãã ã©ã¡ãã®å Žåããéä¿¡ãããã¡ãã»ãŒãžã®éãæžããããåªããããšã¯åççã§ãã ãããè¡ãããã«ãèªèšŒããã»ã¹ããããã«å€æŽããŠãé»åã¡ãŒã«ã®æ°ãæžãããã¬ã¿ãŒããã³ãŒããæœåºããŸããã
é»åã¡ãŒã«ã§ã¡ãã»ãŒãžãéä¿¡ããããšã«ããããŠãŒã¶ãŒã¯ä»¥åã®éä¿¡ããã®ä»ã®äžèŠãªæ
å ±ãåé€ããããšã¯ã»ãšãã©ãããŸãããåã«æ°ããããã¹ããè¿œå ããã ãã§ãã ãã®çµæãã¬ã¿ãŒã«ã¯ãŠãŒã¶ãŒã®çœ²åãšãã®ä»ã®èŠçŽ ãå«ãŸããŸãã ãããã£ãŠããã®ãã£ãã«ãä»ããŠå¯Ÿè©±ããå Žåãããããåé€ããã«ã¯è¿œå ã®äœæ¥ãå¿
èŠã«ãªããŸãã äŸãšããŠã以äžã¯AuthBotã®AzureAuthDialogã³ãŒãã®ã¹ããããã§ãã
if (msg.Text == null) { if (msg.ChannelId != "email") { await context.PostAsync($", ."); } context.Wait(this.MessageReceivedAsync); } else {
ãŠãŒã¶ãŒã«éä¿¡ãããé»åã¡ãŒã«ã®æ°ãæžããããã«ãåä¿¡ããèªèšŒã³ãŒããè¿éããã ãã§ãªããWebããŒãžã«è¡šç€ºããŠãŠãŒã¶ãŒã«æçŽã«è¿ä¿¡ããããã«äŸé ŒããŸãã OAuthCallbackControllerã³ãŒããããããããã«ãAuthBotã®èªèšŒæé ã¯éä¿¡ãã£ãã«ã«ãã£ãŠç°ãªããŸãã
await Conversation.ResumeAsync(resumptionCookie, message); if (message.ChannelId == "skypeforbusiness") resp.Content = new StringContent($"<html><body> ! , , :<br/> {magicNumber} </body></html>", System.Text.Encoding.UTF8, @"text/html"); else if (message.ChannelId == "email") resp.Content = new StringContent($"<html><body> ! , , :<br/> {magicNumber} </body></html>", System.Text.Encoding.UTF8, @"text/html"); else resp.Content = new StringContent($"<html><body> ! , , :<br/> <h1>{magicNumber}</h1>.</body></html>", System.Text.Encoding.UTF8, @"text/html");
åãã£ãã«ã«ã¯äžæã®ååããããŸãã ããã«ãããããããããã°ã©ã ã®åäœããã£ã³ãã«ã®ã¿ã€ãã«ç°¡åã«é©åãããããšãã§ããŸãã
å¥ã®äŸã¯ãã¡ã€ã³ããããããã°ã©ã ã®QïŒAãã€ã¢ãã°ïŒkbDialogïŒã³ãŒãã«å«ãŸããŠããŸãã
string strtosend = message.Text; if (message.ChannelId == "email") { var str = strtosend.Split('\n'); int maxidx = str.Length; if (maxidx > 3) maxidx = 4; for (int i = 0; i < maxidx; i++) strtosend += str[i] + " "; }
ãã®ã³ãŒãã®ç®çã¯ãé»åã¡ãŒã«ã®æåã®éšåã®ã¿ãæœåºãã眲åãåé€ããããšã§ãã å¯èœæ§ã®ãã質åãæåã®3è¡ã«å«ãŸããŠãããšæ³å®ãããŸãã 以äžã¯ã以åã®æçŽãŸãã¯ãŠãŒã¶ãŒã®çœ²åã§ãã ããã¯åãªãä»®å®ã§ãããåžžã«æºããããããã§ã¯ãããŸãããã3æ¥éã®ããã«ãœã³äžã«å®å
šã«æ©èœããŸããã
å¥ã®äŸã¯ãå¿çã®æ»ããå¶åŸ¡ããQïŒA Makerã³ãŒãã¹ããããã§ãã éåžžããœãªã¥ãŒã·ã§ã³ã¯3ã€ä»¥äžã®ãªãã·ã§ã³ããŠãŒã¶ãŒã«æäŸãããŠãŒã¶ãŒã«æé©ãªãªãã·ã§ã³ãå°ããŸãã ãããããŠãŒã¶ãŒã質åãé»åã¡ãŒã«ã§éä¿¡ããå ŽåããŠãŒã¶ãŒã¯ã«ãŠã³ã¿ãŒãªã¯ãšã¹ãã§ã¯ãªãåçãåãåãããšãæåŸ
ããŠããŸãã ãããè¡ãããšã«ããŸããã質åãé»åã¡ãŒã«ã§åä¿¡ãããå Žåããœãªã¥ãŒã·ã§ã³ã¯æåã®åçãè¿ãã ãã§ãã ãŸãããã¹ãŠã®å¿çã®è©³çŽ°ãªå
容ãã¡ãŒã«ã«å«ãããªãã·ã§ã³ãæ€èšããŸããã 次ã®ã³ãŒãã¹ããããã¯ããã®åŠçã®å®è¡æ¹æ³ã瀺ããŠããŸãã
if (qnaResponse.answers.Count == 0) { await context.PostAsync( " . \n - QNA?"); context.Done(true); } else if ((qnaResponse.answers.Count == 1) || (message.ChannelId == "email")) { await context.PostAsync(qnaResponse.answers.First().answer); context.Done(true); } else {
Microsoft GraphãšSharePoint
Microsoft Graph-ãŠãŒã¶ãŒããŒã¿ã®èªã¿åããå€æŽãäœæã®ããã®åäžã®REST APIïŒäŸïŒã«ã¹ã¿ã ã«ã¬ã³ããŒãé»åã¡ãŒã«ãSharePointã³ã³ãã³ããOneDriveïŒã ãã®ãããžã§ã¯ãã®äžç°ãšããŠãSharePointããã³é»åã¡ãŒã«ãšããåãããããã®Graph APIã³ã³ããŒãã³ãã«èå³ããããŸããã
ã¿ã¹ã¯ãç°¡çŽ åããããã«ãMicrosoft.Graph Nugetããã±ãŒãžã䜿çšããŸããã Nugetããã±ãŒãžã®ã³ã³ããŒãã³ãã¯ããã¹ãŠã®èŠæ±ãåŠçãããªããžã§ã¯ããè¿ããŸãã ãã ããããŒã¯ã³ãèªèšŒããŠååŸããå¿
èŠããããŸãã 幞ããªããšã«ãèªèšŒã¡ã«ããºã ã¯ãã§ã«æºåãããŠããŸãïŒãããŠäžèšã§èª¬æããŸããïŒã
äŸãšããŠãSharePointãµããµã€ãã®ææè
ã®ååãè¿ãé¢æ°ã®ã³ãŒãã以äžã«ç€ºããŸãã
public async Task<UserInfo> GetOwnerNameForSite(string token, string siteId) { var graphService = new GraphServiceClient( new DelegateAuthenticationProvider( (requestMessage) => { requestMessage.Headers.Authorization = new AuthenticationHeaderValue("bearer", token); return Task.FromResult(0); })); var s = await graphService.Sites[siteId] .Drives.Request() .GetAsync(); var user = await graphService.Users[s.First().CreatedBy.User.Id].Request().GetAsync(); return new UserInfo() { EmailAddress = user.Mail, Name = user.DisplayName }; }
GraphServiceClientãªããžã§ã¯ããäœæãããšãã¯ãã³ãŒãã«ç€ºãããŠããããã«ããŒã¯ã³ãæž¡ãã ãã§ååã§ãããã®åŸãå¿
èŠãªGraphé¢æ°ãåŒã³åºãããšãã§ããŸãã
è¿ãããã¢ã€ãã ã¯ãã¹ãŠéåžžã«ç°¡åã«åæã§ããããããããã®æäœã¯ç°¡åã§è«ççã§ãã ãã®å ŽåãSharePointã®ææè
ã«ã¡ãŒã«ãéä¿¡ãããããã¡ãŒã«ã¢ãã¬ã¹ãšååãååŸããå¿
èŠããããŸãã ãã®åŸãååã§ãŠãŒã¶ãŒã«é£çµ¡ããæçŽãéãããšãã§ããŸãã
Microsoft Graphã䜿çšããã¡ãŒã«éä¿¡ãéåžžã«ç°¡åã§ãã
public async Task SendEmail(string accessToken, string emailAddress, string body, string subject) { var message = new Message(); message.Body = new ItemBody() { Content = body, ContentType = BodyType.Text }; message.ToRecipients = new List<Recipient>() { new Recipient() {EmailAddress = new EmailAddress() {Address = emailAddress}} }; message.Subject = subject; var graphserviceClient = new GraphServiceClient( new DelegateAuthenticationProvider( (requestMessage) => { requestMessage.Headers.Authorization = new AuthenticationHeaderValue("bearer", accessToken); return Task.FromResult(0); })); await graphserviceClient.Me.SendMail(message, true).Request().PostAsync(); }
ãã®äŸã§ã¯ãåçŽãªããã¹ãã¡ãã»ãŒãžãéä¿¡ããŸãããHTMLããµããŒããããŠããŸãã è€æ°ã®åä¿¡è
ã«æçŽãéãããšãã§ããŸãã æ¢è£œã®ãœãªã¥ãŒã·ã§ã³ããªãªãŒã¹ããã®ã«ãã£ã3æ¥éãããªãã£ããããã§ããéãã·ã³ãã«ãªã³ãŒããäœæããããšã«ããŸããã
ãŠãŒã¶ãŒãèªåã®è³æ Œæ
å ±ã§èªèšŒãããå Žåãã¡ãŒã«ã¯ã¡ãŒã«ããã¯ã¹ããéä¿¡ãããéä¿¡æžã¿ãã©ã«ããŒã§å©çšå¯èœã«ãªããŸãã
ãã®ãµã€ãã§Microsoft Graphã®ãã¹ãŠã®æ©èœãè©Šãããšãã§ããŸãã ç¬èªã®è³æ Œæ
å ±ãæå®ããŠèªèšŒããä»»æã®æ©èœãæäœããŠããšãªã¢ã®è¿œå ãŸãã¯åé€ãçµæã«ã©ã®ããã«åœ±é¿ãããã確èªã§ããŸãã
QïŒAã¡ãŒã«ãŒã®ãã³ã
QïŒA Makerã¯ã質åãšåçã®ãã¢ãéåžžã«è¿
éã«æºåãã質åã«å¯ŸããåçãåŸãããšãã§ããèªç¥ãµãŒãã¹ãéå§ããããã®åªããããŒã«ã§ãã ãã®ããŒã«ã¯çµ±åãéåžžã«ç°¡åã§äœ¿ããããã§ãã ãã®ãµãŒãã¹ã®äœæ¥ã¯ãŸã é²è¡äžã§ãã å©çšå¯èœãªããŒãžã§ã³ã¯ãã¬ã€ãã³ã¹ã®ã¿ã§ãã ããã¯æ¬¡ã®ãããªãã®ã§ãã
ãªã¹ãã«å
¥åããããã€ãã®æ¹æ³ããµããŒããããŠããŸãã APIïŒããã¥ã¡ã³ãã¯
ãã¡ãããå
¥æå¯èœïŒã䜿çš
ããããtsvãã¡ã€ã«ãã€ã³ããŒãããããURLãæäŸã§ããŸãã
Endavaãã¬ããžããŒã¹ã䜿çšããã«ã¯ãèªèšŒãå¿
èŠã§ããããQïŒA Makerã䜿çšããå Žåã¯å¿
èŠãããŸããã ãããã£ãŠãããŒã¹ããšã¯ã¹ããŒãããå¿
èŠããããŸããã ããŒã¿ã¯ãHTMLã³ãŒããå«ãããŸããŸãªåœ¢åŒã§ä¿åãããŠããããããã®ã³ãŒãããããã«ããå¿
èŠããããŸããã
æ£èŠè¡šçŸã䜿çšããŠããŒã¿ãæ¶å»ããŸãããHTMLã¿ã°ãåé€ããã¿ããšæ¹è¡ãè¿œå ããŸããã ã³ãŒãã¹ããããã¯æ¬¡ã®ãšããã§ãã
ã¿ãæåã\ tã§ã¯ãªã\\ tãšæžãããŠããçç±ãå°ããããšãã§ããŸãã çãã¯ã\\ næåã®å Žåãšåãã§ãã å®éãQïŒA Makerã¯çã®ããã¹ãããŒã¿ã®åœ¢åŒã§å¿çãä¿åããŠè¿ããŸãã 䜿çšãããtsvãã¡ã€ã«ã«ã¯ããã£ãªããžãªã¿ãŒã³ãŸãã¯è¿œå ã®ã¿ãæåãå«ããããšã¯ã§ããŸãããããããªããšãã·ã¹ãã ããããæ£ããåŠçã§ããªãå ŽåããããŸãã ãã¹ãŠã®ãã£ãã«ã®ãã³ãã©ãŒã¯ãæå\ tããã³\ nãæ£ãã衚瀺ãããããå¿çãããé©åã«ãã©ãŒãããã§ããŸãã
éèŠãªæ³šæïŒQïŒA Makerã¯ãMarkdownããŒã¯ã¢ããã䜿çšããŠããŒã¿ãä¿åã§ããŸãããäžéšã®ãã£ãã«ã§ã¯ãµããŒããããªãå¯èœæ§ãããããšã«æ³šæããŠãã ãã ã¹ã¯ãªãŒã³ã·ã§ããã¯ãããã€ãã®æ¹è¡\ nã瀺ããŠããŸãã
ãŸããååçã«ãã¬ããžããŒã¹ã®ã¡ã€ã³ããŒãžãžã®ãªã³ã¯ãè¿œå ããŸããã ãããã®ããŒãžã¯ãã¬ãŒã³ããã¹ããããèŠæ ãããããã¡ã€ã³ã³ãŒãããå®å
šã«åé€ããç»åãå«ãŸããŠããå ŽåããããŸãã ãŠãŒã¶ãŒãã§ããã ãå¿«é©ã«ãªãããã«åªããŸããã
é©åãªåçãéžæãããšãQïŒA Makerã¯è³ªåãšåçã®äž¡æ¹ã®ããã¹ããåæããŸãã ãããã£ãŠãåçãå¯èœãªéã詳现ã«ããå¿
èŠããããŸãã
LUISã®ãã³ã
LUISã®æ§æã¯éåžžã«ç°¡åã§ãã ãã®äŸã§ã¯ã1ã€ã®æå³ãš3ã€ã®ãšã³ãã£ãã£ã®ã¿ã䜿çšãããŸãã
LUISã¯æ¬¡ã®ããã«æ©èœããŸãã
- ãŠãŒã¶ãŒãªã¯ãšã¹ãïŒ[éçº]å
±æãã€ã³ããµã€ãã«ã¢ã¯ã»ã¹ããŸã[èªã¿åã]ã
- LUISã¯ãã®æå³ïŒSharePointãžã®ã¢ã¯ã»ã¹ïŒãç解ãã[èªã¿åã]ãš[éçº]ã®2ã€ã®ãšã³ãã£ãã£ãæœåºããŸãã
ã€ã³ãã³ããåŠçããLUISãã€ã¢ãã°ã¯ã©ã¹ããç¹å®ã®é¢æ°ãåŒã³åºãã«ã¯ã以äžã«ç€ºãããã«ãã€ã³ãã³ãã®ååãæã€å±æ§ã§é¢æ°ãããŒã¯ããã ãã§ãã
[LuisIntent("sp-access")] public virtual async Task ProcessSpAccessRequest(IDialogContext context, LuisResult luisResult) { var accessToken = await context.GetAccessToken( ConfigurationManager.AppSettings[ "ActiveDirectory.ResourceId"]);
SharePointããããããã°ã©ã ãšã®ããåãã¯ã¯ããã«ç·åœ¢ã§ãããããLUISãã€ã¢ãã°ããã©ãŒã ãä»ãããã€ã¢ãã°ã«çœ®ãæããŸããç·åœ¢è³ªåã®å Žåã¯ãäœæ¥ãã¯ããã«ç°¡åã«ãªããŸãã SharePoint質ååŠçã³ãŒãã®ã»ãšãã©ã¯ãSpFormHandlerãã©ãŒã ã«é¢é£ããŠããŸãã ããã¯ãè€æ°ã®ãã€ã¢ãã°ãçµã¿åããããšã¬ã¬ã³ããªæ¹æ³ã§ãã ã³ãŒããããããããã«ãä»»æã®ãªããžã§ã¯ããã³ã³ã¹ãã©ã¯ã¿ãŒã«æž¡ãããšãã§ããŸãã
[Serializable] public class SpFormHandler { public IFormDialog<SharepointModel> GetFormDialog(IEnumerable<EntityRecommendation> entities, string token) { var spForm = new SharepointModel(); spForm.Token = token; foreach (EntityRecommendation entity in entities) { if (entity.Type == "sp-sitename" || entity.Type == "builtin.url") { spForm.SitenameOrUrl = entity.Entity; } if (entity.Type == "sp-accessright") { Enum.TryParse(entity.Entity, true, out AccessRights rights); spForm.AccessRights = rights; } } return new FormDialog<SharepointModel>(spForm, BuildForm, FormOptions.PromptInStart); } private IForm<SharepointModel> BuildForm() {
LUISããã®ãšã³ãã£ãã£ãšããŒã¯ã³ã®äž¡æ¹ã転éãããŸãã ãšã³ãã£ãã£ã¯ãèŠæ±ãããã¢ã¯ã»ã¹ã¿ã€ããšåæ§ã«ãSharePointãªãœãŒã¹ã®URLãŸãã¯ååãååŸããããã«äœ¿çšãããŸãã LUISã«ã¯ãURLãªã©ã®å€ãã®çµã¿èŸŒã¿ãšã³ãã£ãã£ãå«ãŸããŠããŸãã ãããã䜿çšããããšã匷ããå§ãããŸãããããã¯ããŸãæ©èœããæéã®ç¯çŽã«åœ¹ç«ã¡ãŸãã
ããŸããŸãªãã€ã¢ãã°ã®åå²ãLUISãã€ã¢ãã°ããã©ãŒã ã䜿çšãããã€ã¢ãã°ãããã³è§£æ±ºããã¿ã¹ã¯ãèæ
®ããéåžžã®ãã€ã¢ãã°ã®çµã¿åããã¯ãå®å
šã«æ£åœåãããäœæ¥ã¢ãããŒãã§ãã
çµè«ãšæ¬¡ã®ã¹ããã
ãã®ãããžã§ã¯ãã®ã³ãŒãã¯3æ¥éã§æžãããã³ãŒãã®äžéšã«ãããŸããããAzure Active Directoryãä»ããèªèšŒãé»åã¡ãŒã«ãå«ãããŸããŸãªãã£ãã«ãä»ããããããããã°ã©ã ãšã®çžäºäœçšãã³ã°ããã£ããµãŒãã¹ã®äœ¿çšãªã©Microsoft Graphãä»ããQïŒAã¡ãŒã«ãŒãšLUISã
å
¬éãããã³ãŒããšããã¥ã¡ã³ãã¯ãå®å
šã«æ©èœãããœãªã¥ãŒã·ã§ã³ã圢æããŸãã å®éã«ã¯ãéšåçãªãœãªã¥ãŒã·ã§ã³ãšå®å
šãªãœãªã¥ãŒã·ã§ã³ã®äž¡æ¹ãäœéšã§ããŸãã Microsoft Graphã³ã³ããŒãã³ãã䜿çšããã«ã¯ãèªèšŒããŠããŒã¯ã³ãååŸããå¿
èŠããããŸãã «», Azure Active Directory , . .
, .
èè
ã«ã€ããŠ
, , - , , . , , . Microsoft, 20 . , , .