Git Product home page Git Product logo

hangouts-chat-bot-cloud-function-nodejs-example's Introduction

Hangouts Chat Bot on Google Cloud Functions

This is not an officially supported Google product

This repo contains a full example of a Google Cloud Function which can server as a bot for Google Hangouts Chat written in NodeJS. The bot is able to authenticate users with their Google account by means of a OAuth 2.0 web flow and acquire permissions for scopes from the Google Cloud Platform (GCP). In this particular example, the bot asks to access Google BigQuery on behalf of the user.

The following sections describe how to deploy the bot on Google Cloud Functions and which prior steps are necessary to prepare your GCP project.

Prerequisites

Following a list of steps which prepare your GCP project and configure the code example:

First, you need to enable the following APIs in your GCP project:

Then, following steps are required:

To enable Google Cloud Build to deploy to Cloud Functions, you need to grant developer permissions and enable the use of service accounts. Add the permissions Service Account > Use Service Account and Cloud Functions > Developer to the Cloud Build service account.

Finally, copy src/param.js.template to src/params.js. In the new file, copy your OAuth client credentials and add scopes (optional).

Deployment

The deployment of the code is a one line execution using the Google Cloud SDK. From the root folder, simply run the following:

gcloud builds submit --substitutions=_BUCKET=[code-bucket]

Test & Experimentation

You can use the following command to trigger the authentication flow from the shell:

curl -vvv -X POST -H "Content-Type: application/json" -d '{"configCompleteRedirectUrl": "https://google.com"}' https://[region]-[gcp-project-id].cloudfunctions.net/[function-name]/bot

To follow the OAuth flow, pick the URL included in the response and open it in a browser (e.g. Chrome).

Read more about concepts of a Hangouts Chat bot.

Publish your Hangouts Chat Bot

The procedure to publish the chat bot is as described in the documentation. When entering the URL of your bot, use the following pattern to construct your bot URL:

https://[region]-[gcp-prject-id].cloudfunctions.net/[function-name]/bot

Contributers

hangouts-chat-bot-cloud-function-nodejs-example's People

Contributors

mugglmenzel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.