问题
How to detect the request coming to dialogflow from google home devices.
For google assistant,Facebook and all, I used the source
parameter from the originalRequest
node.
{"originalRequest":{"source":"google","data":{"sender":{"id":"3"},"recipient":{"id":"3"},"message":{"mid":"mid","text":"apple iphone 8","seq":3},"timestamp":1522229806857}}
But for google home also I am getting the source parameter as google itself.
So Is there any parameter to detect the request coming from google home, so that I can change the response accordingly?
回答1:
Yes and no.
First - The Assistant is largely the same on all platforms, so you should be asking why you're trying to identify if the user is using an Assistant with a screen vs one without a screen. You should always be targeting voice as the primary interaction method, even for devices with a screen, and supplement it with visuals rather than relying on them.
However, to determine what capabilities the device you're talking with has, you should look at the originalRequest.data.surface.capabilities
array. This contains an array of objects with a name
parameter. That parameter lists the capabilities that this specific device can handle. If one of the values is actions.capability.SCREEN_OUTPUT
, then it supports a screen (ie - it is a mobile device currently. This will likely also be what is set for the Smart Displays.). If this is absent, then it is likely a speaker (the only device currently available that doesn't have a screen).
来源:https://stackoverflow.com/questions/49750274/detect-request-coming-from-google-home-using-dialogflow