{"id":24518921,"url":"https://github.com/phalanstere/universal_chatbot","last_synced_at":"2025-03-15T11:21:44.984Z","repository":{"id":57386643,"uuid":"106296758","full_name":"Phalanstere/universal_chatbot","owner":"Phalanstere","description":null,"archived":false,"fork":false,"pushed_at":"2017-12-07T17:55:52.000Z","size":197,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-22T01:47:28.455Z","etag":null,"topics":["aiml","chatbot"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Phalanstere.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-10-09T14:49:39.000Z","updated_at":"2022-04-03T00:07:39.000Z","dependencies_parsed_at":"2022-09-17T00:02:13.567Z","dependency_job_id":null,"html_url":"https://github.com/Phalanstere/universal_chatbot","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Phalanstere%2Funiversal_chatbot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Phalanstere%2Funiversal_chatbot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Phalanstere%2Funiversal_chatbot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Phalanstere%2Funiversal_chatbot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Phalanstere","download_url":"https://codeload.github.com/Phalanstere/universal_chatbot/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243720254,"owners_count":20336790,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aiml","chatbot"],"created_at":"2025-01-22T01:47:52.899Z","updated_at":"2025-03-15T11:21:44.965Z","avatar_url":"https://github.com/Phalanstere.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Universal Chatbot\n\nTaking the principles of aiml - but allowing a dynamic and extendable *.js environment\n\n\n\n```\nnpm install universal_bot\n```\n\n\nTo create a new instance of the bot\n\n\n```\nvar UniversalBot = require(\"universal_chatbot);\n\nvar bot = new UniversalBot();\n```\n\n# Passing parameters\n\nUsuallay, you you would pass some parameters, al list of **aiml-type** files, a **strategy** and so forth.\n\n\n\n\n\n# File structure and internal logic\n\n**index.js** is where it all begins. Here you define the bot's psychology, set the parameters and so forth.\n\nThe bot may follow a strategy.\n\n\n\n\n## aiml files\n\n```\nvar params = {};\n\nparams.aiml = [\n        \"./aiml/conversation_start.json\",\n    ];\n\n\nvar bot = new UniversalBot( params );\n```\n\n## bot_identity\n\nYou can pass a **bot_identity** like this:\n\n\n```\nparams.bot_identity = {\n    name: \"UniversalBot\",\n    age: 12,   \n    hobbys: [\"music\", \"telepathy\"]\n}\n```\n\n\n\n## conversation strategy\n\nThe bot will follow a conversation strategy which is laid down in a *.json file and may be passed indvidually.\n\n\n```\n\n[\n    {\n        \"name\": \"greeting\",\n        \"weight\": 0,\n        \"in\": [],\n        \"out\": [\n            {\n                \"name\": \"identity\",\n                \"weight\": 0.33\n            },\n            {\n                \"name\": \"wheather\",\n                \"weight\": 0.33\n            },\n            {\n                \"name\": \"compliment\",\n                \"weight\": 0.33\n            }\n        ]\n    },\n    {\n        \"name\": \"identity\",\n        \"weight\": 0,\n        \"in\": [\n            {\n                \"name\": \"greeting\",\n                \"weight\": 1\n            }\n        ],\n        \"out\": [\n            {\n                \"name\": \"veracity\",\n                \"weight\": 0.33\n            },\n            {\n                \"name\": \"compliment\",\n                \"weight\": 0.33\n            },\n            {\n                \"name\": \"age\",\n                \"weight\": 0.33\n            }\n        ]\n    },\n    etc.\n\n```\n\n\n\n\n\u003c/hr\u003e\n\n# The different communication layers\n\n## AIML-Layer \n\nThe most fundamental, in a way *hard-wird* layer is the aiml-level.\nHere you just input a phrase - the bozt scans the respectives **aiml-files** and gives an answer\n\n## The paraphrase-Layer\n\nThis layer resembles the classical **eliza-bot** logique.\nHere the bots gets the input - analyses it grammatically - and gives a return.\n\nThe **speechact.js** file refers to the analysis and detection of speechacts. This includes a thougrough syntax analysis.\n\n## AIML combined with intentions\n\n\n\u003chr/\u003e\n\n# AIML \n\nA typical **aiml.json** file looks like the corresponding **.aiml**  type, with some minor differences.\nYou have the typical wildcards, like **\\*** and **^**, you have the **srai** parameter which redirects the phrase.\nYou have also the reponse, stored in the **template**. It it is just one string, this will be taken as the desire4d input, it it is an array, it will be understood as a random list.\n\n\n```\n[\n    {\n        \"pattern\": \"Hello *\",\n        \"srai\": null,\n        \"topic\": \"greeting\",\n        \"template\": [\n            \"Hi\",\n            \"How is it going\"\n        ]\n    },\n    {\n        \"pattern\": \"Hi *\",\n        \"srai\": null,\n        \"template\": [\n            \"How is it going, {name}, you old {nickname}?\"\n        ]\n    }\n]\n```\n\nThe bot also supports **aiml conditions**.  \n\n\n```\nbot.aiml.input ( { pattern: \"What's up?\", condition:  { mood: \"sad\" }  }, bot.session, bot.process_aiml);\n```\n\nThe corresponding json looks like this:\n\n```\n    {\n        \"pattern\": \"What's up?\",\n        \"condition\": true,\n        \"template\": [\n            {\n            \"mood\": \"sad\",\n            \"template\": \"I feeld really depressed\"    \n            },\n            {\n            \"mood\": \"happy\",\n            \"template\": \"Life is great\"\n            }\n        ]\n    },\n```\n\n\n# Working with intentions\n\nAn intention file looks like this:\n\n```\n[\n    {\n        \"name\": \"price\",\n        \"weight\": 0,\n        \"in\": [],\n        \"out\": [\n            {\n                \"name\": \"registration\",\n                \"weight\": 0.2\n            },\n            {\n                \"name\": \"payment_mode\",\n                \"weight\": 0.2\n            },\n            {\n                \"name\": \"withdrawal\",\n                \"weight\": 0.2\n            },\n            {\n                \"name\": \"plausibility\",\n                \"weight\": 0.2\n            },\n            {\n                \"name\": \"info_text\",\n                \"weight\": 0.2\n            }\n        ],\n        \"aiml\": \"HOW_MUCH\",\n        \"keywords\": [\n            \"price\",\n            \"how much\",\n            \"pay\"\n        ],\n        \"excludes\": [\n            \"NEGATION\"\n        ]\n    }\n    etc. \n]\n```\n\nEach node of this consists of **ins** and **outs**  - that means reference to other nodes. The nodes - taken as a whole - form a Markow chain.\n\nBuilding such a chain is quite easy, and there some methods in the **bot.intentions.intentions** object.\n\n```\n    var obj = bot.intentions.intentions;\n```\n\nHere you add some nodes\n```\n    obj.addNodes(   ['price',\n                    'registration', \n                    'payment_mode',\n                    'withdrawal'\n                    ]);\n```\n\nThis defines a node in detail\n```\n    obj.characterize(\"price\", {\n        aiml: \"HOW_MUCH\",\n        keywords: [\"price\", \"how much\", \"pay\"],\n        excludes: ['NEGATION']\n        })\n```\nWith the **aiml** parameter you can set an aiml pointer.\nWhen the user input contains some of the **keywords**, the ususal chain will be overriden and the intention process is privileged.\n\nWith this function you create a Markow-relation between different nodes.\n\n```\n    self.addRelation(\"price\", [\"registration\", \"payment_mode\", \"withdrawal\"]); \n```\n\n\n# Bot interaction\n\nbot interaction is quite easy. As a first parameter you pass the input, then the session_id (that will be returned after you have started a conversation, then a callback)\n\n\n```\nbot.input(\"Who is the leader of the seminaire\", null, function( data, error ) {\n\n    if (data) {\n        console.log( data );\n    }\n\n});\n\n```\n\n\n\n\n\n# Syntax detection\n\nThe bot has an inbuilt **syntax detection** which allows to detect simple sentences (including adverbial phrases and relative sentences)\n\n\n\n\n# Conversation Strategies","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphalanstere%2Funiversal_chatbot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphalanstere%2Funiversal_chatbot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphalanstere%2Funiversal_chatbot/lists"}