Created
May 19, 2018 14:48
-
-
Save icebeam7/a72dee916172e5ede15da2919099c9b1 to your computer and use it in GitHub Desktop.
FaceBot: MessagesController.cs
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
using System.Net; | |
using System.Net.Http; | |
using System.Threading.Tasks; | |
using System.Web.Http; | |
using Microsoft.Bot.Builder.Dialogs; | |
using Microsoft.Bot.Connector; | |
namespace FaceBot | |
{ | |
[BotAuthentication] | |
public class MessagesController : ApiController | |
{ | |
public async Task<HttpResponseMessage> Post([FromBody]Activity activity) | |
{ | |
if (activity.GetActivityType() == ActivityTypes.Message) | |
{ | |
await Conversation.SendAsync(activity, () => new Dialogs.DialogoFace()); | |
} | |
else | |
{ | |
HandleSystemMessage(activity); | |
} | |
var response = Request.CreateResponse(HttpStatusCode.OK); | |
return response; | |
} | |
private Activity HandleSystemMessage(Activity message) | |
{ | |
string messageType = message.GetActivityType(); | |
if (messageType == ActivityTypes.DeleteUserData) | |
{ | |
} | |
else if (messageType == ActivityTypes.ConversationUpdate) | |
{ | |
} | |
else if (messageType == ActivityTypes.ContactRelationUpdate) | |
{ | |
} | |
else if (messageType == ActivityTypes.Typing) | |
{ | |
} | |
else if (messageType == ActivityTypes.Ping) | |
{ | |
} | |
return null; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment