Created
July 11, 2016 09:42
-
-
Save beachside-project/efe5f36fcb57020fee16200be49fe099 to your computer and use it in GitHub Desktop.
FormFlowV3.Controllers
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
namespace FormFlowV3.Controllers | |
{ | |
[BotAuthentication] | |
public class MessagesController : ApiController | |
{ | |
/// <summary> | |
/// POST: api/Messages | |
/// receive a message from a user and send replies | |
/// </summary> | |
/// <param name="activity"></param> | |
[ResponseType(typeof(void))] | |
public virtual async Task<HttpResponseMessage> Post([FromBody] Activity activity) | |
{ | |
if (activity != null) | |
{ | |
// one of these will have an interface and process it | |
switch (activity.GetActivityType()) | |
{ | |
case ActivityTypes.Message: | |
await Conversation.SendAsync(activity, MakeRootDialog); | |
break; | |
case ActivityTypes.ConversationUpdate: | |
case ActivityTypes.ContactRelationUpdate: | |
case ActivityTypes.Typing: | |
case ActivityTypes.DeleteUserData: | |
default: | |
Trace.TraceError($"Unknown activity type ignored: {activity.GetActivityType()}"); | |
break; | |
} | |
} | |
return new HttpResponseMessage(System.Net.HttpStatusCode.Accepted); | |
} | |
internal static IDialog<SandwichOrder> MakeRootDialog() => Chain.From(() => FormDialog.FromForm(SandwichOrder.BuildForm)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment