OAuth

This article goes over the process of incorporating Oauth 2.0 into your chatbot flow.
The OAuthLogin Widget is used in conjunction with Google OAuth2.0 and the Button Widget to prompt users to login to their Google Account. Please note that any service which implements standard oauth2 flow can be used with OAuthLogin.

ID Type Text
ID OAuthLogin {
“url”: “https://accounts.google.com/o/oauth2/auth?client_id=918444-pk0jtbcepocl4e0i50m62641jh6mmuv3.apps.googleusercontent.com&redirect_uri=
https://czdfk.hybrid.chat/oauth_redirect&state=STATE_STRING&scope=profile&response_type=code
“,
“image_url”: “insert URL Here”,
“response_text”: “Trying to login…”,
“save_to_var”: “google”,
“width”: “600”,
“height”: “800”
}

Url: is the oauth url which presents the login form to the user. You can get this url from oauth2 docs of any provider.

image_url: https://developers.google.com/identity/images/btn_google_signin_dark_normal_web.png and the width, height parameters can be used for this

Save_to_var: to be used to specify the variable to save the Response after authenticating.

The second step of the process would be to use the SendRequest widget to receive the Access Token by using the variable with the saved response – “google”

53.1 Dialogue
SendRequest-POST-https://accounts.google.com/o/oauth2/token?grant_type=authorization_code&code={{{vars.google.code}}}&client_id=
931071-pk0jtbcepocl4e0i50m62641jh6mmuv3.apps.googleusercontent.com&client_secret=
2IIm3hwCmUJLQjh8HUCgNaUh&redirect_uri=https://czdfk.hybrid.chat/oauth_redirect

{
“headers”: {
“Content-Type”: “application/json”
},
“save_to_var”: “GoogleAuth”
}
SetVariable-GoogleAccessToken {{{vars.GoogleAuth.body.access_token}}}

And the final step would be use another SendRequest widget to GET the user data. We use the variable with the Access Token saved for this step.

55.1 Dialogue
SendRequest-GET-https://www.googleapis.com/oauth2/v1/userinfo?alt=json {
“headers”: {
“Content-Type”: “application/json”,
“Authorization”: “Bearer {{{vars.GoogleAccessToken}}}”
},
“save_to_var”: “User”
}
SetVariable-GoogleId {{{vars.User.body.id}}}
SetVariable-GoogleName {{{vars.User.body.name}}}
SetVariable-GoogleGiven_name {{{vars.User.body.given_name}}}
SetVariable-GoogleFamily_name {{{vars.User.body.family_name}}}
SetVariable-GooglePicture {{{vars.User.body.picture}}}
SetVariable-GoogleLocale {{{vars.User.body.locale}}}


Canned Response for Slack:

Answer customers or prospects quicker, be more productive and save your company hours of time using Canned Responses for Slack – Hybrid.Chat allows for saving of unlimited canned responses, control the flow, automatic insertion of User Details for personalization, saving multilingual responses-all from your Google Spreadsheet and Slack Chat.

Canned Response for Mattermost:

Answer customers or prospects quicker, be more productive and save your company hours of time using Canned Responses for Mattermost – Hybrid.Chat allows for saving of unlimited canned responses, control the flow, automatic insertion of User Details for personalization, saving multilingual responses-all from your Google Spreadsheet and Mattermost Chat.