{"id":22933980,"url":"https://github.com/atypicalim/chatbot","last_synced_at":"2025-03-03T09:04:08.076Z","repository":{"id":58878956,"uuid":"90100107","full_name":"Atypicalim/chatbot","owner":"Atypicalim","description":"chatbot, an aiml interpreter for PHP","archived":false,"fork":false,"pushed_at":"2024-08-29T12:43:42.000Z","size":1062,"stargazers_count":108,"open_issues_count":0,"forks_count":44,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-02-24T08:05:52.168Z","etag":null,"topics":["aiml","aiml-interpreter","aiml-parser","chatbot","php"],"latest_commit_sha":null,"homepage":null,"language":"PHP","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/Atypicalim.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-05-03T02:36:48.000Z","updated_at":"2024-08-29T12:43:47.000Z","dependencies_parsed_at":"2024-12-14T11:36:53.296Z","dependency_job_id":null,"html_url":"https://github.com/Atypicalim/chatbot","commit_stats":null,"previous_names":["atypicalim/chatbot"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Atypicalim%2Fchatbot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Atypicalim%2Fchatbot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Atypicalim%2Fchatbot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Atypicalim%2Fchatbot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Atypicalim","download_url":"https://codeload.github.com/Atypicalim/chatbot/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241635298,"owners_count":19994792,"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","aiml-interpreter","aiml-parser","chatbot","php"],"created_at":"2024-12-14T11:36:44.832Z","updated_at":"2025-03-03T09:04:08.049Z","avatar_url":"https://github.com/Atypicalim.png","language":"PHP","readme":"#  An aiml parser for PHP\r\n\r\n---\r\n\r\n## 0. notice\r\n\r\n\u003e the chatbot is written according to AIML 2.5 and [Program-P](https://github.com/pe77/Program-P)，it uses utf-8 and i made some customization , there are some differences between standard aiml tags and the tags used in this program.\r\n\r\n## 1. description\r\n\r\n\u003e it is working well on PHP5.4 and Apache server .\r\n\r\n## 2. database configuration\r\n\r\n\u003e you should use MySQL database and import the `chatbot.sql` file to your database . then, you should configure your database information in `chatbot/Config.php` file . \r\n\r\n\r\n## 4. aiml sourses\r\n\r\n\u003e you can edit `aiml/chatbot.aiml` fiel directly or create an aiml file in aiml directory and include it in `aiml/chatbot.aiml` file。\r\n\r\n## 5. about aiml files\r\n\r\n\u003e * `aiml` files should be paleced in `aiml` directory. \r\n\r\n\u003e * `chatbot.aiml`is the entrance ，the `aiml` tag in it can contain various `category` tag , a `default`tag and various `include`tag。\r\n\r\n\u003e * other `aiml` files writen by you should contain a `topic` tag in root `aiml` tag , and the topic can contain various `category` tag and a `default` tag (it should not have `include` tag)。\r\n\r\n\r\n## 6. test\r\n\r\n\u003e you can visit `index.php` to test it.\r\n\r\n## 7. using the chatbot\r\n \r\n\u003e if you want to use the chatbot in your application, you can request `api.php?requestType=talk\u0026userInput=hello`。\r\n\r\n\r\n## 8. about the regular expressions\r\n\r\n\u003e Modified matching rules :\r\n\r\n```PHP\r\n* ---\u003e (\\S+)\r\n# ---\u003e \\S+\r\n_ ---\u003e .*\r\n= ---\u003e \\S*\r\n```\r\n\r\n## 9. about aiml tags\r\n\r\n\u003e it is different from the standard aiml，i made some customizaton to aiml tags , you can see the tag rules in [AIML.MD](AIML.md) file。\r\n\r\n## 10. about the response of api.php\r\n\r\n\r\n```json\r\n{\r\n    \"status\": \"success\",\r\n    \"type\": \"talk\",\r\n    \"message\": \"haha ...\",\r\n    \"data\": {\r\n        \"arr1\": {\r\n            \"name11\": \"value11\",\r\n            \"name12\": \"value12\"\r\n        },\r\n        \"arr2\": {\r\n            \"name21\": \"value21\",\r\n            \"name22\": \"value22\"\r\n        }\r\n    }\r\n}\r\n```\r\n\r\n\u003e you will get above response when you visit `api.php?requestType=talk\u0026userInput=haha` and you have a category like this .\r\n\r\n```xml\r\n\u003ccategory\u003e\r\n    \u003cpattern\u003ehaha\u003c/pattern\u003e\r\n    \u003ctemplate\u003e\r\n        \u003cdata name=\"arr1\"\u003e\r\n            \u003cattr name=\"name11\"\u003evalue11\u003c/attr\u003e\r\n            \u003cattr name=\"name12\"\u003evalue12\u003c/attr\u003e\r\n        \u003c/data\u003e\r\n        \u003cdata name=\"arr2\"\u003e\r\n            \u003cattr name=\"name21\"\u003evalue21\u003c/attr\u003e\r\n            \u003cattr name=\"name22\"\u003evalue22\u003c/attr\u003e\r\n        \u003c/data\u003e\r\n        haha ...\r\n    \u003c/template\u003e\r\n\u003c/category\u003e\r\n```\r\n\r\n## 11. about userId\r\n\r\n\u003e when you send a userId param as a get param , this will be used as a unique identity of user , or the program will use user's ip instead of it .\r\n\r\n```php\r\n$userId = isset($_REQUEST['userId']) ? $_REQUEST['userId'] : $_SERVER['REMOTE_ADDR'];\r\n```\r\n\r\n## 12. about multi chatbot\r\n\r\n\u003e if you set the multiChatbot variable false in 'chatbot/Config.php' , all users share a default chatbot . and if you set it true , every user will have a unique chatbot and we will set the chatbot informations in template tag , like botName , botAge , botSex and others , this will be verry usefull when you are building a voice assistant app and hoping the users can reaname your app . the multi chatbot also uses the userId(ip or the value you send it to chatbot) as a unique identity . \r\n\r\n```php\r\n$user = $this-\u003egetUser($this-\u003e_unique);\r\nif ($this-\u003e_config-\u003emultiChatbot){\r\n    $bot = $this-\u003egetBot($this-\u003e_unique);\r\n} else {\r\n    $bot = $this-\u003egetBot(\"default\");\r\n}\r\n```\r\n\r\n## 13. about userInfo and botInfo\r\n\r\n\u003e userInfo is user's properties like name , sex and age . then , botInfo is similar too . botInfo is the bot's information serving for the user . if you using multi chatbot mode , every user can change their bot's informations , they can rename it , and give it a age . for usage you can view the [AIML.MD](AIML.md) file and study about the tags like set, get, del, user, bot.\r\n\r\n```xml\r\n\u003ccategory\u003e\r\n    \u003cpattern\u003emy name is *\u003c/pattern\u003e\r\n    \u003ctemplate\u003e\r\n        ok , your name is\r\n        \u003cstar/\u003e\r\n        \u003cset type=\"user\" name=\"name\"\u003e\r\n            \u003cstar/\u003e\r\n        \u003c/set\u003e\r\n    \u003c/template\u003e\r\n\u003c/category\u003e\r\n\r\n\u003ccategory\u003e\r\n    \u003cpattern\u003ewhat is my name\u003c/pattern\u003e\r\n    \u003ctemplate\u003e\r\n        oh , your name is\r\n        \u003cget type=\"user\" name=\"name\"/\u003e\r\n        , i remembered it last time ...\r\n    \u003c/template\u003e\r\n\u003c/category\u003e\r\n```\r\n\r\n## 14. about database\r\n\r\n\u003e `log` table is for logging . \r\n\r\n\u003e `property` table is for storing the userInfo and botInfo , it is the memory of the chatbot . set ,get, del, user, bot tags are operating this table .\r\n\r\n\u003e `data` table is for storing the words spoken by user and bot . input , that, topic tags will operate Parser::$_data array and the array will be saved to data table when the program is finishing . then , it will be loaded at the next time users requests the chatbot program . the unique key in data table is userId(ip or the value you send it to chatbot) too.\r\n\r\n\r\n\r\n\r\n# Enjoy it\r\n\r\n![screenshot](./screenshot.jpg)\r\n\r\n---","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatypicalim%2Fchatbot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fatypicalim%2Fchatbot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatypicalim%2Fchatbot/lists"}