Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to make a request to a REST service from within a Dialogflow intent #22

Closed
fitsie007 opened this issue May 30, 2019 · 1 comment
Closed
Assignees

Comments

@fitsie007
Copy link

I am trying to make a request to a REST API from within my intent, but it always throws an error:

MalformedResponse: Failed to parse Dialogflow response into AppResponse because of empty speech response

I am using spring-framework RestTemplate to send the request as follows.

@ForIntent("process-greeting")
  public ActionResponse greetingProcessor(ActionRequest request) {
...
String givenName = (String) request.getParameter("given-name");
Greeting greeting = restTemplate.getForObject("https://fitzroi-rest-api-0525.appspot.com/rest/{name}", Greeting.class, givenName);
responseBuilder.add(greeting.getContent()); //this is a simple greeting like "Hello, Fitz"
}

Is this the right way to make a call to a REST service from within an Intent?
Also, how do I log custom error messages for debugging?

@taycaldwell taycaldwell self-assigned this May 30, 2019
@taycaldwell
Copy link
Contributor

Hi @fitsie007,

Our dialog-quotes-java sample provides a great example on how to make requests to external APIs and URLs. You can use that as an example.

Regarding logging - You can log using SLF4J, providing any underlying implementation you wish, such as log4j. The sample mentioned above also provides an example of this that you can use as a reference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants