Giter Club home page Giter Club logo

cogit's Introduction

DISCLAIMER: This framework is released for internal purporse, it is buggy, incompleted and it need a lot of refactoring. It shouldn't be used for production. It is released under Open Source License, do what you prefer at your own risk.

COGIT

A framework to build multiplatform intelligent bots

HOW IT WORK

INITIAL CONFIGURATION

Configure your bot in settings.py file.

Define user-bot interaction in json files inside the corpora folder with the following constants:

  • PLATFORM the platform where the bot will run, currently the only supported platform is Messenger.
  • BASE_PATH the full path to the bot.py file (dumb thing sorry).
  • DB_NAME if you want to use the Sqlite ORM specify your db username here.
  • DB_USER if you want to use the Sqlite ORM specify your db username here.
  • DB_PSW if you want to use the Sqlite ORM specify your db password here.
  • MESSENGER_TOKEN your bot's private token for the messenger platform.
  • MESSENGER_VERIFY_TOKEN your bot's verify token for the messenger platform webhook configuration.
  • ALGORITHM the algorithm that will power your bot brain, options are "standard" for full-matching or "probabilistic" for TF/IDF.
  • PROBA_THRESHOLD if you want to use the probabilistic algorithm set the threshold here.
  • UNDER_MAINTENANCE put your bot under maintance, your bot will answer with UNDER_MAINTENANCE_MSG at each user except the DEV.
  • UNDER_MAINTENANCE_MSG the message shown when the bot is under maintenance.
  • DEV_ID if your bot is under maintenance it can interact only with this user.
  • PORT the port where the bot app will run.
  • DEBUG enable debug mode.

DEFINE USER-BOT INTERACTION

You can define interactions in json files inside corpora folder. An example of brain.json from Hi Coach:

{
	"revision": "1.1",

	"base": {
		"IS-STRING": {
			"text": "Hello there, what you want to do today ?",
			"choose": [
				["Choose a workout"],
				["Start your plan"],
				["Set a reminder"],
				["Nutrition facts"]
			],
			"context": "start-training"
		},
		"DEFAULT": {
			"text": "Sorry dude, I don't understand",
			"buttons": [
				["Hi Coach"],
				["Contact support", "Rate the Coach"]
			]
		},
		"hi coach": {
			"action": "stopWorkout",
			"id": true,
			"result": {
				"ok": {
					"text": "Hello there, what you want to do today ?",
					"choose": [
						["Choose a workout"],
						["Start your plan"],
						["Set a reminder"],
						["Nutrition facts"]
					],
					"context": "start-training"
				}
			}
		},
    "about me": {
			"text": "Hello there, I am Coach Bot, I can create personalized bodyweight workout for you every time that you need it, then I listen to your feedback to make the training perfect for you. Just tell me what you want to do.",
			"choose": [
				["Choose a workout"],
				["Start your plan"],
				["Set a reminder"],
				["Nutrition facts"]
			],
			"context": "start-training"
		},
		
		"motivate me":
		{
						"action": "getMotivation",
						"id": true,
						"result": {
						"ARRAY": {
					"template": "$TEXT. Check out this video $VIDEO",
					"context": "base"
				}
			}
		},

		"facebook page": {
			"text": "Follow Avada's Facebook Page for fitness tips fb.me/avadatech",
			"context": "base"
		},
		"rate the coach": {
			"text": "Do you want more training programs ? Rate the coach and we will add new workouts https://telegram.me/storebot?start=the_coach_bot",
			"context": "base"
		},
		"get avada app": {
			"text": "Download Avada iOS App for free and you will get full personalized functional bodyweight workouts https://itunes.apple.com/it/app/avada-training/id1078235590?mt=8&ign-mpt=uo%3D4&ls=1",
			"context": "base"
		},
		"contact support": {
			"text": "Contact us for support and feedback https://telegram.me/coachbot_support",
			"context": "base"
		},
		"back": {
			"text": "Okay, let me know when you want to workout",
			"context": "base"
		},
		"cancel": {
			"text": "Okay, let me know when you want to workout",
			"context": "base"
		}
	},

	"set-time": {
		"IS-STRING": {
			"action": "setAlertDays",
			"id": true,
			"result": {
				"ok": {
					"text": "At what time do you want to workout ? Insert it in 24h format",
					"context": "set-reminder"
				}
			}
		}
	},
}

In the examples above:

  • CONTEXTS are "base" and "set-time, if context are no define for a response it will keep the current context.
  • PATTERNS are "hi coach", "about you", "motivate me" ecc
  • PATTERNS PLACEHOLDER are "IS-STRING" and "DEFAULT", those repleace pattern for particular cases, DEFAULT is the answer for unmatched patterns, IS-STRING and IS-INT are used to handle variables.
  • ACTION are functions defined in functions.py they will be executed before sending the response, you can create conditional responses based on the result, if "id" is true the function will receive the user id as input. You can define template for action response, you can use them returning a dict in function (with lowercase keys) and use the keys in the template as $KEY (uppercase key).

cogit's People

Contributors

guiz4rd avatar

Stargazers

Prateek Chanda avatar  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.