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.
- This same code works for Skype.
- 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!
Others also experience this. Here's the relevant issue: https://github.com/Microsoft/BotBuilder/issues/618
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!