GithubHelp home page GithubHelp logo

chatbot's Introduction

This chatbot implements some simple function to reply customer with predefined messages when receiving certain messages.

1. Setup Database with below 2 commands(password is empty):
$ mysql -uroot -p < ./models/init_tables.sql 
$ mysql -uroot -p < ./models/init_test_data.sql  

2. Start chatbot
Go to chatbot directory, and check whether there is file main.go, then run below command to start the chatbot server:
$ go run main.go

3. Interact with chatbot by using below curl commands:
$ curl -X POST localhost:8000/chats/review/ -H 'Content-Type: application/json' -d '{"message":"","customer_id":3}'
$ curl -X POST localhost:8000/chats/review/ -H 'Content-Type: application/json' -d '{"message":"I would like to subscribe service from connectly.ai","customer_id":3,"chat_id": "USE_THE_chat_id_GOT_FROM_ABOVE_HTTP_REQUEST"}'
$ curl -X POST localhost:8000/chats/review/ -H 'Content-Type: application/json' -d '{"message":"I would like to know more about connectly.ai","customer_id":3,"chat_id": "USE_THE_chat_id_GOT_FROM_ABOVE_HTTP_REQUEST"}'
$ curl -X POST localhost:8000/chats/review/ -H 'Content-Type: application/json' -d '{"message":"I would like to give feedback about your product","customer_id":3,"chat_id": "USE_THE_chat_id_GOT_FROM_ABOVE_HTTP_REQUEST"}'
$ curl -X POST localhost:8000/chats/review/ -H 'Content-Type: application/json' -d '{"message":"I like your service","customer_id":3,"chat_id": "USE_THE_chat_id_GOT_FROM_ABOVE_HTTP_REQUEST"}' 
$ curl -X POST localhost:8000/chats/review/ -H 'Content-Type: application/json' -d '{"message":"thanks","customer_id":3,"chat_id": "USE_THE_chat_id_GOT_FROM_ABOVE_HTTP_REQUEST"}'

$ curl -X POST localhost:8000/chats/followup -H 'Content-Type: application/json' -d '{"message":"","customer_id":2}'

eg:
$ curl -X POST localhost:8000/chats/review/ -H 'Content-Type: application/json' -d '{"message":"","customer_id":3}'
$ curl -X POST localhost:8000/chats/review/ -H 'Content-Type: application/json' -d '{"message":"I would like to subscribe service from connectly.ai","customer_id":2,"chat_id": "3E5B2C43-0DE7-4ACB-83AD-C630BA29FFAA"}'
$ curl -X POST localhost:8000/chats/review/ -H 'Content-Type: application/json' -d '{"message":"I would like to know more about connectly.ai","customer_id":2,"chat_id": "3E5B2C43-0DE7-4ACB-83AD-C630BA29FFAA"}'
$ curl -X POST localhost:8000/chats/review/ -H 'Content-Type: application/json' -d '{"message":"I would like to give feedback about your product","customer_id":2,"chat_id": "3E5B2C43-0DE7-4ACB-83AD-C630BA29FFAA"}'
$ curl -X POST localhost:8000/chats/review/ -H 'Content-Type: application/json' -d '{"message":"I like your service","customer_id":2,"chat_id": "3E5B2C43-0DE7-4ACB-83AD-C630BA29FFAA"}' 
$ curl -X POST localhost:8000/chats/review/ -H 'Content-Type: application/json' -d '{"message":"thanks","customer_id":2,"chat_id": "3E5B2C43-0DE7-4ACB-83AD-C630BA29FFAA"}'

$ curl -X POST localhost:8000/chats/followup -H 'Content-Type: application/json' -d '{"message":"","customer_id":2}'

4. code structures:
models/:  includes the scripts helping setup db, and the code interact with db;
routers/: includes the logic for handling the http requests
setting/: includes a chatbot.ini file saving db and http server settings, a setting.go file having the logic to load .ini setting
main.go:  contains the main logic of starting a chatbot server

chatbot's People

Contributors

wuxinxin2000 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.