Beispiel #1
0
        public static SendMessageToAssistantResponse SendMessageToAssistant(string messsage, IBM.WatsonDeveloperCloud.Assistant.v1.Model.Context context)
        {
            List <string> lstMessages = new List <string>();

            try
            {
                IBM.WatsonDeveloperCloud.Assistant.v1.Model.MessageResponse response = IBMWatsonChatBot.SendMessageToAssistant(messsage, context);


                var aasd = response.Context;


                foreach (var item in response.Output.text)
                {
                    lstMessages.Add(item.ToString());
                }
                //Pending validation error from API
                return(new SendMessageToAssistantResponse {
                    IsSuccessful = true, ResponseMessage = AppManagement.MSG_SendMessageToAssistantResponse_Succesful, lstMessages = lstMessages, Context = response.Context
                });
            }
            catch (Exception ex)
            {
                return(new SendMessageToAssistantResponse {
                    IsSuccessful = false, ResponseMessage = ErroMessagesTranslate.TranslateException(ex), lstMessages = lstMessages
                });
            }
        }
Beispiel #2
0
        public static SendMessageToSpeechToTextResponse SendMessageToAssistant(byte[] audio)
        {
            List <string> lstMessages = new List <string>();

            try
            {
                var response = IBMWatsonSpeechToText.SendMessageToAssistant(audio);

                foreach (var item in response.Results)
                {
                    lstMessages.Add(item.ToString());
                }

                return(new SendMessageToSpeechToTextResponse {
                    IsSuccessful = true, ResponseMessage = AppManagement.MSG_SendMessageToAssistantResponse_Succesful, lstMessages = lstMessages
                });
            }
            catch (Exception ex)
            {
                return(new SendMessageToSpeechToTextResponse {
                    IsSuccessful = false, ResponseMessage = ErroMessagesTranslate.TranslateException(ex), lstMessages = lstMessages
                });
            }
        }