Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Send Message error 500 in Microsoft BotConnectorBot

I'm working with Bot Connector to reply message. I using incomingMessage.CreateReplyMessage() it worked, but i new ConnectorClient() to reply then 500 Internal Server Error. Non-bots can't talk to non-bots

public async Task<Message> Post([FromBody]Message incomingMessage)
    {
        var connector = new ConnectorClient();

        connector.Messages.SendMessage(incomingMessage.CreateReplyMessage("ねぇ"));
        connector.Messages.SendMessage(incomingMessage.CreateReplyMessage("お返事ちょうだい?"));
        connector.Messages.SendMessage(incomingMessage.CreateReplyMessage("なんでお返事くれないの?"));
        connector.Messages.SendMessage(incomingMessage.CreateReplyMessage("どうして?"));
        connector.Messages.SendMessage(incomingMessage.CreateReplyMessage("私のこと捨てるの?"));
        connector.Messages.SendMessage(incomingMessage.CreateReplyMessage("ねぇ"));
        connector.Messages.SendMessage(incomingMessage.CreateReplyMessage("なんで?"));
        connector.Messages.SendMessage(incomingMessage.CreateReplyMessage("嘘つき"));
        connector.Messages.SendMessage(incomingMessage.CreateReplyMessage("なんでこんなひどいことするの?"));
        connector.Messages.SendMessage(incomingMessage.CreateReplyMessage("なんで?"));
        connector.Messages.SendMessage(incomingMessage.CreateReplyMessage("なんで?なんで?なんで?なんで?なんで?なんで?なんで?なんで?なんで?なんで?なんで?なんで?なんで?なんで?なんで?なんで?なんで?なんで?"));

        return incomingMessage.CreateReplyMessage("今あなたの家の前にいるの");
    }
like image 471
Nguyễn Trứ Avatar asked Oct 19 '22 09:10

Nguyễn Trứ


2 Answers

I had a same problem, but https://stackoverflow.com/a/37334528/5951301 helped me to solve it:

using (var scope = DialogModule.BeginLifetimeScope(Conversation.Container, message))   
{
    var client = scope.Resolve<IConnectorClient>();
    client.Messages.SendMessage(message);
}
like image 134
Sovan Avatar answered Oct 21 '22 01:10

Sovan


Had the same problem, and in my case it was because I was using the Bot Framework Emulator to invoke my bot logic (the Post method). The only way I got the direct connection via ConnectorClient working was to do a real end-to-end test via a configured channel (like Skype).

like image 28
Heine Frifeldt Avatar answered Oct 21 '22 01:10

Heine Frifeldt