Hooking up a web service, which can ask things back and receives answers?

987 views Asked by At

Is it somehow possible to call a web service which can ask things back and receives the answer?

Let me explain: At home, I have a media center with some movies on it. It's content changes over time of course: Files get added, removed, renamed and so on.

Now I’d like to say for example “Hey Google, play wizard of oz” and then wizard of oz should played on my tv.

Since I know how to develop things in .NET, the web service running at home already exists and works fine, movies start. And I guess thanks to API.ai, I should be able connect it via the webhook function to Google Home.

But what if there are multiple results and I want to ask, which result should be picked? For example:

  1. User says "Play Star Wars"
  2. Google Home calls my web service, which checks my disk and finds out that there are multiple Star Wars movies.
  3. Now, the user needs to be asked "There are multiple results. Which one would you like to see? Star Wars: A new hope, Star Wars: The empire strikes back, ..."
  4. The user now answers "Star Wars: A new hope"
  5. Google Home calls the web service again with that info and after success it replies "Okay, playing Star Wars: A new hope."

I haven't found out how to do that with API.ai. As I understand, API.ai calls the web service with some parameters (JSON), sends the response text received from the web service back to Google Home and then just ends.

Or did I miss something? Do you guys have any idea how I could achieve this scenario?

Or can we somehow develop our private services, like the ones listed in the Google Home app (Akinator, Dominos, CNBC, ...) or is that only possible as a partner? Would be nice actually.

Thanks in advance!

2

There are 2 answers

1
SysCoder On BEST ANSWER

As I understand, API.ai calls the web service with some parameters (JSON), sends the response text received from the web service back to Google Home and then just ends.

The bot is still in control unless you send from your web service:

data: {
  google: {
   expect_user_response: false,
 }
}

or check this box in API.AI in the intent pane

enter image description here

If you are using the ActionsSDKAssistant, make sure that you are using the right method. Ask vs. Tell

https://developers.google.com/actions/reference/ActionsSdkAssistant#ask https://developers.google.com/actions/reference/ActionsSdkAssistant#tell

2
Bela Vizy On

You need to study the API, the api.ai webhook request/response format and implement it. Take a look at this tutorial. Then, of course, you will have to poke a hole in your firewall to be able to receive the calls from Google or use ngrok or the BST proxy.