Just1B / meme-bot

Google Hangouts Chatbot for Meme generation in chats

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Chatbot

This is a sample chatbot for Google Hangouts Chat written in Elixir, using the Phoenix framework. This application comes with a Dockerfile and is ready to be packaged as a container and is perfect for running in your serverless environment.

This application was written as a demo for Cloud Next '19.

Dependencies

The chatbot is meant to receive messages from Google Hangouts Chat.

There is a runtime dependcy on Cloud Firestore in Datastore Mode.

The chatbot also depends on a meme service, and by default uses the one hosted at https://meme-fpz6derz7a-uc.a.run.app

Build

  1. Generate a new secret key base.
 SECRET_KEY_BASE=$(elixir -e ":crypto.strong_rand_bytes(48) |> Base.encode64 |> IO.puts")
 sed "s|SECRET+KEY+BASE|$SECRET_KEY_BASE|" config/prod.secret.exs.sample >config/prod.secret.exs
  1. To build with Google Cloud Build, simply issue this gcloud command.
gcloud builds submit --tag=gcr.io/<GOOGLE CLOUD PROJECT>/chatbot:v1 .

Deploy

These instructions are for deploying the meme-bot to Google's Cloud Run Service.

  1. Enable Google Cloud Firestore and create a database in Datastore mode (use a geography based on where you will deploy the chatbot).

  2. Give your default compute service account datatore read and write permissions

  3. Deploy the built image to Cloud Run

You'll need to set a couple of environment variables.

  • PROJECT = Your Google Cloud Project Name. This is required to connect to datastore.
  • MEME = a URL for a MEME generation service. You can use the one in the example below.
 gcloud beta run deploy chatbot --image gcr.io/<GOOGLE CLOUD PROJECT>/chatbot:v1 --memory=512M --set-env-vars=PROJECT=<PROJECT NAME>,MEME=https://meme-fpz6derz7a-uc.a.run.app
  1. Register the chatbot with Hangouts Chat in your GSuite domain.

This is done by creating a domain scoped project. Select synchronous / HTTP for the bot configuration and set the URL to be the deployed URL of your Cloud Run service, plus the path /api/hello

https://<your service>.a.run.app/api/hello

About

Google Hangouts Chatbot for Meme generation in chats

License:Apache License 2.0


Languages

Language:Elixir 72.0%Language:CSS 17.8%Language:JavaScript 6.8%Language:Dockerfile 1.9%Language:HTML 1.5%