{"id":20455342,"url":"https://github.com/alexmhack/django-rasa-bot","last_synced_at":"2025-07-23T14:07:45.773Z","repository":{"id":114089265,"uuid":"151398324","full_name":"Alexmhack/Django-Rasa-Bot","owner":"Alexmhack","description":"Integrating Rasa Core with Django backend and finally using Webchat for chatbot user interface","archived":false,"fork":false,"pushed_at":"2019-10-14T15:40:54.000Z","size":1276,"stargazers_count":34,"open_issues_count":0,"forks_count":25,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-20T09:00:22.718Z","etag":null,"topics":["bot","chatbot","django-backend","django-server","django2","rasa","rasa-core","rasa-nlu","rasa-socketio-layer","rasa-webchat","webchat"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Alexmhack.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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,"zenodo":null}},"created_at":"2018-10-03T10:52:00.000Z","updated_at":"2025-07-12T07:46:21.000Z","dependencies_parsed_at":"2023-06-12T13:15:38.866Z","dependency_job_id":null,"html_url":"https://github.com/Alexmhack/Django-Rasa-Bot","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Alexmhack/Django-Rasa-Bot","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Alexmhack%2FDjango-Rasa-Bot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Alexmhack%2FDjango-Rasa-Bot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Alexmhack%2FDjango-Rasa-Bot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Alexmhack%2FDjango-Rasa-Bot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Alexmhack","download_url":"https://codeload.github.com/Alexmhack/Django-Rasa-Bot/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Alexmhack%2FDjango-Rasa-Bot/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266691580,"owners_count":23969182,"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","status":"online","status_checked_at":"2025-07-23T02:00:09.312Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["bot","chatbot","django-backend","django-server","django2","rasa","rasa-core","rasa-nlu","rasa-socketio-layer","rasa-webchat","webchat"],"created_at":"2024-11-15T11:18:35.712Z","updated_at":"2025-07-23T14:07:45.752Z","avatar_url":"https://github.com/Alexmhack.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"### Chatbot Models are up to date with the current versions of rasa core \u0026 nlu\n\n# Usage\n**Replace the rasachat/models folder with your models folder and run django server and bot.py file seperately**\n\n**The data used to train the chatbot is very minimal, you should replace the rasachat/models folder or extend and improve the training data by updating `rasachat/nlu.nd` \u0026 `rasachat/stories.md` files.**\n\nAlso refer to [Django-Rasa-Sockets](https://github.com/Alexmhack/Django-Rasa-Sockets) for more info on implementing Django and Rasa with Sockets.\n\n# Django-Rasa-Bot\nIntegrating Rasa Core with Django backend and finally using Webchat for chatbot user interface\n\nIn this project we will be using [rasa_core](https://rasa.com/docs/core/quickstart/) \nfor our chatbot backend **django** for website backend and [rasa-webchat](https://github.com/mrbot-ai/rasa-webchat) for chatbot **User Interface**\n\nWe have to first create a Rasa SocketIO Channel Layer\n\nCreate a separate file for this layer in rasachat folder **bot.py**\n```\nfrom rasa_core.agent import Agent\nfrom rasa_core.channels.socketio import SocketIOInput\nfrom rasa_core.agent import Agent\n\n# load your trained agent\nagent = Agent.load('models/dialogue', interpreter='models/current/nlu')\n\ninput_channel = SocketIOInput(\n\t# event name for messages sent from the user\n\tuser_message_evt=\"user_uttered\",\n\t# event name for messages sent from the bot\n\tbot_message_evt=\"bot_uttered\",\n\t# socket.io namespace to use for the messages\n\tnamespace=None\n)\n\n# set serve_forever=False if you want to keep the server running\ns = agent.handle_channels([input_channel], 5500, serve_forever=True)\n```\n\nAbove piece of code comes from Rasa [docs](https://www.rasa.com/docs/core/connectors/#id18)\n\nThen in your html template configure rasa-webchat with following code\n\n```\n\u003cbody\u003e\n\t\u003cdiv id=\"webchat\"\u003e\n\t\t\u003cscript src=\"https://storage.googleapis.com/mrbot-cdn/webchat-latest.js\"\u003e\u003c/script\u003e\n\t\t\u003cscript\u003e\n\t\t    WebChat.default.init({\n\t\t        selector: \"#webchat\",\n\t\t        initPayload: \"/get_started\",\n\t\t        interval: 1000, // 1000 ms between each message\n\t\t        customData: {\"sender\": \"django\"}, // arbitrary custom data. Stay minimal as this will be added to the socket\n\t\t        socketUrl: \"http://localhost:5500/\",\n\t\t        title: \"Connect\",\n\t\t        subtitle: \"The bot which connects people\",\n\t\t        profileAvatar: \"https://rasa.com/assets/img/demo/rasa_avatar.png\",\n\t\t        showCloseButton: true,\n\t\t        fullScreenMode: false\n\t\t    })\n\t\t\u003c/script\u003e\n\t\u003c/div\u003e\n\u003c/body\u003e\n```\n\nThe ```socketUrl``` is the url endpoint that we configured with **rasa socketio layer** and the ```profileAvatar``` is the image that is displayed in bot message\n\nNow run the django server and the socketio server seperately using two terminals,\n\n```\n../Django-Rasa-Bot\u003e python manage.py runserver\n# then in another command prompt or terminal run\n../Django-Rasa-Bot/rasachat\u003e python bot.py\n```\n\nNow open the url [127.0.0.1:8000](http://127.0.0.1:8000) and click on the chat widget placed in bottom right and \nenter ```hi there``` and the bot will reply.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexmhack%2Fdjango-rasa-bot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falexmhack%2Fdjango-rasa-bot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexmhack%2Fdjango-rasa-bot/lists"}