private CreateResponseBody CreateAPIPostCall(RequestBody Body)
        {
            ErrorDTO pageError = new ErrorDTO();
            Tuple <HttpWebRequest, ErrorDTO> ReqVar;
            CreateResponseBody responseBody = null;

            try
            {
                ReqVar       = BotAPIService.ManageConfigurationForAPIPostCall(Body);
                responseBody = GetResponseFromAPI(ReqVar.Item1);
            }
            catch (Exception exception)
            {
                //handle error
            }
            return(responseBody);
        }
Exemple #2
0
        private static async Task SendWelcomeMessageAsync(ITurnContext turnContext, CancellationToken cancellationToken)
        {
            foreach (var member in turnContext.Activity.MembersAdded)
            {
                if (member.Id != turnContext.Activity.Recipient.Id)
                {
                    var userName = turnContext.Activity.From.Name;
                    await turnContext.SendActivityAsync(
                        //$"Welcome to Bot {member.Name}. {WelcomeText}",
                        //                         $"Welcome to Bot {member.Name}.",
                        $"Welcome to Bot {userName}.",
                        cancellationToken : cancellationToken);


                    //Create request body to sent it to connect api
                    Body = BotAPIService.CreateBody();

                    //////////////////////////////////
                    /////Add card on startup message

                    ////var attachments = new List<Attachment>();
                    ////var reply = MessageFactory.Attachment(attachments);
                    //Attachment cardAttachment = null;
                    ////if (text.Contains("testdc"))
                    ////{
                    //AdaptiveCard card = AdaptiveCardBotHelper.CreateHelloAdaptiveCard();
                    //cardAttachment = new Attachment()
                    //{
                    //    ContentType = AdaptiveCard.ContentType,
                    //    Content = card
                    //};
                    ////reply.Attachments.Add(cardAttachment);
                    ////}
                    //if (cardAttachment != null)
                    //{
                    //    await turnContext.SendActivityAsync(MessageFactory.Attachment(cardAttachment), cancellationToken);
                    //}
                }
            }
        }
        public CreateResponseBody GetResponseFromAPI(WebRequest request)
        {
            string   response  = string.Empty;
            ErrorDTO pageError = new ErrorDTO();
            var      Error     = "test123";
            Tuple <ErrorDTO, string> responseFromAPI = new Tuple <ErrorDTO, string>(pageError, response);

            responseFromAPI = BotAPIService.GetResponse(request);

            CreateResponseBody responseBody = null;

            if (!string.IsNullOrEmpty(responseFromAPI.Item2))
            {
                BotAPIHelper botAPIHelper       = new BotAPIHelper();
                var          responseAfterParse = botAPIHelper.ParseCreateResponse(responseFromAPI.Item2);
                if (responseAfterParse.Body != null)
                {
                    responseBody   = responseAfterParse.Body;
                    ApiUnavailable = false;
                }
            }
            return(responseBody);
        }