1

I want to listen to the radio in my own app made with dialogflow using a webhook (hosted on firebase). I saw the prebuilt-agent sample of dialogflow but it only helps creating the intent, not on how to play the radio.

I know that we can stream audio with SSML or mp3 files but I never saw anything concerning the radio?

I know it is possible because I can ask my Google Home Mini to play a radio station, but is it possible to create an app that does it? Any indications would be appreciated.

Rémi C.
  • 339
  • 2
  • 12
  • Accoring to a comment on [this answer](https://stackoverflow.com/a/42058545/43846) by a [Google Developer Programs Engineer](https://stackoverflow.com/users/594751/leon-nicholls), _"Streaming is not supported yet [in Actions on Google]"_. – stuartd Apr 10 '18 at 17:04
  • @stuartd Ok! thanks for your answer! – Rémi C. Apr 11 '18 at 07:00
  • What do you mean by "the radio". What is the source of the audio? (As in - you're providing the audio. How do you want to send it?) – Prisoner Apr 11 '18 at 09:36
  • @Prisoner I'd like to have something similar to what is built-in in my Google Home, like when I say "Ok Google, je veux écouter France-Inter" (Ok Google, I want to hear France-Inter), I want to hear the same output. The audio is on the server of France Inter and I can probably retrieve it with it's IP, but I have for now no way to play it. Otherwise I wanted to play my playlist (a list of audio files) but I can't put more than one music in a Media Response and the SSML's limitation is a problem – Rémi C. Apr 11 '18 at 09:59

1 Answers1

2

You have two slightly different problems you're trying to solve.

Radio streams such as the France-Inter stream you're talking about still need to be coordinated with Google directly or with one of the existing streaming services.

For your own audio files, SSML is certainly an issue, but you can handle what you want with the Media Response. Dialogflow will be called with an Event of actions_intent_MEDIA_STATUS which you can create an Intent to capture. You can then send another Media Response with the next song in the playlist.

Update based on your comment.

To maintain your position in the playlist you should not use a global variable. Firebase cloud functions do not guarantee that you will get the same instance two calls in a row. There are a few good approaches which boil down to one of

  • Using a Dialogflow Context to store the location
  • Store the location in some data store (like a Firestore database) and index it using the session ID or
  • Use the Actions on Google library app.data object
Prisoner
  • 49,922
  • 7
  • 53
  • 105
  • That is exactly what I was thinking concerning the media response! My problem now would be to know my position in my playlist because for each https request received, I instantiate a new class and therefore I can't save my position as an attribute. As my code is on firebase, maybe I can use a kind of global variable for it. Thanks for your pointers! – Rémi C. Apr 11 '18 at 12:49
  • Answer updated to address your playlist question. (Going into details might best be done as another question, however) – Prisoner Apr 11 '18 at 13:09
  • Thanks! I'll check that and if I have any problem, I'll ask another question – Rémi C. Apr 11 '18 at 13:11
  • How do you use the app.data object to store info? When I create my app I initialize my playlist index at 0, when i start the playlist I increment it. Then at the end of the audio I receive the end media event and I check the index value but it is always 0... Do I have to add it as JSON or does it not store the data of a session? – Rémi C. Apr 11 '18 at 14:21
  • Using `app.data` is best asked as another question. – Prisoner Apr 11 '18 at 14:53