{ "info": { "author": "Izhar Firdaus", "author_email": "kagesenshi.87@gmail.com", "bugtrack_url": null, "classifiers": [ "Programming Language :: Python" ], "description": ".. contents::\n\nIntroduction\n============\n\n``koslab.messengerbot`` makes writing \n`Facebook Messenger Bot `_\neasier by providing a framework that handles and abstract \nthe Bots API. It is originally developed using `Morepath `_\nas the web request processor and the default hub implementation is on morepath, but this library should\nwork with any Python web frameworks\n\nExample: Writing An Echo Bot \n=============================\n\nLets install ``koslab.messengerbot``\n\n.. code-block:: bash\n\n pip install koslab.messengerbot\n\nNow lets write our EchoBot in ``echobot.py``\n\n.. code-block:: python\n\n from koslab.messengerbot.bot import BaseMessengerBot\n\n # bot implementation\n class EchoBot(BaseMessengerBot):\n\n GREETING_TEXT = 'Hello!. EchoBot, at your service!'\n STARTUP_MESSAGE = {'text': 'Hi!, lets get started!' }\n\n def message_hook(self, event):\n text = event['message'].get('text', '')\n self.send(recipient=event['sender'], message={'text': text})\n\n\nAnd now lets write a hub config file, ``config.yml``.\n\n.. code-block:: yaml\n\n webhook: webhook\n use_message_queue: false\n message_queue: amqp://guest:guest@localhost:5672//\n hub_verify_token: \n bots:\n - page_id: \n title: EchoBot\n class: echobot:EchoBot\n access_token: \n\n\nStart the bot\n\n.. code-block:: bash\n\n messengerbot_hub config.yml\n\nFinally proceed to follow the `Messenger Platform Getting Started\n`_\nguide to get your bot configured and registered in Facebook.\n\nBot Configuration\n==================\n\n``POSTBACK_HANDLERS``\n Dictionary mapping of payload to name of object method that will handle the \n payload. Default value is:\n\n .. code-block:: python\n\n POSTBACK_HANDLERS = {}\n\n Example:\n\n .. code-block:: python\n \n POSTBACK_HANDLERS = {\n 'mypostback': 'mypostback_hook'\n }\n\n def mypostback_hook(self, event):\n ...\n\n``GREETING_TEXT``\n `Greeting text\n `_ \n for new threads. Default value is:\n\n .. code-block:: python\n\n GREETING_TEXT = 'Hello World!'\n\n``STARTUP_MESSAGE``\n Message object to be sent when **Get Started** menu is clicked. Default value is:\n\n .. code-block:: python\n\n STARTUP_MESSAGE = { 'text' : 'Hello World!' }\n\n``PERSISTENT_MENU``\n `Persistent menu `_ ``call_for_action`` buttons configuration. Default value is:\n\n .. code-block:: python\n\n PERSISTENT_MENU = [{\n 'type': 'postback',\n 'title': 'Get Started',\n 'payload': 'messengerbot.get_started'\n }]\n \n\nBot Hooks\n==========\n\nFollowing are the list of hooks that can be implemented on the bot\n\n``message_hook``\n Handles `Message Received\n `_ \n and `Message Echo\n `_\n event.\n\n``postback_hook``\n Handles `Postback Received\n `_\n event. This hook have a default implementation which triggers methods based\n on payload value. To define the mapping, configure\n ``POSTBACK_HANDLERS`` class variable.\n\n\n``authentication_hook``\n Handles `Authentication\n `_\n event. \n\n``account_linking_hook``\n Handles `Account Linking\n `_\n event.\n\n``message_delivered_hook``\n Handles `Message Delivered\n `_\n event.\n\n``message_read_hook``\n Handles `Message Read\n `_\n event\n\nSend API\n=========\n\n``BaseMessengerBot`` class provide a ``send`` method to send responses to\nFacebook Messenger Bot service. Parameters are:\n\n``recipient``\n Recipient object. Eg: ``{ 'id': '12345678'}``\n\n``message``\n Message object. Refer to `Facebook Send API reference\n `_\n for supported messages\n\n``sender_action``\n Sender actions. Supported values: ``mark_seen``, ``typing_on``,\n ``typing_off``\n\n**Note:** If ``message`` is defined, ``sender_action`` value will be ignored.\n\nA convenience method ``reply`` can also be used to send a response. Parameters\nare:\n\n``event``\n Event object\n\n``message``\n Accepts string, callable or message object. Strings are automatically \n converted into message object. Callable will be called with the event \n object as its parameter.\n\nPostback Payload\n================\n\nPostback values may be a JSON object or a string. In the case of\nPostback in JSON object format, an ``event`` key is required for routing postbacks\nto the right handler by ``postback_hook``. For string postback values, the\nwhole string is treated as the event key.\n\nSession \n========\n\nSession Management is provided through a thin wrapper around `Beaker Cache\n`_. Current conversation\nsession variable may be acquired through ``get_session`` method on\n``BaseMessengerBot`` class. Session object is ``dict``-like and may be treated\nas such.\n\n.. code-block:: python\n\n def message_hook(self, event):\n session = self.get_session(event)\n\nMessenger Bot with AMQP\n========================\n\nAMQP queuing is supported by the hub process. To use this, in ``config.yml``\nsimply set ``use_message_queue`` to ``true`` and configure the transport uri \nto the message queue on ``message_queue`` setting. The queue is implemented using \n`Kombu `_, so you may also use \n`other transports\n`_\nthat are supported by Kombu\n\n.. code-block:: yaml\n\n use_message_queue: true\n message_queue: amqp://guest:guest@localhost:5672//\n\n \nConversation API\n=================\n\n**NOTE:** This is a draft spec. Not yet implemented. Inputs are welcomed.\n\nSpec\n\n.. code-block:: yaml\n\n conversation: myconversation\n steps:\n - message: What is your name?\n type: text\n store: name\n - message: Please share your photo\n type: image-attachment\n store: photo\n - message: Please share your location\n type: location-attachment\n store: location\n - message: \n - type: generic-template\n elements:\n - title: Summary\n subtitle: Summary\n image_url: ${data['photo']['url']}\n buttons: \n - type: postback\n title: Save\n payload: myconversation.save \n\n \n\nContributors\n============\n\nNote: place names and roles of the people who contribute to this package\n in this file, one to a line, like so:\n\n- Mohd Izhar Firdaus Bin Ismail, Original Author\n\nChangelog\n=========\n\n1.0b5 (2016-08-09)\n------------------\n\n- Rearrange priority of event handlers so that quick reply postbacks are \n caught [Izhar Firdaus]\n\n\n1.0b4 (2016-08-08)\n------------------\n\n- Ignore CLI when starting up hub\n [Izhar Firdaus]\n\n\n1.0b3 (2016-08-08)\n------------------\n\n- Ensure that all child processes are killed when parent is terminated.\n [Izhar Firdaus]\n\n\n1.0b2 (2016-07-13)\n------------------\n\n- Bug with page_id mapping. Ensure it is read as string now instead of integer\n [Izhar Firdaus]\n\n\n1.0b1 (2016-07-13)\n------------------\n\n- Initial fully functional bot framework with hub implementation\n [Izhar Firdaus]", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/koslab/koslab.messengerbot/", "keywords": "morepath facebook bot messenger chatbot", "license": "MIT", "maintainer": null, "maintainer_email": null, "name": "koslab.messengerbot", "package_url": "https://pypi.org/project/koslab.messengerbot/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/koslab.messengerbot/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://github.com/koslab/koslab.messengerbot/" }, "release_url": "https://pypi.org/project/koslab.messengerbot/1.0b5/", "requires_dist": null, "requires_python": null, "summary": "Facebook messenger bot framework", "version": "1.0b5" }, "last_serial": 2270571, "releases": { "1.0b1": [ { "comment_text": "", "digests": { "md5": "e19347be72c7fe71198a980a1bf059cd", "sha256": "e6a7f4050f4a843288f822fbe3b90560573671c47dc3e569e09801d7b77e3f91" }, "downloads": -1, "filename": "koslab.messengerbot-1.0b1.tar.gz", "has_sig": false, "md5_digest": "e19347be72c7fe71198a980a1bf059cd", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10049, "upload_time": "2016-07-13T03:45:09", "url": "https://files.pythonhosted.org/packages/aa/c1/cff118e747cd18815a2399629d46e3e83e625b6a0838738841a626a11868/koslab.messengerbot-1.0b1.tar.gz" } ], "1.0b2": [ { "comment_text": "", "digests": { "md5": "ea8f8b20f83aaf24a2315e315c208c99", "sha256": "3358afb213250daedcada24c7917131d4027a890902bfc44ae3486713d157e3c" }, "downloads": -1, "filename": "koslab.messengerbot-1.0b2.tar.gz", "has_sig": false, "md5_digest": "ea8f8b20f83aaf24a2315e315c208c99", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10072, "upload_time": "2016-07-13T04:56:32", "url": "https://files.pythonhosted.org/packages/3a/6c/f156bf0292b4f896141634de0f383162036bdf24ef7d22a098d8b2ee6a01/koslab.messengerbot-1.0b2.tar.gz" } ], "1.0b3": [ { "comment_text": "", "digests": { "md5": "384796bb5626b8dfd875a6cee4a14cfa", "sha256": "4ceeb55ff24700521b946bf6636a6d7db2fec6f89a7e428540b1f11df206958e" }, "downloads": -1, "filename": "koslab.messengerbot-1.0b3.tar.gz", "has_sig": false, "md5_digest": "384796bb5626b8dfd875a6cee4a14cfa", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10327, "upload_time": "2016-08-08T08:51:05", "url": "https://files.pythonhosted.org/packages/da/f9/db79305ef470919541f2fd3ac487b272615bc16f719c12b7dfec61e290b8/koslab.messengerbot-1.0b3.tar.gz" } ], "1.0b4": [ { "comment_text": "", "digests": { "md5": "50fcf7b925aa86d6351e3709792d3ae1", "sha256": "0eb21a0d4a0ee2aa5e77427ef5321632975734f4189e12454ad7e0ce0234c4b8" }, "downloads": -1, "filename": "koslab.messengerbot-1.0b4.tar.gz", "has_sig": false, "md5_digest": "50fcf7b925aa86d6351e3709792d3ae1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10375, "upload_time": "2016-08-08T09:42:32", "url": "https://files.pythonhosted.org/packages/bc/2f/df3626d31290665bb0aef3611a6b6b724cd9562afd7a91d04381c83a82cf/koslab.messengerbot-1.0b4.tar.gz" } ], "1.0b5": [ { "comment_text": "", "digests": { "md5": "790ecb1a2f6aebeba42bc00f1a1a98c7", "sha256": "f17ff64d959a8d9273c706d3af96fa204fd14a3a9e6eca5f7e85c6094c1a4548" }, "downloads": -1, "filename": "koslab.messengerbot-1.0b5.tar.gz", "has_sig": false, "md5_digest": "790ecb1a2f6aebeba42bc00f1a1a98c7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11336, "upload_time": "2016-08-09T05:27:18", "url": "https://files.pythonhosted.org/packages/3b/4d/8b441b72ac39eb3f7657337b088f9429a149b154c5121515590ab3cfcaed/koslab.messengerbot-1.0b5.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "790ecb1a2f6aebeba42bc00f1a1a98c7", "sha256": "f17ff64d959a8d9273c706d3af96fa204fd14a3a9e6eca5f7e85c6094c1a4548" }, "downloads": -1, "filename": "koslab.messengerbot-1.0b5.tar.gz", "has_sig": false, "md5_digest": "790ecb1a2f6aebeba42bc00f1a1a98c7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11336, "upload_time": "2016-08-09T05:27:18", "url": "https://files.pythonhosted.org/packages/3b/4d/8b441b72ac39eb3f7657337b088f9429a149b154c5121515590ab3cfcaed/koslab.messengerbot-1.0b5.tar.gz" } ] }