Skip to content

Instantly share code, notes, and snippets.

@beachside-project
Created July 11, 2016 09:42
Show Gist options
  • Save beachside-project/efe5f36fcb57020fee16200be49fe099 to your computer and use it in GitHub Desktop.
Save beachside-project/efe5f36fcb57020fee16200be49fe099 to your computer and use it in GitHub Desktop.
FormFlowV3.Controllers
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