Skip to content

Instantly share code, notes, and snippets.

@winstongubantes
Last active February 1, 2017 14:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save winstongubantes/a99608699274c6269cea0ab302f1c177 to your computer and use it in GitHub Desktop.
Save winstongubantes/a99608699274c6269cea0ab302f1c177 to your computer and use it in GitHub Desktop.
MessageController
[BotAuthentication]
public class MessagesController : ApiController
{
public async Task<HttpResponseMessage> Post([FromBody]Activity activity)
{
ConnectorClient connector = new ConnectorClient(new Uri(activity.ServiceUrl));
if (activity.Type == ActivityTypes.Message)
{
// 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;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment