Code Monkey home page Code Monkey logo

rumors-line-bot's Introduction

rumors-line-bot

Line bot that checks if a message contains internet rumor.

Build Status

State diagram & Documents

This is a one of the sub-project of 真的假的

This state diagram describes how the LINE bot talks to users:

The state diagram

Development

Developing rumors-line-bot requires you to finish the following settings.

LINE@ account & Developer accounts

Please follow all the steps in LINE official tutorial.

Environment variables

First, install heroku toolbelt.

Create .env file, copy the template below and LINE_CHANNEL_SECRET, LINE_CHANNEL_TOKEN inside.

API_URL=https://cofacts-api.g0v.tw/graphql
LINE_CHANNEL_SECRET=<paste LINE@'s channel secret here>
LINE_CHANNEL_TOKEN=<paste LINE@'s channel token here>

Other customizable env vars are:

  • REDIS_URL: If not given, redis://127.0.0.1:6379 is used.
  • PORT: Which port the line bot server will listen at.
  • GOOGLE_DRIVE_IMAGE_FOLDER: Google drive folder id is needed when you want to test uploading image.

Redis server

We use Redis to store conversation context / intents. Please run a Redis server on your machine, or use the Heroku Redis's REDIS_URL directly if you happen to deploy the bot to Heroku.

Node Dependencies

You will need Node.JS 6+ and yarn to proceed.

$ yarn

Get the bot server running on your local machine

With Heroku toolbelt installed, just do this:

$ heroku local

and the server will be started on localhost:5000. (Or the PORT you specified in your .env file.)

Get LINE messages to your local machine

We recommend using ngrok to create a public address that directs the traffic from LINE server to your local machine. With ngrok in your path, just

$ ngrok http 5000

ngrok will give you a public URL. Use this to set the webhook URL of your Channel (See the section "Channel Console" in LINE official tutorial).

We recommend using ngrok configuration file to setup a tunnel with a fixed subdomain. In this way the public URL can be fixed (means no repeatitive copy-pasting to LINE Channel settings!) as long as the subdomain is not occupied by others.

Upload image/video

First, follow the step1 in this url to get client_secret.json and save it to project root.

Second, run:

$ node authGoogleDrive.js

Visit the given url provided above. Get the auth code and paste it to console. Then the program will save your google drive access_token locally at ./.gdrive_access_token.

Make sure you've also set GOOGLE_DRIVE_IMAGE_FOLDER = folderID in .env file.

ref:

OAuth2 Protocols

Googleapi Nodejs Client P.S. This page provide the newest api usage then this.


Production Deployment

If you would like to start your own LINE bot server in production environment, this section describes how you can deploy the line bot to your own Heroku account.

Get the server running

You can deploy the line bot server to your own Heroku account by creating a Heroku app and push to it.

Despite the fact that we don't use Procfile, Heroku still does detection and installs the correct environment for us.

Provision add-on "Heroku Redis"

Provision a Heroku Redis addon to get redis. It sets the env var REDIS_URL for you.

Configurations

You will still have to set the following config vars manually:

$ heroku config:set API_URL=https://cofacts-api.g0v.tw/graphql
$ heroku config:set SITE_URL=https://cofacts.g0v.tw
$ heroku config:set LINE_CHANNEL_SECRET=<Your channel secret>
$ heroku config:set LINE_CHANNEL_TOKEN=<Your channel token>
$ heroku config:set BOTIMIZE_API_KEY=<Your botimize API Key (optional)>

rumors-line-bot's People

Contributors

mrorz avatar godgunman avatar darkbtf avatar nonumpa avatar

Watchers

James Cloos 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.