ReplyToActivityAsync throwing exception with Slack connector on Bot Framework v3.0

て烟熏妆下的殇ゞ 提交于 2020-01-17 05:39:06

问题


I have created a bot v3.0 project and connected it to both Slack and Skype. The Skype connector works great, but I am having trouble with the Slack connector.

Here is my Post handler from the default project.

public async Task<HttpResponseMessage> Post([FromBody]Activity activity)
{
    if (activity.Type == ActivityTypes.Message)
    {
        ConnectorClient connector = new ConnectorClient(new Uri(activity.ServiceUrl));

        // calculate something for us to return
        int length = (activity.Text ?? string.Empty).Length;

        // return our reply to the user
        Activity reply = activity.CreateReply($"You sent {activity.Text} which was {length} characters");
        await connector.Conversations.ReplyToActivityAsync(reply);
    }
    else
    {
        HandleSystemMessage(activity);
    }

    var response = Request.CreateResponse(HttpStatusCode.OK);
    return response;
}

When I send a message from Slack, it is delivered to the post handler and the activity object looks fine. I can see the slack data including the message, recipient, etc. Then the call to:

await connector.Conversations.ReplyToActivityAsync(reply);

throws an exception with the message "Unable to deserialize the response" and an inner exception with the error "Unexpected character encountered while parsing value: <. Path '', line 0, position 0."

A few additional points.

  1. This same code works for Skype.
  2. I used this slack bot from a Bot Framework v1 project successfully.

Is there something that I need to do differently for the Slack channel?

Thanks!

UPDATE: This issue occurred in Microsoft.Bot.Builder v3.0.0 and it is fixed in Microsoft.Bot.Builder v3.0.1. I am now able to communicate with my bot properly from both Slack and Skype.

https://github.com/Microsoft/BotBuilder/releases/tag/botbuilder%403.0.1

Thanks stevenic!


回答1:


Others also experience this. Here's the relevant issue: https://github.com/Microsoft/BotBuilder/issues/618




回答2:


This issue occured in Microsoft.Bot.Builder v3.0.0 and it is fixed in Microsoft.Bot.Builder v3.0.1. I am now able to communicate with my bot properly from both Slack and Skype.

https://github.com/Microsoft/BotBuilder/releases/tag/botbuilder%403.0.1

Thanks stevenic!



来源:https://stackoverflow.com/questions/38278845/replytoactivityasync-throwing-exception-with-slack-connector-on-bot-framework-v3

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!