Exemple #1
0
        /// <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
                    MessagingExtension msgExt = new MessagingExtension(activity);
                    var invokeResponse        = msgExt.CreateResponse();

                    // Return the response
                    return(Request.CreateResponse(HttpStatusCode.OK, invokeResponse));
                }
                else if (activity.Name == "fileConsent/invoke")
                {
                    // Try to replace with File uploaded card.
                    return(Request.CreateResponse(HttpStatusCode.OK));
                }
                else if (activity.IsTeamsVerificationInvoke())
                {
                    await Conversation.SendAsync(activity, () => new Dialogs.RootDialog());
                }
                else if (activity.Name == "task/fetch")
                {
                    JObject parameters = activity.Value as JObject;

                    if (parameters != null)
                    {
                        string command = parameters["command"].ToString();

                        // Fetch dynamic adaptive card for task module.
                        if (command == "createPostingExtended")
                        {
                            JObject resp = new TaskModuleHelper().CreateJobPostingTaskModuleResponse();
                            return(Request.CreateResponse(HttpStatusCode.OK, resp));
                        }
                    }
                }
            }
            else
            {
                await HandleSystemMessage(activity);
            }
            var response = Request.CreateResponse(HttpStatusCode.OK);

            return(response);
        }
Exemple #2
0
        /// <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 MessagingExtension(activity).CreateResponse();

                    // Return the response
                    return(Request.CreateResponse(HttpStatusCode.OK, invokeResponse));
                }
                else if (activity.Name == "fileConsent/invoke")
                {
                    // Try to replace with File uploaded card.
                    return(Request.CreateResponse(HttpStatusCode.OK));
                }
                else if (activity.Name == "signin/verifyState")
                {
                    await HandleLoginVerification(activity);

                    return(Request.CreateResponse(HttpStatusCode.OK));
                }
            }
            else
            {
                await HandleSystemMessage(activity);
            }
            var response = Request.CreateResponse(HttpStatusCode.OK);

            return(response);
        }