[Question] Unable to connect the Luis from the Bot Emulator
Steps to Reproduce the Issue
1 . I created the intents on Luis and published the app 2. Got the app Id and key and used them in the bot 3. When I run the emulator I get an error message and it does not hit the intent functions
Expected Behavior
Based on the text, the control shud flow to appropriate intent function
Actual Results
From the emulator it fails to connect,
Please help as I am not sure what am doing wrong here...
When I type the published Luis uri on the browser, I do get the json response, so I think my bot is unable to reach you that uri and could be its trying some other uri... Just a thought... Not sure
Please help
Are you using the .NET SDK or the NodeJS SDK? Can you provide code that replicates your issue?
When you connect to a bot in the emulator, you provide the appId and key for the bot itself; not for LUIS. The LUIS information is to go inside of your code. Depending on the SDK being used you either have to supply the LUIS App ID and LUIS Key as separate parameters, or you can just give the published endpoint to the bot.
@stevengum97, I am using the .Net SDK
And I am supplying the LUIS App ID and key using the attributes in the BOT
The BOT ID and Password are blank in the config since I am just using the Emulator and using the Localhost
namespace SimpleTaskAutomationBot.Dialogs
{
[LuisModel("3760f5e301e74da6a6f32698992b0246", "06550db2-6b03-4bb7-8ef3-b5533b253d0d")]
[Serializable]
public class LUISDialog: LuisDialog<object>
{
[LuisIntent("")]
[LuisIntent("None")]
public async Task None(IDialogContext context, LuisResult result)
{
await context.PostAsync("I am sorry, I dont understand u!!");
context.Wait(MessageReceived);
}
[LuisIntent("Greeting")]
public async Task Greeting(IDialogContext context, LuisResult result)
{
await context.PostAsync("Hello There!!");
context.Wait(MessageReceived);
}
}
}
And to call this in the MessageController I have following:
public class MessagesController : ApiController
{
/// <summary>
/// POST: api/Messages
/// Receive a message from a user and reply to it
/// </summary>
public async Task<HttpResponseMessage> Post([FromBody]Activity activity)
{
if (activity.Type == ActivityTypes.Message)
{
await Conversation.SendAsync(activity, () => new LUISDialog());
}
else
{
this.HandleSystemMessage(activity);
}
var response = Request.CreateResponse(HttpStatusCode.OK);
return response;
}
I tried attaching the ZIP file of the code, for some reason its taking time, please let me know for queststions. Thanks.
https://drive.google.com/file/d/0Bye0RkOToURlX25TTTFOZmw5alE/view
Please use the above Google drive link to get the complete code,
Please help
Following is the endpoint from LUIS, it all works on Browser, but how do I use this to automatically trigger the Task Intent in my BOT
https://westus.api.cognitive.microsoft.com/luis/v2.0/apps/1589fc3a-7fc8-4ed3-8b6b-5c4fc7075e0b?subscription-key=2e80de1f1a724caa8a92fd29f481cebb&verbose=true&timezoneOffset=0&q=Hello
OK, I got to know what was wrong:
- The Luis App Id and Programmatic API Key were incorrect
- Even when I correct the App ID and Key, it won't work in my Office Network. It could be something to do with security
- It only works when I am outside my Office network
But I wonder how the endpoint works both at office and outside netwrok [https://westus.api.cognitive.microsoft.com/luis/v2.0/apps/1589fc3a-7fc8-4ed3-8b6b-5c4fc7075e0b?subscription-key=2e80de1f1a724caa8a92fd29f481cebb&verbose=true&timezoneOffset=0&q=Hello]
so my last question is there a way to use the Endpoint mentioned above, and append the incoming message, then get the JSON response, check the Intent and then trigger the corresponding Intent Task in the BOT?
any code to refer, that would be a great help for my Demonstration of my Demo this Friday. Thanks.
I checked your LUISDialog.cs to see if there were any differences from the code you posted; there weren't any differences so I'll address the issues I see here.
[LuisModel("3760f5e301e74da6a6f32698992b0246", "06550db2-6b03-4bb7-8ef3-b5533b253d0d")]
[Serializable]
public class LUISDialog: LuisDialog<object>
This is wrong, the order is in reverse and they don't match the endpoint you've provided.
Going off the endpoint you provided in your comment, we've changed the code above to below.
[LuisModel("1589fc3a-7fc8-4ed3-8b6b-5c4fc7075e0b", "2e80de1f1a724caa8a92fd29f481cebb")]
[Serializable]
public class LUISDialog: LuisDialog<object>
You indicated that you changed your code, is this what you changed it to? Regarding the endpoint not working from the bot, but working when pasted into a browser, that is strange. As you said, it sounds like a security issue, but I could be wrong.
You are right, I changed the code as you mentioned above, and it all works if I am on the Internet and Once I login my office Intranet, it doesn't connect at all.
So I will not use the LUISDialog
While appending the "OriginalText" to the endpoint, I am unable to extract the "OriginalText" from the IDialogContext context. Is there a way to do that in IDialog
When are you trying to call LUIS in your RootDialog (I'm assuming you're calling it from here)? If in MessageReceivedAsync then attaching result.text to the end of your endpoint should work.
Hello all
I am all good now, following are the issues which I faced,
- I was unable to connect to LUIS using the Key and AppID in the attributes from the BOT, it was throwing issue like (unable to contact https://westus.api.cognitive.microsoft.com)
The issue was with the Proxy setting at my office intranet, outside I can very well reach that URI.
so I changed the prxy settings in my program and sent the HTTPRequest to LUIS manually and got the HTTPReposponse and then deseralized that to a LUIS object. Then used the (LUISResult.topScoringIntent.intent) to decide which logic to execute.
Proxy Setting Help: https://stackoverflow.com/questions/1938990/c-sharp-connecting-through-proxy
Thanks for all the help:)