From ed8a4dc8569017f88c0c7dfea8ebce1a0f77805e Mon Sep 17 00:00:00 2001 From: Unknown Date: Sat, 9 Feb 2019 18:04:29 +0100 Subject: [PATCH 01/13] Update Microsoft.Net.Compilers --- EmergencyServicesBot.csproj | 4 ++-- packages.config | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/EmergencyServicesBot.csproj b/EmergencyServicesBot.csproj index a084936..ed8762b 100644 --- a/EmergencyServicesBot.csproj +++ b/EmergencyServicesBot.csproj @@ -1,7 +1,7 @@  + - @@ -256,9 +256,9 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Voici une réponse qui je pense vous aidera : + + + Bien sûr, Comment puis-je vous aider ? Vous pouvez demander quelque chose comme “Quelle démarche dois-je faire pour une déclaration d'assurance ?” ou “Comment puis-je contacter un centre d'urgence pour une assistance ?” + + + Obtenir les réponses + + + 1 - Obtenir les réponses + + + 2 - 🌐 Sélectionner la langue + + + Auriez-vous d'autres questions auxquelles je pourrais répondre ? + + + 🌐 Sélectionner la langue + + + Langue définie à + + + Bienvenue dans le bot de Service d'Urgences ! Comment puis-je vous aider ? + + + J'ai rencontré une erreur dans la demande de réponse à votre question. Peut-être une autre question marchera mieux. Y-a-t-il quelque chose d'autre que je puisse faire pour vous aider ? + + + Désolé, je n'ai pas trouvé de réponse correspondant à votre demande. + + + Plus d'informations + + + https://pbs.twimg.com/profile_images/378800000210718633/4a028ce30e9238501be08f97ddbfd9f8_400x400.png + + + Service d'Urgences bot + + \ No newline at end of file From 3d7d720a119b061b0d5b1bcfed85ff0d1fb6ec69 Mon Sep 17 00:00:00 2001 From: Unknown Date: Sun, 10 Feb 2019 08:17:15 +0100 Subject: [PATCH 07/13] Change french display name --- Dialogs/LanguageConst.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dialogs/LanguageConst.cs b/Dialogs/LanguageConst.cs index c408195..6ebaa2e 100644 --- a/Dialogs/LanguageConst.cs +++ b/Dialogs/LanguageConst.cs @@ -25,7 +25,7 @@ internal static class LanguageConst internal const string enLanguageName = "English"; internal const string esLanguageName = "Español"; internal const string zhLanguageName = "中文"; - internal const string frLanguageName = "French"; + internal const string frLanguageName = "Français"; internal static readonly string[] languages = new[] { enLanguageName, esLanguageName, zhLanguageName, frLanguageName }; internal static readonly string[] smsLanguages = new[] { $"1 -{enLanguageName}", $"2 -{esLanguageName}", $"3 -{zhLanguageName}", $"4 -{frLanguageName}" }; From bd8270d5f881aa00e70996e0bfbcb814762ac602 Mon Sep 17 00:00:00 2001 From: Unknown Date: Sun, 10 Feb 2019 08:34:20 +0100 Subject: [PATCH 08/13] Add french welcome message and choices --- Dialogs/QandADialog.cs | 6 +++--- Dialogs/RootDialog.cs | 9 ++++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Dialogs/QandADialog.cs b/Dialogs/QandADialog.cs index b0788d1..1017f2b 100644 --- a/Dialogs/QandADialog.cs +++ b/Dialogs/QandADialog.cs @@ -53,9 +53,7 @@ private async Task QuestionAskedImpl(IDialogContext context, string question) using (var qnaClient = new HttpClient { BaseAddress = new Uri(ConfigurationManager.AppSettings[@"QnAendpoint"] + ConfigurationManager.AppSettings[@"QnAKnowledgebaseId"] + "/generateanswer" )}) { qnaClient.DefaultRequestHeaders.Add(@"Ocp-Apim-Subscription-Key", ConfigurationManager.AppSettings[@"QnASubscriptionKey"]); - - - + string ApiKey = ConfigurationManager.AppSettings[@"TranslatorApiKey"]; string targetLang = context.UserData.GetValue(@"userLanguage"); string knowledgeBaseLang = ConfigurationManager.AppSettings[@"QnAKnowledgebaseLanguage"]; @@ -163,10 +161,12 @@ static async Task GetAuthenticationToken(string key) } } + //TODO change to use resources private bool IsDoneCommand(string commandText) => commandText.Equals(@"done", StringComparison.OrdinalIgnoreCase) || commandText.StartsWith(@"no", StringComparison.OrdinalIgnoreCase) || commandText.Equals(@"exit", StringComparison.OrdinalIgnoreCase) + || commandText.Equals(@"quitter", StringComparison.OrdinalIgnoreCase) || commandText.Equals(@"quit", StringComparison.OrdinalIgnoreCase); } } \ No newline at end of file diff --git a/Dialogs/RootDialog.cs b/Dialogs/RootDialog.cs index 87a86ef..d760a43 100644 --- a/Dialogs/RootDialog.cs +++ b/Dialogs/RootDialog.cs @@ -139,12 +139,15 @@ private async Task UserChoiceMade(IDialogContext context, IAwaitable res { var choice = await result; + //TODO change with resource entry directly if ((choice.IndexOf(@"get answers", 0, StringComparison.OrdinalIgnoreCase) != -1) || (choice.IndexOf(@"Obtener Respuestas", 0, StringComparison.OrdinalIgnoreCase) != -1) || + (choice.IndexOf(@"Obtenir les réponses", 0, StringComparison.OrdinalIgnoreCase) != -1) || (choice.IndexOf(@"其他问题", 0, StringComparison.OrdinalIgnoreCase) != -1)) context.Call(new QandADialog(), DoneWithSubdialog); else if ((choice.IndexOf(@"Select language", 0, StringComparison.OrdinalIgnoreCase) != -1) || (choice.IndexOf(@"Seleccione el idioma", 0, StringComparison.OrdinalIgnoreCase) != -1) || + (choice.IndexOf(@"Sélectionner la langue", 0, StringComparison.OrdinalIgnoreCase) != -1) || (choice.IndexOf(@"选择语言", 0, StringComparison.OrdinalIgnoreCase) != -1)) context.Call(new SetLanguage(), DoneWithSubdialog); } @@ -183,12 +186,12 @@ public static async Task SendWelcomeMessage(IMessageActivity activity) Url = translateDialog.GetString("WelcomeImageUrl", LanguageConst.ciEnglish), }; - + //TODO change by adding resources instead of hardcoded text var heroCard = new HeroCard { Title = title, - Subtitle = "Hello. Hola. 你好.", - Text = "Say \"hi\" to begin, diga \"hola\" para comenzar, 说“嗨”开始", + Subtitle = "Hello. Hola. 你好. Bonjour.", + Text = "Say \"hi\" to begin, diga \"hola\" para comenzar, 说“嗨”开始, dites \"Bonjour\" pour commencer", Images = new List { CI } }; From 3e86e078323a041936178f5cbfe29ffcb83e7802 Mon Sep 17 00:00:00 2001 From: Unknown Date: Sun, 10 Feb 2019 08:48:05 +0100 Subject: [PATCH 09/13] Set language to french --- Dialogs/SetLanguage.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dialogs/SetLanguage.cs b/Dialogs/SetLanguage.cs index 29bdf20..bbaf02a 100644 --- a/Dialogs/SetLanguage.cs +++ b/Dialogs/SetLanguage.cs @@ -57,7 +57,7 @@ private async Task onLanguageSelect(IDialogContext context, IAwaitable r { choice = LanguageConst.frLanguageId; selectedLanguage = LanguageConst.frLanguageName; - culture = LanguageConst.ciChinese; + culture = LanguageConst.ciFrench; } else { From dfd07656ee26764f9268b0197eb1146809f6e55e Mon Sep 17 00:00:00 2001 From: Unknown Date: Tue, 12 Feb 2019 09:55:50 +0100 Subject: [PATCH 10/13] Revert to use Authorization header for QnA client --- Dialogs/QandADialog.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dialogs/QandADialog.cs b/Dialogs/QandADialog.cs index 1017f2b..7b30eb5 100644 --- a/Dialogs/QandADialog.cs +++ b/Dialogs/QandADialog.cs @@ -52,8 +52,8 @@ private async Task QuestionAskedImpl(IDialogContext context, string question) { using (var qnaClient = new HttpClient { BaseAddress = new Uri(ConfigurationManager.AppSettings[@"QnAendpoint"] + ConfigurationManager.AppSettings[@"QnAKnowledgebaseId"] + "/generateanswer" )}) { - qnaClient.DefaultRequestHeaders.Add(@"Ocp-Apim-Subscription-Key", ConfigurationManager.AppSettings[@"QnASubscriptionKey"]); - + qnaClient.DefaultRequestHeaders.Add("Authorization", $"EndpointKey {ConfigurationManager.AppSettings[@"QnASubscriptionKey"]}"); + string ApiKey = ConfigurationManager.AppSettings[@"TranslatorApiKey"]; string targetLang = context.UserData.GetValue(@"userLanguage"); string knowledgeBaseLang = ConfigurationManager.AppSettings[@"QnAKnowledgebaseLanguage"]; From 8f4164fd7e866381ce31be16c7af9ee7f23bf5a3 Mon Sep 17 00:00:00 2001 From: Unknown Date: Tue, 12 Feb 2019 10:00:49 +0100 Subject: [PATCH 11/13] Add null operator in case null response --- Dialogs/RootDialog.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Dialogs/RootDialog.cs b/Dialogs/RootDialog.cs index d760a43..45c583e 100644 --- a/Dialogs/RootDialog.cs +++ b/Dialogs/RootDialog.cs @@ -22,9 +22,9 @@ namespace EmergencyServicesBot.Dialogs public class RootDialog : IDialog { static ResourceManager translateDialog = new ResourceManager("EmergencyServicesBot.Resources.Resources", Assembly.GetExecutingAssembly()); - + private const string userDataCultureKey = @"cultureInfo"; - + public async Task StartAsync(IDialogContext context) { /* Wait until the first message is received from the conversation and call MessageReceviedAsync @@ -85,7 +85,7 @@ private async Task DetectAndSaveUserLanguageAsync(IDialogContext context, string { var detectedLanguageXmlResponse = XDocument.Parse(await langDetectClient.GetStringAsync($@"{ConfigurationManager.AppSettings[@"TranslatorEndpoint"]}/Detect?text={HttpUtility.UrlEncode(userText)}")); - context.UserData.SetValue(@"userLanguage", detectedLanguageXmlResponse.Root.Value); + context.UserData.SetValue(@"userLanguage", detectedLanguageXmlResponse?.Root?.Value); var userCulture = GetCultureInfoFromLanguageId(detectedLanguageXmlResponse?.Root?.Value); context.UserData.SetValue(userDataCultureKey, userCulture); @@ -142,7 +142,7 @@ private async Task UserChoiceMade(IDialogContext context, IAwaitable res //TODO change with resource entry directly if ((choice.IndexOf(@"get answers", 0, StringComparison.OrdinalIgnoreCase) != -1) || (choice.IndexOf(@"Obtener Respuestas", 0, StringComparison.OrdinalIgnoreCase) != -1) || - (choice.IndexOf(@"Obtenir les réponses", 0, StringComparison.OrdinalIgnoreCase) != -1) || + (choice.IndexOf(@"Obtenir les réponses", 0, StringComparison.OrdinalIgnoreCase) != -1) || (choice.IndexOf(@"其他问题", 0, StringComparison.OrdinalIgnoreCase) != -1)) context.Call(new QandADialog(), DoneWithSubdialog); else if ((choice.IndexOf(@"Select language", 0, StringComparison.OrdinalIgnoreCase) != -1) || From 61f4262bf090b3ab8c02e827906bd0a16b058af8 Mon Sep 17 00:00:00 2001 From: Unknown Date: Tue, 12 Feb 2019 10:36:05 +0100 Subject: [PATCH 12/13] Remove hardcoded qna uri after merge --- Dialogs/QandADialog.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dialogs/QandADialog.cs b/Dialogs/QandADialog.cs index a2eb7ab..d516140 100644 --- a/Dialogs/QandADialog.cs +++ b/Dialogs/QandADialog.cs @@ -50,7 +50,7 @@ private async Task QuestionAskedImpl(IDialogContext context, string question) } else { - using (var qnaClient = new HttpClient { BaseAddress = new Uri(ConfigurationManager.AppSettings[@"QnAendpoint"] + "/knowledgebases/" + ConfigurationManager.AppSettings[@"QnAKnowledgebaseId"] + "/generateAnswer" )}) + using (var qnaClient = new HttpClient { BaseAddress = new Uri(ConfigurationManager.AppSettings[@"QnAendpoint"] + ConfigurationManager.AppSettings[@"QnAKnowledgebaseId"] + "/generateAnswer" )}) { qnaClient.DefaultRequestHeaders.Add("Authorization", $"EndpointKey {ConfigurationManager.AppSettings[@"QnASubscriptionKey"]}"); From 9a6fac434f6f4e975518895ef69a4005ee8cf1b3 Mon Sep 17 00:00:00 2001 From: Unknown Date: Tue, 12 Feb 2019 10:36:05 +0100 Subject: [PATCH 13/13] Revert "Remove hardcoded qna uri after merge" This reverts commit 61f4262bf090b3ab8c02e827906bd0a16b058af8. --- Dialogs/QandADialog.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dialogs/QandADialog.cs b/Dialogs/QandADialog.cs index d516140..a2eb7ab 100644 --- a/Dialogs/QandADialog.cs +++ b/Dialogs/QandADialog.cs @@ -50,7 +50,7 @@ private async Task QuestionAskedImpl(IDialogContext context, string question) } else { - using (var qnaClient = new HttpClient { BaseAddress = new Uri(ConfigurationManager.AppSettings[@"QnAendpoint"] + ConfigurationManager.AppSettings[@"QnAKnowledgebaseId"] + "/generateAnswer" )}) + using (var qnaClient = new HttpClient { BaseAddress = new Uri(ConfigurationManager.AppSettings[@"QnAendpoint"] + "/knowledgebases/" + ConfigurationManager.AppSettings[@"QnAKnowledgebaseId"] + "/generateAnswer" )}) { qnaClient.DefaultRequestHeaders.Add("Authorization", $"EndpointKey {ConfigurationManager.AppSettings[@"QnASubscriptionKey"]}");