I am trying to write a simple bot that uses LUIS, but seem to have an issue with after an update.
So before updating the Botbuilder to 1.1, I was having issues where Luis.Models couldn't be found. After the upgrade, and resolving a coding error, and removing Microsoft.Bot.Connector.Utilities, I can compile and run successfully, but I can't connect via the emulator.
This is the code I am using.
using System;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using System.Web.Http;
using System.Web.Http.Description;
using System.Collections.Generic;
using Microsoft.Bot.Connector;
using Microsoft.Bot.Builder.Dialogs;
//using Microsoft.Bot.Connector.Utilities;
using Microsoft.Bot.Builder.Luis;
using Microsoft.Bot.Builder.Luis.Models;
using Newtonsoft.Json;
[LuisModel("c413b2ef-382c-45bd-8ff0-f76d60e2a821", "6d0966209c6e4f6b835ce34492f3e6d9")]
[Serializable]
public class Mybot : LuisDialog<object>
{
[LuisIntent("")]
public async Task None(IDialogContext context, LuisResult result)
{
string message = "I'm sorry I didn't understand. Try asking about your bill.";
await context.PostAsync(message);
context.Wait(MessageReceived);
}
[LuisIntent("NextInvoiceDate")]
public async Task NextInvoiceDate(IDialogContext context, LuisResult result)
{
string message = "Your next payment will go out on the 17th of the month.";
await context.PostAsync(message);
context.Wait(MessageReceived);
}
[LuisIntent("NextAmount")]
public async Task NextAmount(IDialogContext context, LuisResult result)
{
string message = $"Your next amount is expected to be around £29.72.";
await context.PostAsync(message);
context.Wait(MessageReceived);
}
}
When I run the project, it starts without errors, and I get the webpage that says:
MYBot Describe your bot here and your terms of use etc. Visit Bot Framework to register your bot. When you register it, remember to set your bot's endpoint to https://your_bots_hostname/api/messages
When I run the emulator pointing to https://localhost/api/messages, it retuns "an error occurred while sending the request".
The JSON is here:
System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 127.0.0.1:443
at System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult)
at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception)
--- End of inner exception stack trace ---
at System.Net.HttpWebRequest.EndGetRequestStream(IAsyncResult asyncResult, TransportContext& context)
at System.Net.Http.HttpClientHandler.GetRequestStreamCallback(IAsyncResult ar)
--- End of inner exception stack trace ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
at Microsoft.Bot.Connector.Emulator.ConversationModel.<SendMessageAsync>d__50.MoveNext()
I have also tried just HTTP (rather than HTTPS).
Can you check you are using the correct url for your bot? Check the project url in your project properties and make sure you are using the correct port number. By default the Bot Framework project template uses http://localhost:3978/

Two things I'm seeing here:
Also, you still need the MessageController even if you use LUIS (this based on the comment you added).
The MessageController will receive the message and start the conversation by "launching" a Dialog. In this case, your LUIS dialog.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With