/// <summary> /// POST: api/Messages /// Receive a message from a user and reply to it /// </summary> public async Task <HttpResponseMessage> Post([FromBody] Activity activity) { HttpResponseMessage response; string originalLocale = TranslationUtil.GetDefaultLocale(activity.Locale); try { // Ensure spanish await TranslationUtil.EnsureSpanishTranslation(activity); _channelId = activity.ChannelId; if (!string.IsNullOrEmpty(activity.ServiceUrl)) { _connector = new ConnectorClient(new Uri(activity.ServiceUrl)); } // Get username _userName = GetUserNameOrDefault(activity); if (activity.Type == ActivityTypes.Message) { // Go to MainDialog var dialogInfo = new DialogInfo(activity.ChannelId, _userName, originalLocale); await Microsoft.Bot.Builder.Dialogs.Conversation.SendAsync(activity, () => new MainLUISDialog(dialogInfo)); } else { await HandleSystemMessage(activity); } response = Request.CreateResponse(HttpStatusCode.OK); } catch (Exception ex) { var telemetryClient = new TelemetryClient(); telemetryClient.TrackException(ex); response = Request.CreateResponse(HttpStatusCode.InternalServerError, ex.InnerException.ToString()); } return(response); }