public IActionResult ReplaceContentResponseBuilder([FromBody] GeneralWebhookFulfillmentRequest request) { var builder = new ResponseBuilder(); builder.WithContent("This is now the output speech"); return(Ok(builder.BuildResponse())); }
public async Task <IActionResult> HandleRequest([FromBody] GeneralWebhookFulfillmentRequest request) { // get the spotify access token from post-account linking var accessToken = request?.OriginalRequest?.AccessToken; // validate that we have the access token if (string.IsNullOrEmpty(accessToken)) { return(Ok(_responseBuilder.WithContent("You are not signed in. Please link your spotify account first") .BuildResponse())); } // set it in the http header for future requests _spotifyProvider.SetToken(accessToken); // get the current spotify user var result = await _spotifyProvider.GetJsonAsync <SpotifyUser>("https://api.spotify.com/v1/me"); // build the response with the user's actual name replacing the {username} variable in the output if (result.ResultType == ResultType.Ok) { return(Ok(_responseBuilder.WithContent(request.Response.Content) .WithReplacement("{username}", result.Data.DisplayName) .BuildResponse())); } return(Ok()); }
public IActionResult ReplaceContent([FromBody] GeneralWebhookFulfillmentRequest request) { return(Ok(new GeneralFulfillmentResponse { Data = new ContentFulfillmentWebhookData { Content = "This is now the output speech" } })); }