GithubHelp home page GithubHelp logo

chatting-bot-practice's Introduction

QRCode

image

Usage

輸入start開始

start

設定身高、體重、預算、年齡

function_list

出現「功能選單」

function_list2

點選 show FSM

show_fsm

FSM圖

fsm

點選 建議營養比例

showsuggestion

點選 設定個人資訊 更新身高、體重、預算、年齡

modified_information

點選 分析早/午/晚餐營養指標 進入「選擇餐點」

checknutrition

點選 早餐

breakfast

點選餐點後回到「選擇餐點」,點選 顯示您的攝取資訊

shownutrition

shownutrition2

輸入return繼續選擇午餐、晚餐

backtochecknutrition

lunch

dinner

輸入完 早/午/晚餐 後的完整攝取資訊

show_all_nutrition

Deny states : 4 deny states

1.餘額不足 money_deny

2.熱量太高 calorie_deny

3.澱粉太多 starch_deny

4.蛋白質太多 protein_deny

TOC Project 2020

Maintainability

Known Vulnerabilities

Template Code for TOC Project 2020

A Line bot based on a finite state machine

More details in the Slides and FAQ

Setup

Prerequisite

  • Python 3.6
  • Pipenv
  • Facebook Page and App
  • HTTPS Server

Install Dependency

pip3 install pipenv

pipenv --three

pipenv install

pipenv shell

Secret Data

You should generate a .env file to set Environment Variables refer to our .env.sample. LINE_CHANNEL_SECRET and LINE_CHANNEL_ACCESS_TOKEN MUST be set to proper values. Otherwise, you might not be able to run your code.

Run Locally

You can either setup https server or using ngrok as a proxy.

a. Ngrok installation

or you can use Homebrew (MAC)

brew cask install ngrok

ngrok would be used in the following instruction

ngrok http 8000

After that, ngrok would generate a https URL.

Run the sever

python3 app.py

b. Servo

Or You can use servo to expose local servers to the internet.

Finite State Machine

fsm

Usage

The initial state is set to user.

Every time user state is triggered to advance to another state, it will go_back to user state after the bot replies corresponding message.

  • user
    • Input: "go to state1"

      • Reply: "I'm entering state1"
    • Input: "go to state2"

      • Reply: "I'm entering state2"

Deploy

Setting to deploy webhooks on Heroku.

Heroku CLI installation

or you can use Homebrew (MAC)

brew tap heroku/brew && brew install heroku

or you can use Snap (Ubuntu 16+)

sudo snap install --classic heroku

Connect to Heroku

  1. Register Heroku: https://signup.heroku.com

  2. Create Heroku project from website

  3. CLI Login

    heroku login

Upload project to Heroku

  1. Add local project to Heroku project

    heroku git:remote -a {HEROKU_APP_NAME}

  2. Upload project

    git add .
    git commit -m "Add code"
    git push -f heroku master
    
  3. Set Environment - Line Messaging API Secret Keys

    heroku config:set LINE_CHANNEL_SECRET=your_line_channel_secret
    heroku config:set LINE_CHANNEL_ACCESS_TOKEN=your_line_channel_access_token
    
  4. Your Project is now running on Heroku!

    url: {HEROKU_APP_NAME}.herokuapp.com/callback

    debug command: heroku logs --tail --app {HEROKU_APP_NAME}

  5. If fail with pygraphviz install errors

    run commands below can solve the problems

    heroku buildpacks:set heroku/python
    heroku buildpacks:add --index 1 heroku-community/apt
    

    refference: https://hackmd.io/@ccw/B1Xw7E8kN?type=view#Q2-如何在-Heroku-使用-pygraphviz

Reference

Pipenv ❤️ @chihsuan

TOC-Project-2019 ❤️ @winonecheng

Flask Architecture ❤️ @Sirius207

Line line-bot-sdk-python

chatting-bot-practice's People

Contributors

clover-forever avatar

Watchers

 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.