Search code examples
google-assistant-sdk

Google embedded assistant service gives an error about text_config missing when it is included


I'm trying to use the embedded Google Assistant service (https://developers.google.com/assistant/sdk/reference/rpc/google.assistant.embedded.v1alpha2) to send some text queries from an app I'm writing in Rust. As there's no official client library and I haven't been able to get either of the GRPC libraries I've tried working, I'm POSTing an AssistRequest proto directly to https://embeddedassistant.googleapis.com/$rpc/google.assistant.embedded.v1alpha2.EmbeddedAssistant/Assist. After getting the appropriate OAuth token and registering a device ID, I send a proto like this:

config {
  text_query: "what's the time"
  audio_out_config {
    encoding: MP3
    sample_rate_hertz: 16000
  }
  screen_out_config {
    screen_mode: PLAYING
  }
  dialog_state_in {
    language_code: "en-US"
  }
  device_config {
    device_id: "my_device_id"
    device_model_id: "<my model id>"
  }
}

(with a valid device_id and device_model_id filled in). However, I always get a 400 back, with the error

"Invalid \'AssistConfig\': audio_in_config or text_query must be provided."

Why am I getting this error, when text_query is clearly filled in? I get the same error if I try setting audio_in_config.


Solution

  • Answering my own question, it turned out I needed to wrap the request in a StreamBody proto, putting the serialised AssistRequest in the message field. This was not documented anywhere I could see though!