GithubHelp home page GithubHelp logo

geoffmomin / ama-bot Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jeperez/ama-bot

0.0 1.0 0.0 25.41 MB

Bot ask for asking me anything

Home Page: https://mycaule-ama-bot.herokuapp.com/

License: MIT License

JavaScript 65.40% CSS 11.53% HTML 23.07%

ama-bot's Introduction

AskMeAnything bot

Bot ask for asking me anything.

Demo | Blog post

screenshot

Ready for production chatbot with integrated SaaS backoffices.

The application use this stack : Smooch.io + Dialogflow + GitHub Issues + Node.js + Docker.

Setup

  1. Configure the following two Smooch integration in their web interface: Web messenger, Webhooks

  2. Create an agent using Dialogflow and plug-in the Smalltalk option.

  3. Fill in the secrets file with API keys config/secrets.json.

  4. Install this app and run it!

Domain Key name Documentation
DialogFlow clientAccessToken In the Agent General properties, refer to the API keys section
Smooch appId appId can be found in the homepage https://app.smooch.io/apps/{appId}
Smooch keyId Generate this in the Secrets keys section of https://app.smooch.io/apps/{appId}/settings
Smooch secretKey Generate this in the Secrets keys section of https://app.smooch.io/apps/{appId}/settings

Running the code locally

# Install node dependencies
npm install

# App will be running on port 3000
nodemon app.js

# Optional, generate a public URL with ngrok tunnel
ngrok http 3000

You also have to configure Smooch webhook url with the public url at this point. You can create one using ngrok for example.

See Smooch - Receiving Messages.

Running the code on production

I use Docker to put the application inside a container so that it can be deployed to any cloud platform you like. Application containers have the advantage to be language agnostic for the host and they provide standard operations to deploy, run and monitor your apps.

See Google - Scalable Microservices with Kubernetes

Deploy locally

# Rebuilding the image
docker build -t mycaule/ama-bot .
# Listing images
docker images

# Make sure to have the secrets.json locally
vi config/secrets.json

# Running the image with a redirection to local port 8080
docker run -p 8080:3000 -v $PWD/config:/usr/src/app/config -d mycaule/ama-bot

# In production
# docker run -e "NODE_ENV=production" --rm -it --init -m "300M" --memory-swap "1G" -p 80:3000 -v $PWD/config:/usr/src/app/config --name "ama-bot" -d mycaule/ama-bot

# Listing docker processes
docker ps

# Printing app output
docker logs <container id>

# Enter the container
docker exec -it <container id> /bin/sh

See Dockerizing a Node.js web app.

Deploy using Heroku

Run the following commands to deploy the Docker image to Heroku.

heroku container:login
heroku create
heroku container:push web

Please note that Heroku does not support the following Dockerfile commands: EXPOSE, VOLUME. Hence, the HTTP port is defined by Heroku and the config variables have to be defined using heroku config:set command or on their interface. To do so, please have the following variables defined in process.env context: dialogflow_clientAccessToken, smooch_appId, smooch_keyId, smooch_secretKey.

See Heroku - Container Registry & Runtime and Heroku - Configuration and Config Vars

Configure Smooch with production URL

smooch webhook

Deploy using App Engine

Demo

[Configure docker for Cloud Repositories](Configure docker for Cloud Repositories):

gcloud components install docker-credential-gcr
docker-credential-gcr configure-docker
gcloud app deploy --project ama-bot app.yaml

The environment variables are defined in env_variables section of app.yaml file. Create one using the template found in /config/app.template.yaml.

See Google - Configuring your App with app.yaml.

Deploy using Cloud Container Engine

This method is for deploying the Docker image on Google Cloud Platform.

TODO

  • How to handle volumes with kubectl?

Make sure to have a Compute Engine instance first, if you don't check this and this posts.

# Upload the docker image to Container Registry
export PROJECT_ID="$(gcloud config get-value project -q)"
docker build -t gcr.io/${PROJECT_ID}/ama-bot .

# Create a new cluster
gcloud container clusters create k0
gcloud components install kubectl

# List available instances
gcloud compute instances list

# Deploy the application
kubectl run ama-bot --image=gcr.io/${PROJECT_ID}/ama-bot --port 8080

# List available deployments
kubectl get pods

# Expose the application
kubectl expose deployment ama-bot --type=LoadBalancer --port 80 --target-port 8080

# List available exposed services, EXTERNAL-IP
kubectl get services

GCP external IP

See Google - Deploying a containerized web application.

Routes

Available HTTP routes are:

  • GET /: A web interface for the chatbot,
  • POST /: A webhook implementing Smooch and Dialogflow REST API calls.

Roadmap

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.