I am developing an application which uses a chatbot. It will partly run on LUIS dataset that I have trained and partly on AIML, in case i don't have any relevant response.
Here is a piece of code from the file. I am basically trying to fetch entity type from LUIS and if it returns nothing, then trying to run AIML.
But it keeps throwing an unhandled exception: An unhandled exception of type 'System.ArgumentNullException' occurred in mscorlib.dll Additional information: Value cannot be null.
I have taken this AIML code from another project. Here's the link: https://github.com/Gr8z/ChatBotProject
Exception occurs in line: AimlBot.loadSettings();
Here's the stack trace of the exception:
at System.IO.Path.Combine(String path1,String path2)
at AIMLbot.Bot.get_PathToConfigFiles();
at AIMLbot.Bot.loadSettings(String pathToSettings)
at WDB.Chatbot.AIMLChatbot.Initialize() in
E:\WDB-master\WDB\manishChatBot.cs:line 229
And the source code:
#region LUIS Link
private string luisLink(string usrInput)
{
string input = usrInput;
string op = wb.DownloadString("https://westus.api.cognitive.microsoft.com/luis/v2.0/apps/15c6bd2a-ecdc-41de-a054-0cce461e13a3?subscription-key=b72bdbb572fe4e90837647eb9c82b1c0&verbose=true&timezoneOffset=0&q=" + input);
var jsonParse = JsonConvert.DeserializeObject<JClass>(op);
if (jsonParse.entities.Count != 0)
{
entity = jsonParse.entities[0].type;
return entity;
}
else
{
AIMLChatBot a = new AIMLChatBot();
string aiml_response = a.getOutput(input);
return aiml_response;
}
}
#endregion
#region AIML
public class AIMLChatBot
{
const string UserId = "szabist";
private Bot AimlBot;
private User myUser;
public AIMLChatBot()
{
AimlBot = new Bot();
myUser = new User(UserId, AimlBot);
Initialize();
}
// Loads all the AIML files in the \AIML folder
public void Initialize()
{
AimlBot.loadSettings(); //Exception on this line
AimlBot.isAcceptingUserInput = false;
AimlBot.loadAIMLFromFiles();
AimlBot.isAcceptingUserInput = true;
}
// Given an input string, finds a response using AIMLbot lib
public String getOutput(String input)
{
Request r = new Request(input, myUser, AimlBot);
Result res = AimlBot.Chat(r);
return (res.Output);
}
}
#endregion