{ "info": { "author": "shaileshahuja", "author_email": "shailesh.ahuja03@gmail.com", "bugtrack_url": null, "classifiers": [ "Environment :: Other Environment", "Framework :: Django", "Framework :: Django :: 1.10", "Framework :: Django :: 1.11", "Framework :: Django :: 1.8", "Framework :: Django :: 1.9", "Intended Audience :: Developers", "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Topic :: Communications", "Topic :: Communications :: Chat", "Topic :: Software Development", "Topic :: Software Development :: Libraries" ], "description": "django-bot\n==========\nA django library that makes it easier to develop bots with a common interface for messaging platforms (eg. Slack, FB messenger) and natural langauge parsers (eg. api.ai).\n\n.. image:: https://travis-ci.org/shaileshahuja/django-bot.svg?branch=develop\n :target: https://travis-ci.org/shaileshahuja/django-bot\n.. image:: https://badge.fury.io/py/django-bot.svg\n :target: https://pypi.python.org/pypi/django-bot\n\nOverview\n========\nBETA version: Currently django-bot only supports Slack and api.ai. Future plans include supporting more messaging platforms (Facebook Messenger, Telegram, Kik, Google assistant, Cortana, Skype, Alexa), and more natural langauge parsers (AWS Lex, wit.ai).\n\nThis library helps to maintain authenticated users and groups in the database and allows you to respond to any messages as well as initiate conversations with any of those.\n\nRequirements and Installation\n*****************************\n\ndjango-bot for Python works with Python 2.7, 3.4, 3.5, 3.6 and django >= 1.8, and requires ``PyPI`` to install dependencies. The message parsing and delivery is done in the background with the help of celery. It also requires slackclient and apiai python libraries for communication with the external services. \n\n.. code-block:: bash\n\n pip install django-bot\n\nOf course, if you prefer doing things the hard way, by pulling down the source code directly into your project:\n\n.. code-block:: bash\n\n git clone https://github.com/shaileshahuja/django-bot.git\n\nAdd to ``INSTALLED_APPS``\n\n``settings.py``\n\n.. code-block:: python\n\n INSTALLED_APPS = [\n ...\n 'converse',\n # your apps\n ]\n\n # must remove CSRFMiddleware\n MIDDLEWARE = [\n 'django.middleware.security.SecurityMiddleware',\n 'django.contrib.sessions.middleware.SessionMiddleware',\n 'django.middleware.common.CommonMiddleware',\n 'django.contrib.auth.middleware.AuthenticationMiddleware',\n 'django.contrib.messages.middleware.MessageMiddleware',\n 'django.middleware.clickjacking.XFrameOptionsMiddleware',\n ]\n\n # making sure reversing URLs produces https instead of http, required for Slack integration\n SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')\n\nGetting started\n===============\n\nUser model\n**********\n\nFirst, we need to define the model and attributes of every user communicating with the bot.\n\n``models.py``\n\n.. code-block:: python\n\n from converse.models import AbstractUser\n\n class MyUser(AbstractUser):\n credits = models.FloatField(default=0.0)\n\nThis user model is automatically created for each authenticated user. For example, if a slack team is authenticated, ``MyUser`` object will be created for each user in the team. Make sure to define defaults for all fields.\n\nDefault properties available\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\n``org``: The organization this user belongs to.\n\n``messenger``: Returns an implementation of ``converse.messengers.MessengerBase`` object. This messenger object can be used to send messages to the user. It exposes a consistent interface for different platforms.\n\n``email``: The email address of the user, if available\n\n``name``: The name of the user, if available\n\nOrganization model\n******************\n\nYou must also define a model that will be instantiated for each organization that authenticates your bot. Again, remember to define defaults for any custom fields.\n\n``models.py``\n\n.. code-block:: python\n\n from converse.models import AbstractOrganization\n\n class Organization(AbstractOrganization):\n pass\n\nDefault properties available\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\n``users``: A queryset of user objects that belong to this organization\n\n``messenger``: Returns an implementation of ``converse.messengers.MessengerBase`` object. This messenger object can be used to send messages to a group common to all members of the organization. In Slack, if your bot is added, this can send a message to #general,\n\n``name``: The name of the organization, if available\n\nSending messages as the bot\n***************************\n\nBy using ``user.messenger`` or ``org.messenger``, you can get access to an implementation of ``converse.messengers.MessengerBase``, such as ``converse.messengers.SlackMessenger``.\n\nMethods:\n^^^^^^^^\n``send``: To send a plaintext message.\n\n``send_text``: To send a message with quick replies.\n\n``send_image``: To send an image with quick replies.\n\nQuick replies are instant prompts for the user to click and respond. In Slack, they are sent as actions.\n\nExample:\n\n.. code-block:: python\n\n user.messenger.send_text(\"Are you sure?\", quick_replies=[QuickReply(\"yes\"), QuickReply(text=\"Cancel\", value=\"No\")])\n\nClicking on 'yes' will send a request back to your server with query ``QuickReply.value``.\n\nParsers\n*******\n\nParsers are responsible for understanding the intent of the user from the text query, which receives the text to be parsed and the session id. The session id can be used to respond to queries with context.\n``converse.parsers.APIAIParser`` is one such parser that connects to api.ai.\n\nIntegrating with api.ai\n^^^^^^^^^^^^^^^^^^^^^^^\n\n``settings.py``\n\n.. code-block:: python\n\n # right now this is the only supported NLP framework for chatbots\n TEXT_PARSER = 'converse.parsers.APIAIParser'\n API_AI_CLIENT_TOKEN = ''\n\nTo match the actions in api.ai to the actions you write, make sure the name in ``@Executor(action=\"\")`` is the same as the one the 'actions' field in your intent. You can access the slot filling params using ``self.params`` and the conversation context using ``self.contexts``.\n\nImplementing your own parser\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\nIf you don't wish to use api.ai, you can implement your own parser.\n\n``parsers.py``\n\n.. code-block:: python\n\n from converse.parsers import ParserBase, ParserResponse\n\n class MyParser(ParserBase):\n def parse(self, query, session_id):\n # your code\n ...\n response = ParserResponse()\n response.text = ... # this will be sent instantly to the user\n response.action = ... # this action will be called, if slot filling is complete\n response.slot_filling_complete = ... # determines whether the query is complete\n response.params = ... # parameters extracted from 'query'\n response.contexts = ... # context of this conversation\n\n return response\n\nHave a look at the ``ParserResponse`` class for more information.\n\nActions\n*******\n\nActions define a unit of execution that is called in the background using celery. These can be triggered when the user sends a message. The natural language parser will detect the intent of the user, extract parameters and the pass action be to taken back to the calling program. An action should be decorated with ``Executor``, which defines the name of the corresponding action. The decorated object can either be a subclass of ``ActionBase`` and implement the ``execute`` method, or a method can receives user, params and contexts as kwargs.\n\n``actions.py``\n\n.. code-block:: python\n\n from converse.executors import Executor, ActionBase\n from converse.messengers import QuickReply\n\n @Executor(action=\"account.balance\")\n class CreditsAction(ActionBase):\n def execute(self):\n self.user.messenger.send(\"Please wait while we retrieve your details...\")\n # this method is called in the background, so it is safe to make time consuming API requests\n account_type = self.contexts[\"accounts\"][\"type\"]\n date_from = self.params[\"date_from\"]\n\n self.user.messenger.send_text(\"You have ${:.2f} left in your {} account\".format(self.user.credits, account_type),\n quick_replies=[QuickReply(\"buy credits\"), QuickReply(\"redeem gift\")])\n\nWe also need to tell django where the action classes / methods are written.\n\n``settings.py``\n\n.. code-block:: python\n\n ACTION_MODULES = [''] # ['x.actions']\n\nIntegrating with Slack\n**********************\nCopy the credentials from the developer portal to your django application. If this is your first time with a Slack application, please read the documentation from Slack on getting started. You have to give bot permission, create a bot user and subscribe to bot events.\n\n``settings.py``\n\n.. code-block:: python\n\n SLACK_CLIENT_ID = ''\n SLACK_CLIENT_SECRET = ''\n SLACK_VERIFICATION_TOKEN = ''\n\nNext, add this to your django URLs.\n\n``urls.py``\n\n.. code-block:: python\n\n urlpatterns = [\n ...,\n url(r'^converse/', include('converse.urls', namespace='converse'))\n ]\n\nNext, start your server (behind https, try ngrok if in development environment), and add these URLs to your Slack app.\n\nOAuth & Permissions -> Redirect URLs: /converse/slack/oauth\n\nEvent Subscriptions -> Request URL: /converse/slack/webhook\n\nInteractive Messages -> Request URL: /converse/slack/action\n\nAfter these steps, when someone authenticates a Slack team, the Organization and User objects will be created in an async task.", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/shaileshahuja/django-bot", "keywords": "", "license": "GNU General Public License v3.0", "maintainer": "", "maintainer_email": "", "name": "django-bot", "package_url": "https://pypi.org/project/django-bot/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/django-bot/", "project_urls": { "Homepage": "https://github.com/shaileshahuja/django-bot" }, "release_url": "https://pypi.org/project/django-bot/0.2.2/", "requires_dist": null, "requires_python": "", "summary": "A lightweight django framework for bots", "version": "0.2.2" }, "last_serial": 2923881, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "ad421197f6b04ebcbf7faa985bacef2e", "sha256": "450dbca4c4cf27f9fbe981895cfff09af29327c6cfe63f5f515f0dd3e0206576" }, "downloads": -1, "filename": "django_bot-0.0.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "ad421197f6b04ebcbf7faa985bacef2e", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 10535, "upload_time": "2017-05-18T14:17:42", "url": "https://files.pythonhosted.org/packages/24/c6/afc8dc18e7ff20957c243d2d5bd95cfd9ad7272f0925ff0ac8e0b876a983/django_bot-0.0.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "3d0f6f8973aba88e72c2394c2eefef47", "sha256": "68cb624c655b49004183346d781587d9128fe0b80a2a8acb9ac5527d0cd94204" }, "downloads": -1, "filename": "django-bot-0.0.1.tar.gz", "has_sig": false, "md5_digest": "3d0f6f8973aba88e72c2394c2eefef47", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6387, "upload_time": "2017-05-18T14:17:44", "url": "https://files.pythonhosted.org/packages/1e/3d/6ca9c5b0df68c52eaafbd93b09363d6202608b8096ab47a776e5243c126e/django-bot-0.0.1.tar.gz" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "e2a79ca435a481f0463e973dbcd14a11", "sha256": "80e16e06e695557d7cb9a2231d320a34b3fe5f475ba320b71f89a6a7efbd1658" }, "downloads": -1, "filename": "django_bot-0.0.2-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "e2a79ca435a481f0463e973dbcd14a11", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 11554, "upload_time": "2017-05-22T11:04:03", "url": "https://files.pythonhosted.org/packages/22/e2/1ec2e86dd9c4e68132ccbfa0c74e51e94e381cfb1af9bd1a0e9b01f4bc23/django_bot-0.0.2-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "7a674e08fdfca1b3cc3b0749fe02a772", "sha256": "057dfd9838d570e229c61cbb5e7fec655e2c9b061b40f260f5024ccb21bd7539" }, "downloads": -1, "filename": "django-bot-0.0.2.tar.gz", "has_sig": false, "md5_digest": "7a674e08fdfca1b3cc3b0749fe02a772", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 19630, "upload_time": "2017-05-22T10:57:40", "url": "https://files.pythonhosted.org/packages/1d/af/8f3cb3c8eb8f40afa15bb59aa33f4c73091957115e03acb32bada951122c/django-bot-0.0.2.tar.gz" } ], "0.0.3": [ { "comment_text": "", "digests": { "md5": "c404d7a7eb0ce2d15e83a2ba513230cf", "sha256": "a5720d4e09ddee3820778955044a5d067fddcd65710748c530760ebcba7416cc" }, "downloads": -1, "filename": "django_bot-0.0.3-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "c404d7a7eb0ce2d15e83a2ba513230cf", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 11589, "upload_time": "2017-05-22T17:58:22", "url": "https://files.pythonhosted.org/packages/7a/3e/e3fcecb7d0e735ed485365762b4aa2772c161d61f551a2a44824d57edec8/django_bot-0.0.3-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "7c1e930f0aae3b0223d61aa30a23777e", "sha256": "945069a2e17419a9107a2dd1f00ad793e084ed1fb2253a0f45738e8a4201e391" }, "downloads": -1, "filename": "django-bot-0.0.3.tar.gz", "has_sig": false, "md5_digest": "7c1e930f0aae3b0223d61aa30a23777e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 19661, "upload_time": "2017-05-22T17:58:33", "url": "https://files.pythonhosted.org/packages/07/60/3ba8ae3ca4a8aa73e82f7771e9cd7bbcc54825588a9d53eda74edb758a14/django-bot-0.0.3.tar.gz" } ], "0.0.4": [ { "comment_text": "", "digests": { "md5": "81938892398f61eeb6971461f0c07f66", "sha256": "478596b254f240e149811393e2ecd60579e6726e64b97df56005ce4f5582d77c" }, "downloads": -1, "filename": "django_bot-0.0.4-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "81938892398f61eeb6971461f0c07f66", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 11604, "upload_time": "2017-05-22T18:26:37", "url": "https://files.pythonhosted.org/packages/3c/f5/a14dfb8c4d0a9f7088bcaf8f8f3d856fa728a19e09ab8411e868cdedadbb/django_bot-0.0.4-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "c69cf5ab8236cc2b2f9dce554aeba063", "sha256": "b5fcd0930e292eb051ac19ecacf339fae71472c6c8a319d7b3514d1eba4e4ff3" }, "downloads": -1, "filename": "django-bot-0.0.4.tar.gz", "has_sig": false, "md5_digest": "c69cf5ab8236cc2b2f9dce554aeba063", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 19678, "upload_time": "2017-05-22T18:26:26", "url": "https://files.pythonhosted.org/packages/d1/20/741abe817a89603c9e060bbbbbdd0bc1bfa7886aec461e6a998272677129/django-bot-0.0.4.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "63fe4220cd2f6018e3eebf69a0d5d322", "sha256": "f198797d60103af98e6646fea1ec01195ebc2089082056fe137ad975a1ef5cf8" }, "downloads": -1, "filename": "django_bot-0.1.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "63fe4220cd2f6018e3eebf69a0d5d322", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 17936, "upload_time": "2017-05-30T09:40:37", "url": "https://files.pythonhosted.org/packages/38/51/03bc47b7d06238dc7cedfd3719179a9995899d5bb30bbb83fa44622f6fe0/django_bot-0.1.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "ad7ca1cc0690877be7802ef733626dba", "sha256": "660dbc6c961b729dc929cafddee92d5bf7945e0dcc804d4df8ea1c1ab9e97744" }, "downloads": -1, "filename": "django-bot-0.1.1.tar.gz", "has_sig": false, "md5_digest": "ad7ca1cc0690877be7802ef733626dba", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 25450, "upload_time": "2017-05-30T09:40:30", "url": "https://files.pythonhosted.org/packages/cb/d2/1949c300c5e63aa73782e197f2a040c7a213bf104f66d4f140f3166ccd4f/django-bot-0.1.1.tar.gz" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "b748a582aef91b03c63d3fd3b1cac385", "sha256": "e5f75395251a2ea9d86218b9c9d9b3c900fb7eb37cf895a8a434a9df6ca3edc3" }, "downloads": -1, "filename": "django_bot-0.2.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "b748a582aef91b03c63d3fd3b1cac385", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 18824, "upload_time": "2017-06-03T08:40:17", "url": "https://files.pythonhosted.org/packages/34/a2/888a9f12bb474f1dd2c3f1de2e2ff735e73d783a6b6209852333e6b2ff63/django_bot-0.2.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "756277ab78efdaa34c15ae7152a77c62", "sha256": "b084ad91929c2afbbad7888c573ef943f6052853c166e40b86e20cc9040d21a6" }, "downloads": -1, "filename": "django-bot-0.2.1.tar.gz", "has_sig": false, "md5_digest": "756277ab78efdaa34c15ae7152a77c62", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 26383, "upload_time": "2017-06-03T08:40:11", "url": "https://files.pythonhosted.org/packages/52/73/94406b1a12695de7df81aaddf2bd93e3d86737c672a3e61293d3792b8fa8/django-bot-0.2.1.tar.gz" } ], "0.2.2": [ { "comment_text": "", "digests": { "md5": "ca8e1e23580281db4e519e01a512a002", "sha256": "fd14e245516d73c28b6ecc5924cc4293fa85eabbfd882a46fd5185c1edb7038b" }, "downloads": -1, "filename": "django_bot-0.2.2-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "ca8e1e23580281db4e519e01a512a002", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 20205, "upload_time": "2017-06-04T05:02:32", "url": "https://files.pythonhosted.org/packages/73/80/805ae12b64895919fb8a40e18aae61508f365e5973a20692347a92bae765/django_bot-0.2.2-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "545cdcd584d54aed3eaee1d8f297e10e", "sha256": "eb7bf29892fdf8f8899f1086fadc1bdebe0d576aff4da290345d5f2e5a83bde7" }, "downloads": -1, "filename": "django-bot-0.2.2.tar.gz", "has_sig": false, "md5_digest": "545cdcd584d54aed3eaee1d8f297e10e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 27831, "upload_time": "2017-06-04T05:02:15", "url": "https://files.pythonhosted.org/packages/ae/74/0e3242bb588fb3787401752183e2e05d2ee749f4a32b4218ca5f56d6c10f/django-bot-0.2.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "ca8e1e23580281db4e519e01a512a002", "sha256": "fd14e245516d73c28b6ecc5924cc4293fa85eabbfd882a46fd5185c1edb7038b" }, "downloads": -1, "filename": "django_bot-0.2.2-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "ca8e1e23580281db4e519e01a512a002", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 20205, "upload_time": "2017-06-04T05:02:32", "url": "https://files.pythonhosted.org/packages/73/80/805ae12b64895919fb8a40e18aae61508f365e5973a20692347a92bae765/django_bot-0.2.2-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "545cdcd584d54aed3eaee1d8f297e10e", "sha256": "eb7bf29892fdf8f8899f1086fadc1bdebe0d576aff4da290345d5f2e5a83bde7" }, "downloads": -1, "filename": "django-bot-0.2.2.tar.gz", "has_sig": false, "md5_digest": "545cdcd584d54aed3eaee1d8f297e10e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 27831, "upload_time": "2017-06-04T05:02:15", "url": "https://files.pythonhosted.org/packages/ae/74/0e3242bb588fb3787401752183e2e05d2ee749f4a32b4218ca5f56d6c10f/django-bot-0.2.2.tar.gz" } ] }