private static WebhookResponse InitializeResponse(bool expectUserInput, string userId)
        {
            WebhookResponse webResp = new WebhookResponse();

            var message = new Intent.Types.Message();

            webResp.FulfillmentMessages.Add(message);
            message.Platform = Intent.Types.Message.Types.Platform.ActionsOnGoogle;

            Value payloadVal = new Value();

            payloadVal.StructValue = new Struct();

            Value expectedUserResp = new Value();

            expectedUserResp.BoolValue = expectUserInput;
            payloadVal.StructValue.Fields.Add("expectUserResponse", expectedUserResp);

            Value userStorageValue = new Value();

            UserStorage userStorage = new UserStorage();

            userStorage.UserId           = userId;
            userStorageValue.StringValue = JsonConvert.SerializeObject(userStorage);

            payloadVal.StructValue.Fields.Add("userStorage", userStorageValue);

            Struct payloadStruct = new Struct();

            payloadStruct.Fields.Add("google", payloadVal);

            webResp.Payload = payloadStruct;

            return(webResp);
        }
Beispiel #2
0
        public async Task <WebhookResponse> GetExternalNews(GoogleCloudDialogflowV2WebhookRequest intent)
        {
            var    newsSourceRequested = intent.QueryResult.Parameters[newsParameter].ToString();
            string urlToUse            = "";

            urlToUse = BuildUrlToUse(newsSourceRequested, out string readableParameter);
            NewsExtract extracts = await ObtainNewAPIDta(urlToUse);

            if (extracts == null)
            {
                return(new WebhookResponse
                {
                    FulfillmentText = Utilities.ErrorReturnMsg()
                });
            }

            string returnString = ExtractHeadlines(extracts);

            var returnValue = new WebhookResponse
            {
                FulfillmentText = returnString
            };

            // returnValue = ExtractHeadlines(extracts, returnValue);

            return(returnValue);
        }
        public async Task <IActionResult> Post([FromBody] GoogleCloudDialogflowV2WebhookRequest intent)
        {
            WebhookResponse returnValue = await obtainStockQuote.GetMarketData(intent);

            if (returnValue == null)
            {
                returnValue = new WebhookResponse
                {
                    FulfillmentText = Utilities.ErrorReturnMsg() + Utilities.EndOfCurrentRequest()
                };
            }
            else if (returnValue.FulfillmentMessages.Count == 0 &&
                     !returnValue.FulfillmentText.Contains(Utilities.EndOfCurrentRequest()))
            {
                returnValue.FulfillmentText = returnValue.FulfillmentText + "\n" + Utilities.EndOfCurrentRequest();
            }
            var responseString = returnValue.ToString();

            _log.LogTrace("Completed processing request");
            return(new ContentResult
            {
                Content = responseString,
                ContentType = "application/json",
                StatusCode = 200
            });
        }
Beispiel #4
0
        private static IActionResult ResponseUploadPhoto()
        {
            var reponseText        = "Please take a photo first";
            var dialogflowResponse = new WebhookResponse
            {
                FulfillmentText     = reponseText,
                FulfillmentMessages =
                {
                    new Intent.Types.Message
                    {
                        SimpleResponses = new Intent.Types.Message.Types.SimpleResponses
                        {
                            SimpleResponses_ =
                            {
                                new Intent.Types.Message.Types.SimpleResponse
                                {
                                    DisplayText  = reponseText,
                                    TextToSpeech = reponseText,
                                }
                            }
                        }
                    }
                }
            };
            var jsonResponse = dialogflowResponse.ToString();

            return(new ContentResult {
                Content = jsonResponse, ContentType = "application/json"
            });
        }
Beispiel #5
0
        private static IActionResult ResponseShareLocation()
        {
            var reponseText        = "Please share your location with us so we know where those cigarette butts are";
            var dialogflowResponse = new WebhookResponse
            {
                FulfillmentText     = reponseText,
                FulfillmentMessages =
                {
                    new Intent.Types.Message
                    {
                        SimpleResponses = new Intent.Types.Message.Types.SimpleResponses
                        {
                            SimpleResponses_ =
                            {
                                new Intent.Types.Message.Types.SimpleResponse
                                {
                                    DisplayText  = reponseText,
                                    TextToSpeech = reponseText,
                                }
                            }
                        }
                    }
                }
            };
            var jsonResponse = dialogflowResponse.ToString();

            return(new ContentResult {
                Content = jsonResponse, ContentType = "application/json"
            });
        }
        public static async Task <IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req,
            ILogger log)
        {
            log.LogInformation("Starting President service.");

            string         requestBody = await new StreamReader(req.Body).ReadToEndAsync();
            WebhookRequest request;

            request = jsonParser.Parse <WebhookRequest>(requestBody);
            var firstParamName = request.QueryResult.Parameters.Fields["presidentName"].ToString().Replace("\"", "");

            var response = new WebhookResponse
            {
                FulfillmentText = $"Hello {firstParamName}"
            };

            log.LogInformation("Ending Presidnet service");
            return(new ContentResult
            {
                Content = response.ToString(),
                ContentType = "application/json",
                StatusCode = 200
            });
        }
Beispiel #7
0
        public ContentResult DialogAction()
        {
            // Parse the body of the request using the Protobuf JSON parser,
            // *not* Json.NET.

            WebhookRequest request;

            using (var reader = new StreamReader(Request.Body))
            {
                request = jsonParser.Parse <WebhookRequest>(reader);
            }
            var inputString = request.QueryResult.QueryText;
            List <DocumentResult> documents = new List <DocumentResult>();

            if (inputString.Trim() != "")
            {
                documents = Helpers.Search(inputString);
            }
            var    firstdocument = documents.FirstOrDefault();
            string responseText  = firstdocument != null?Helpers.ResponseBuilder(firstdocument) : "Sorry, I could not find a relevant document.";

            // Populate the response
            WebhookResponse response = new WebhookResponse
            {
                FulfillmentText = responseText
            };
            // Ask Protobuf to format the JSON to return.
            // Again, we don’t want to use Json.NET — it doesn’t know how to handle Struct
            // values etc.
            string responseJson = response.ToString();

            return(Content(responseJson, "application/json"));
        }
 /// <summary>
 /// HttpResponceMessage
 /// </summary>
 /// <param name="webhookResponse"></param>
 /// <param name="response"></param>
 /// <returns></returns>
 private static HttpResponseMessage HttpResponceMessage(WebhookResponse webhookResponse, HttpResponseMessage response)
 {
     response.Content    = new StringContent(webhookResponse.ToString());
     response.StatusCode = HttpStatusCode.OK;
     response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
     return(response);
 }
Beispiel #9
0
        //[Route("/api/download/{id}")]
        public async Task <IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Anonymous, "post")] WebhookResponse webhookResponse,
            ILogger log)
        {
            log.LogInformation("C# HTTP trigger function processed a request.");



            if (_downloadService == null)
            {
                log.LogError("download service null");
                return(new BadRequestObjectResult("error"));
            }
            if (webhookResponse.transcript_id is null || webhookResponse.status != "completed")
            {
                return(new BadRequestObjectResult("errors galore!!"));
            }

            DownloadResponse downloadResponse;

            try
            {
                downloadResponse = await _downloadService.FetchDownload(webhookResponse.transcript_id);
            }
            catch (Exception e)
            {
                log.LogError($"Error from download service:{e}");
                return(new BadRequestObjectResult(e));
            }

            return(new JsonResult(downloadResponse));
        }
Beispiel #10
0
        public static async Task <IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req,
            ILogger log)
        {
            string          requestBody = await new StreamReader(req.Body).ReadToEndAsync();
            string          intentName  = "";
            WebhookResponse returnValue = new WebhookResponse
            {
                FulfillmentText = Utilities.ErrorReturnMsg()
            };
            var retrunErrorString = JsonConvert.SerializeObject(returnValue,
                                                                Formatting.Indented,
                                                                new JsonSerializerSettings
            {
                ContractResolver = new CamelCasePropertyNamesContractResolver()
            });
            WebhookRequest webhookRequest;

            try
            {
                var parserResult = JObject.Parse(requestBody);
                webhookRequest = jsonParser.Parse <WebhookRequest>(requestBody);

                GetAttribute(parserResult, IntentPath, out intentName);
                returnValue = await ProcessIntent(intentName, parserResult, webhookRequest, log);
            }
            catch (Exception ex)
            {
                log.LogError($"Exception while running ParentFunction\nDetails:{ex.Message}");
                return(new ContentResult
                {
                    Content = retrunErrorString,
                    ContentType = "application/json",
                    StatusCode = 200
                });
            }
            if (returnValue.FulfillmentMessages.Count == 0 &&
                !returnValue.FulfillmentText.Contains(@"'bye bye' to quit"))
            {
                returnValue.FulfillmentText = returnValue.FulfillmentText + "\n" + Utilities.EndOfCurrentRequest();
            }
            returnValue.FulfillmentText = Utilities.ConvertAllToASCII(returnValue.FulfillmentText);
            returnValue.Source          = webhookRequest.QueryResult.WebhookSource;
            log.LogInformation("C# HTTP trigger function processed a request.");
            //var returnString = JsonConvert.SerializeObject(returnValue,
            //	Formatting.Indented,
            //	new JsonSerializerSettings
            //	{
            //		ContractResolver = new CamelCasePropertyNamesContractResolver()
            //	});
            var returnString = returnValue.ToString();

            log.LogInformation(returnString);
            return(new ContentResult
            {
                Content = returnString,
                ContentType = "application/json",
                StatusCode = 200
            });
        }
        public ActionResult GetWebhookResponse2([FromBody] System.Text.Json.JsonElement dados)
        {
            if (!Autorizado(Request.Headers))
            {
                return(StatusCode(401));
            }

            WebhookRequest request =
                _jsonParser.Parse <WebhookRequest>(dados.GetRawText());

            WebhookResponse response = new WebhookResponse();


            if (request != null)
            {
                string action = request.QueryResult.Action;

                if (action == "ActionTesteWH")
                {
                    response.FulfillmentText = "testando o webhook 2";
                }
            }

            return(Ok(response));
        }
Beispiel #12
0
        public IActionResult Post([FromBody] WebhookRequest webhookRequest, [FromHeader(Name = "DigitalSignature")] string digitalSignature)
        {
            Console.WriteLine($"Received webhook: {webhookRequest.Type}, payload: {webhookRequest.Payload}");

            // It is important to get body from request object to calculate hash
            // Conversion back from WebhookRequest object may result in different string that will fail validation
            Request.Body.Position = 0;
            using var reader      = new StreamReader(Request.Body);
            var body = reader.ReadToEnd();

            var verified = DigitalSignature.Verify(digitalSignature, body, _authProfile.ClearBankPublicKey);

            if (!verified)
            {
                return(BadRequest("Incorrect signature"));
            }

            // In production system you should put that webhook into the internal queue for processing
            // Don't do heavy processing here and respond to webhook as quick as possible

            var result = new WebhookResponse {
                Nonce = webhookRequest.Nonce
            };

            var response  = JsonSerializer.Serialize(result);
            var signature = DigitalSignature.Generate(response, _authProfile.ClientPrivateKey);

            Request.HttpContext.Response.Headers.Add("DigitalSignature", signature);

            return(Content(response));
        }
Beispiel #13
0
        public WebhookResponse GetGoogleResponse()
        {
            var webhookResponse = new WebhookResponse();

            webhookResponse.FulfillmentText = string.Join('.', messages);
            return(webhookResponse);
        }
        public ContentResult DialogAction()
        {
            // Parse the body of the request using the Protobuf JSON parser,
            // *not* Json.NET.
            WebhookRequest request;

            using (var reader = new StreamReader(Request.Body))
            {
                request = jsonParser.Parse <WebhookRequest>(reader);
            }

            double noites  = 0;
            double pessoas = 0;
            double euros   = 0;

            var requestParameters = request.QueryResult.Parameters;

            noites  = requestParameters.Fields["noites"].NumberValue;
            pessoas = requestParameters.Fields["pessoas"].NumberValue;
            euros   = noites * pessoas;


            // Note: you should authenticate the request here.

            // Populate the response
            WebhookResponse response = new WebhookResponse
            {
                FulfillmentText = $"Obrigado por nos escolher! Vai ficar com {pessoas} durante {noites}, o que amonta para {euros} euros"
            };

            // Ask Protobuf to format the JSON to return.
            string responseJson = response.ToString();

            return(Content(responseJson, "application/json"));
        }
        public IHttpActionResult GetWebhookResponse()
        {
            WebhookRequest request;

            using (var reader = new StreamReader(HttpContext.Current.Request.InputStream))
            {
                request = jsonParser.Parse <WebhookRequest>(reader);
            }

            var actionType = request.QueryResult.Action;
            var parameters = request.QueryResult.Parameters;
            var response   = new WebhookResponse();

            switch (actionType)
            {
            case "input.welcome":
                response.FulfillmentText = $"Hi {CurrentUser.UserName}, I am trip palnner agent how can help you.";
                return(Ok(response));

            case "input.flight":
                var flightDate = parameters.Fields["date"].ToString();
                var flyingFrom = parameters.Fields["flyingFrom"].ToString();
                var flyingTo   = parameters.Fields["flyingTo"].ToString();
                response.FulfillmentText = $"Congrax your flight from {flyingFrom} to {flyingTo} booked for {flightDate}";
                return(Ok(response));

            case "input.hotal":
                response.FulfillmentText = "your hotal has been booked";
                return(Ok(response));

            default:
                response.FulfillmentText = "Sorry ask somting else";
                return(Ok(response));
            }
        }
Beispiel #16
0
        public static WebhookResponse AddToSession(this WebhookResponse webhookResponse, string sessionId, string key, Value value, int?maxLifespan = null)
        {
            Context outputContext = null;

            var outPutContextName = $"{sessionId}/contexts/{DataKey}";

            var lifespan = maxLifespan ?? MaxLifespan;

            if (webhookResponse?.OutputContexts.GetContext(outPutContextName) == null)
            {
                outputContext = new Context
                {
                    Name = outPutContextName
                };

                webhookResponse.OutputContexts.Add(outputContext);
            }
            else
            {
                outputContext = webhookResponse.OutputContexts.First(x => x.Name.Equals(outPutContextName, StringComparison.OrdinalIgnoreCase));
            }

            outputContext.LifespanCount = lifespan;

            if (outputContext.Parameters == null)
            {
                outputContext.Parameters = new Struct();
            }

            outputContext.Parameters.Fields[key] = value;

            return(webhookResponse);
        }
Beispiel #17
0
        public static T Convert <T>(CommonModel model)
        {
            object result = null;

            if (model.Source.Equals("google"))
            {
                result = new WebhookResponse()
                {
                    FulfillmentText = model.ResponseString
                };
            }
            else if (model.Source.Equals("amazon"))
            {
                result = ResponseBuilder.Tell(model.ResponseString);

                //new ResponseBody()
                //{
                //    Reprompt = new Reprompt(model.ResponseString),
                //    ShouldEndSession = false,
                //},
                //Version = model.Version
            }

            return((T)result);
        }
Beispiel #18
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.Run(async(context) =>
            {
                //  WebhookRequest request;
                //  string json;

                /*   using (StreamReader reader = new StreamReader(context.Request.Body))
                 * {
                 *
                 *     json = reader.ReadToEnd();
                 *     request = jsonParser.Parse<WebhookRequest>(json);
                 *
                 * } */

                var response = new WebhookResponse
                {
                    FulfillmentText = "Hello from Csharp"   //request.QueryResult.Intent.DisplayName
                };

                await context.Response.WriteAsync((response.ToString()));
            });
        }
Beispiel #19
0
        public string GetMyDiscount()
        {
            Discount discount = null;

            var discounts = _context.getDiscounts();
            // discount = discounts.FirstOrDefault();

            // Get those which are still valid
            //discounts = discounts.Where(d => d.ValidTill > DateTime.Now.AddDays(-1)).ToList();

            double latitude  = 50.0730903;
            double longitude = 14.4691482;

            // Select location radius
            var coord   = new GeoCoordinate(latitude, longitude);
            var nearest = discounts.OrderBy(x => x.GetDistance(coord)).Where(x => x.GetDistance(coord) < 8000);

            // Calculate prioritzation score

            // Select by prioritization score
            discount = nearest.OrderBy(d => d.Propagations).FirstOrDefault();

            // Increment propagation
            _context.IncrementPropagation(discount);


            // Send resposne voie asssitant response
            WebhookResponse webHookResponse = null;

            webHookResponse = DialogFlowManager.GetDialogFlowResponse(null, $"Your discount for today is: " + discount.DiscountName + " for " + (int)discount.Price + " czech crowns, in " + discount.BusinessName);

            return(webHookResponse.ToString());
        }
        public async Task <dynamic> GetAll([FromBody] WebhookRequest dialogflowRequest)
        {
            var intentName     = dialogflowRequest.QueryResult.Intent.DisplayName;
            var actualQuestion = dialogflowRequest.QueryResult.QueryText;
            var datas          = await _repository.GetAll();

            var testAnswer = "";

            datas.ToList().ForEach(c => testAnswer += c.SomeParameter.ToString() + ", ");
            var parameters         = dialogflowRequest.QueryResult.Parameters;
            var dialogflowResponse = new WebhookResponse
            {
                FulfillmentText     = testAnswer,
                FulfillmentMessages =
                { new Intent.Types.Message
                  {
                      SimpleResponses = new Intent.Types.Message.Types.SimpleResponses
                      {
                          SimpleResponses_ =
                          { new Intent.Types.Message.Types.SimpleResponse
                                {
                                    DisplayText  = testAnswer,
                                    TextToSpeech = testAnswer,
                                } }
                      }
                  } }
            };
            var jsonResponse = dialogflowResponse.ToString();

            return(new ContentResult {
                Content = jsonResponse, ContentType = "application/json"
            });;
        }
Beispiel #21
0
 public virtual IActionResult ApiParcelByTrackingIdWebhooksPost([FromRoute][Required][RegularExpression("^[A-Z0-9]{9}$")] string trackingId, [FromQuery][Required()] string url)
 {
     try
     {
         //search for parcel with trackingId
         if (!_webrep.GetParcelByTrackingID(trackingId))
         {
             return(StatusCode(404));
         }
         //create new Webhook
         WebhookResponse newHook = new WebhookResponse()
         {
             TrackingId = trackingId,
             Url        = url,
             CreatedAt  = DateTime.Now
         };
         var  DALWebhook = _mapper.Map <DAL.Webhook>(newHook);
         long newId      = _webrep.Create(DALWebhook);
         newHook.Id = newId;
         return(StatusCode(200, newHook));
     }
     catch (DAL.DALException exc)
     {
         return(handleReturn(System.Reflection.MethodBase.GetCurrentMethod().Name, exc));
     }
     catch (Exception exc)
     {
         return(handleReturn(System.Reflection.MethodBase.GetCurrentMethod().Name, exc));
     }
 }
Beispiel #22
0
 public ResponseBuilder()
 {
     _followUpBuilder = new FollowUpBuilder();
     _response        = new WebhookResponse <ContentFulfillmentWebhookData>
     {
         Data = EmptyResponse()
     };
 }
        public static async Task <IActionResult> AddressManagement(
            [HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] HttpRequest req,
            [Table("AddressManagementv2")] CloudTable inTable,
            ILogger log)
        {
            var parser          = new JsonParser(JsonParser.Settings.Default.WithIgnoreUnknownFields(true)); // パーサーを作る
            var webhookRequest  = parser.Parse <WebhookRequest>(await req.ReadAsStringAsync());              // パースする
            var webhookResponse = new WebhookResponse();

            log.LogInformation(webhookRequest.QueryResult.Intent.DisplayName);

            var items = webhookRequest.QueryResult.Parameters.Fields["items"].StringValue;

            log.LogInformation(items);

            //データの読み取り
            TableQuery <Person> rangeQuery = new TableQuery <Person>();

            log.LogInformation(TableQuery.GenerateFilterCondition("items", QueryComparisons.Equal, items));

            TableContinuationToken     token   = null;
            TableQuerySegment <Person> segment = await inTable.ExecuteQuerySegmentedAsync(rangeQuery, token);

            //応答部分
            switch (webhookRequest.QueryResult.Intent.DisplayName)
            {
            default:
            {
                if (segment.Any())
                {
                    var fulfillmentText = "お調べします。\n";
                    {
                        foreach (Person entity in segment)
                        {
                            log.LogInformation(entity.PartitionKey);
                            log.LogInformation(entity.items);
                            log.LogInformation(items);

                            if (entity.items == items)        //フィルター
                            {
                                fulfillmentText += $"{entity.items}は、{entity.location}にあります。";
                                log.LogInformation(entity.PartitionKey);
                                log.LogInformation(entity.items);
                            }
                        }
                    }
                    webhookResponse.FulfillmentText = fulfillmentText;
                }
                else
                {
                    webhookResponse.FulfillmentText = "登録されていません";
                }
            }
            break;
            }

            return(new ProtcolBufJsonResult(webhookResponse, JsonFormatter.Default));
        }
Beispiel #24
0
        public JsonResult Post([FromBody] WebhookRequest value)
        {
            var response = new WebhookResponse
            {
                FulfillmentText = "Estou consultando uma informação no banco de dados. A hora do servidor é -> " + DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss.fff"),
                Source          = "sample fullfillment api",
            };

            return(new JsonResult(response));
        }
Beispiel #25
0
        public void AddHelperIntent()
        {
            WebhookResponse response = new WebhookResponse();

            response.AddHelperIntent(new SignInIntent());

            Assert.NotNull(response.payload["google"]);

            string json = JsonConvert.SerializeObject(response);
        }
 private WebhookResponse CheckAndAddEndOfMessage(WebhookResponse response)
 {
     if (response.FulfillmentMessages.Count == 0 &&
         !response.FulfillmentText.Contains(Utility.EndOfCurrentRequest()))
     {
         response.FulfillmentText = response.FulfillmentText + "\n" +
                                    Utility.EndOfCurrentRequest();
     }
     return(response);
 }
Beispiel #27
0
        public static void PlaceStandardHeaders(WebhookResponse returnValue)
        {
            var platform = new Message
            {
                Platform = Message.Types.Platform.ActionsOnGoogle
            };

            // returnValue.FulfillmentText = "";
            returnValue.FulfillmentMessages.Add(platform);
        }
Beispiel #28
0
        public async Task <WebhookResponse> SelectRandomGoodFirms()
        {
            _log.LogTrace("Started to select better investments");
            try
            {
                var betterScores = _ratingsConnectionHandler.Get(r => r.Rating >= 7 && r.FYear == DateTime.Now.Year).ToList();
                if (betterScores == null || betterScores.Count == 0)
                {
                    betterScores = _ratingsConnectionHandler.Get(r => r.Rating >= 7 && r.FYear == DateTime.Now.Year - 1).ToList();
                }
                if (betterScores.Any())
                {
                    betterScores.Shuffle();
                }
                betterScores = betterScores.Take(4).ToList();
                var messageString = new StringBuilder();
                messageString.Append("Here are a few recommendations for you.\n");
                foreach (var piotroskiScore in betterScores)
                {
                    var companyName = _dbconCompany.Get(r => r.SimId.Equals(piotroskiScore.SimId)).FirstOrDefault().Name;
                    if (!string.IsNullOrWhiteSpace(companyName))
                    {
                        string targetPrice;
                        if (betterScores.First() != piotroskiScore)
                        {
                            var a = await Task.Delay(100).ContinueWith(t => GetTargetPriceAsync(piotroskiScore.Ticker));

                            targetPrice = a.Result;
                        }
                        else
                        {
                            targetPrice = await GetTargetPriceAsync(piotroskiScore.Ticker);
                        }
                        messageString.Append($"{companyName} with ticker {piotroskiScore.Ticker} scores {piotroskiScore.Rating}.\n");
                        if (!targetPrice.IsNullOrWhiteSpace())
                        {
                            messageString.Append(targetPrice);
                        }
                    }
                }
                messageString.Append($"\n Note: Recommendations are based on SEC filings. Market conditions will affect the company's performance.\n");
                messageString.Append($"\n Further research needs to be done before you place your order.\n");
                var returnResponse = new WebhookResponse
                {
                    FulfillmentText = messageString.ToString()
                };
                return(returnResponse);
            }
            catch (Exception ex)
            {
                _log.LogCritical($"Error while getting data from database;\n{ex.Message}");
                return(new WebhookResponse());
            }
        }
Beispiel #29
0
        public WebhookResponse CreateResponse(Response data)
        {
            string          fullfilment = data.Message;
            var             output      = FulfillmentMessages(data);
            WebhookResponse response    = new WebhookResponse()
            {
                fulfillmentText = fullfilment, fulfillmentMessages = output, source = null, followupEventInput = null, outputContexts = null, payload = null
            };

            return(response);
        }
        public static string populateResponse(string text)
        {
            var teamsMessage = PayloadHelper.CreateSkypePayload(text);

            // Populate the response
            WebhookResponse response = new WebhookResponse();

            response.FulfillmentMessages.Add(teamsMessage);
            string responseJson = response.ToString();

            return(responseJson);
        }