/// <summary> /// POST: api/Messages /// Receive a message from a user and reply to it /// </summary> public async Task <HttpResponseMessage> Post([FromBody] Activity activity) { if (activity.Type == ActivityTypes.Message) { //Handle basic message types, e.g. user initiated await Conversation.SendAsync(activity, () => new Dialogs.RootDialog()); } else if (activity.Type == ActivityTypes.Invoke) { //Compose extensions come in as Invokes. Leverage the Teams SDK helper functions if (activity.IsComposeExtensionQuery()) { // Determine the response object to reply with var invokeResponse = new ComposeExtension(activity).CreateComposeExtensionResponse(); // Return the response return(Request.CreateResponse <ComposeExtensionResponse>(HttpStatusCode.OK, invokeResponse)); } else { // Handle other types of Invoke activities here, e.g. CardActions } } else { await HandleSystemMessage(activity); } var response = Request.CreateResponse(HttpStatusCode.OK); return(response); }
/// <summary> /// POST: api/Messages /// Receive a message from a user and reply to it /// </summary> public async Task <HttpResponseMessage> Post([FromBody] Activity activity) { MicrosoftAppCredentials.TrustServiceUrl(activity.ServiceUrl); if (activity.Type == ActivityTypes.Message) // If we just received a message, then let Dialogs process it. { await Conversation.SendAsync(activity, () => new Dialogs.RootDialog()); } else if (activity.Type == ActivityTypes.Invoke) // Received an invoke { if (activity.IsComposeExtensionQuery()) { // Determine the response object to reply with var invokeResponse = new ComposeExtension(activity).CreateComposeExtensionResponse(); // Return the response return(Request.CreateResponse <ComposeExtensionResponse>(HttpStatusCode.OK, invokeResponse)); } else { // Handle other types of Invoke activities here. } } else { HandleSystemMessage(activity); } var response = Request.CreateResponse(HttpStatusCode.OK); return(response); }