Last active
February 1, 2017 14:09
-
-
Save winstongubantes/a99608699274c6269cea0ab302f1c177 to your computer and use it in GitHub Desktop.
MessageController
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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