armilam / google-assistant-ruby Goto Github PK
View Code? Open in Web Editor NEWA ruby gem for creating Google Assistant actions
License: MIT License
A ruby gem for creating Google Assistant actions
License: MIT License
According to the Google Actions documentation, you can get a user id that works similarly to a cookie session identifier. It's great for anonymous user identification. See the documentation.
Implement a way to get at this identifier.
This comes in the request JSON:
{
"user": {
"user_id": "abcd1234"
},
...
}
Right now, we handle_error(message)
if something is wrong, and that just raise
s that message.
Instead, perhaps we should create error classes and raise
instances of those instead?
The README could use some better instruction and examples, as well as a copy of the license.
According to Google's documentation, you can link a user's Google account with their existing account on your service. Implement a way to do this.
According to Google's documentation, you can ask for user information, like their address. Implement a way to do this.
A possible API for this:
# lib/google_assistant/permission.rb
module GoogleAssistant
module Permission
NAME = "NAME"
DEVICE_PRECISE_LOCATION = "DEVICE_PRECISE_LOCATION"
DEVICE_COARSE_LOCATION = "DEVICE_COARSE_LOCATION"
end
end
# controller
permission = GoogleAssistant::Permission::NAME
// OR
permission = [
GoogleAssistant::Permission::NAME,
GoogleAssistant::Permission::DEVICE_PRECISE_LOCATION
]
assistant.ask_for_permission("To address you by name and know where you sleep", permission)
And then, of course, we'll need a way to get that information from the response. It seems that information comes in the response immediately when the user allows it.
We'll also need to handle rejection.
Hi! it seems like you use the App Actions and not Conversational ones, right?
i been struggle with different JSON request 😔
Right now, GoogleAssistant
is a class and is also a namespace. I don't like this. Make it a module and move its direct functionality to another class.
It seems Google is going to add support for creating accounts directly via Google Assistant.
When they make this available, we should support it.
Hi, i'm currently trying to use rails to build custom google actions with DialogFlow, together with the omniauth-google_oauth2 gem to provide the oauth2 service. I also require user authorization in order to pull information from their google accounts.
All works well up till the point where the google user signs up/ chooses their google account. Right after they do so, an error occurs:
`{
"error": {
"code": 400,
"message": "Bad response from IdP in Auth Code Exchange",
"status": "FAILED_PRECONDITION"
}
}
Request URL: https://oauthintegrations.googleapis.com/v1/token:getForService
Request Method: POST
Status Code: 400
Remote Address: 74.125.24.95:443
Referrer Policy: no-referrer-when-downgrade
access-control-allow-origin: https://gala-demo.appspot.com
access-control-expose-headers: content-encoding,date,server,content-length
alt-svc: quic=":443"; ma=2592000; v="43,42,41,39,35"
cache-control: private
content-encoding: gzip
content-length: 136
content-type: application/json; charset=UTF-8
date: Thu, 05 Jul 2018 13:17:41 GMT
server: ESF
status: 400
vary: Origin, X-Origin, Referer
x-content-type-options: nosniff
x-frame-options: SAMEORIGIN
x-xss-protection: 1; mode=block
Provisional headers are shown
Authorization: Bearer *my access_token*
Content-Type: application/json
Origin: https://gala-demo.appspot.com
Referer: https://gala-demo.appspot.com/app
User-Agent: *my user agent*
{credential: {,…}, gdiState: "APP_AUTH", serviceId: "ardent-fusion-209108_dev",…}
credential
:
{,…}
gdiState
:
"APP_AUTH"
scopes
:
["https://mail.google.com/"]
serviceId
:
"*my_project_id*_dev"`
On Actions on Google, I've set the account linking settings to be:
On DialogFlow, I've also set the webhooks to be that of my_rails_app.com/google_assistant, without any headers/username and password as i have already put skip_before_verify for my google assistant action.
(I've also tried setting the linking flow to be the authorization code flow. However, i am unsure what is the token_url, and when i put in the same url as that of the auth url, the same error occurs.)
Please do let me know if there is any more information you need! I've already asked the same question on Stackoverflow here: https://stackoverflow.com/questions/51178237/bad-response-from-idp-in-auth-code-exchange-during-google-account-linking-with-r , and the very helpful user Prisoner has helped me clarify that this may be an issue with omniauth (if you feel the same way, let me know and i'll re-open the issue at the omniauth gem page instead). He also mentioned it may only work with the authorization code flow, but i've tried that way to no avail as well.
EDIT: I've since realized that omniauth follows the auth code flow. I've thus changed my linking flow to auth code and added /users/auth/google_oauth2 as my auth url and /users/auth/google_oauth2/callback as my token url. However, there is now an error of redirect_uri_mismatch even though i have added https://my_app.com//users/auth/google_oauth2/callback and https://my_app.com//users/auth/google_oauth2 into my oauth client's authorized uri redirects.
Any help will be greatly appreciated!
Google API requests come in with a list of the device's capabilities:
"surface": {
"capabilities": [
{
"name": "actions.capability.AUDIO_OUTPUT"
},
{
"name": "actions.capability.SCREEN_OUTPUT"
}
]
}
Add support for reading that.
GooglAssistant#build_input_prompt
is based off Google's node SDK, but I think we can improve on the API for ruby. Explore some options and change the API to make it more intuitive and ruby-like.
The Google Assistant API v2 supports account linking during the conversation. This is a more natural flow than requiring users to sign in before they can even talk to your assistant.
Implement support for this.
Can we implement web based authentication method instead of saving credentials in application ?
That would be easy go make multiple account to use same webhook
They're on v2 now. We should support that. See https://developers.google.com/actions/reference/v1/migration#submitting_your_v2_api-enabled_app_1 for details.
It would be nice to document the code itself now that it's taking shape.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.