{"id":20986895,"url":"https://github.com/christippett/hangouts-helper","last_synced_at":"2025-08-22T22:34:35.361Z","repository":{"id":57436689,"uuid":"144011068","full_name":"christippett/hangouts-helper","owner":"christippett","description":"Helpful Python classes for handling and responding to Hangouts Chat bot events","archived":false,"fork":false,"pushed_at":"2019-12-22T00:46:56.000Z","size":33,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-30T18:30:54.608Z","etag":null,"topics":["chatbot","hangouts-chat"],"latest_commit_sha":null,"homepage":"","language":"Python","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/christippett.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":"2018-08-08T12:32:50.000Z","updated_at":"2022-07-28T16:20:01.000Z","dependencies_parsed_at":"2022-09-10T01:51:38.277Z","dependency_job_id":null,"html_url":"https://github.com/christippett/hangouts-helper","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/christippett%2Fhangouts-helper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/christippett%2Fhangouts-helper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/christippett%2Fhangouts-helper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/christippett%2Fhangouts-helper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/christippett","download_url":"https://codeload.github.com/christippett/hangouts-helper/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225303981,"owners_count":17453037,"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":["chatbot","hangouts-chat"],"created_at":"2024-11-19T06:15:17.469Z","updated_at":"2024-11-19T06:15:18.184Z","avatar_url":"https://github.com/christippett.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"Hangouts Chat Helper\n=============================================================\n\n[![PyPI version](https://img.shields.io/pypi/v/hangouts-helper.svg)](https://pypi.python.org/pypi/hangouts-helper)\n[![Build status](https://img.shields.io/travis/christippett/hangouts-helper.svg)](https://travis-ci.org/christippett/hangouts-helper)\n[![Coverage](https://img.shields.io/coveralls/github/christippett/hangouts-helper.svg)](https://coveralls.io/github/christippett/hangouts-helper?branch=master)\n[![Python versions](https://img.shields.io/pypi/pyversions/hangouts-helper.svg)](https://pypi.python.org/pypi/hangouts-helper)\n[![Github license](https://img.shields.io/github/license/christippett/hangouts-helper.svg)](https://github.com/christippett/hangouts-helper)\n\nDescription\n===========\n\nHelper Python classes for handling and responding to Hangouts Chat events.\n\nInstallation\n============\n\nInstall with `pip`:\n\n``` bash\npip install hangouts-helper\n```\n\nMessage Components\n=====\n\nThis library contains several component classes to assist with constructing a Hangouts Chat message.\n- `Message`\n- `Section`\n- `Card`\n- `CardAction`\n- `CardHeader`\n- `TextParagraph`\n- `KeyValue`\n- `Image`\n- `ButtonList`\n- `ImageButton`\n- `TextButton`\n\nExample\n-------\n\nUsing the [**Pizza Bot**](https://developers.google.com/hangouts/chat/reference/message-formats/cards#full_example_pizza_bot) example from the official Hangouts Chat API documentation, this is how you'd construct the same message using the components above.\n\n```python\nfrom hangouts_helper.message import (Message, Card, CardHeader, Section,\n    Image, KeyValue, ButtonList, TextButton)\n\nmessage = Message()\nmessage.add_card(\n    Card(\n        CardHeader(\n            title='Pizza Bot Customer Support',\n            subtitle='pizzabot@example.com',\n            image_url='https://goo.gl/aeDtrS'),\n        Section(\n            KeyValue(top_label='Order No.', content='12345'),\n            KeyValue(top_label='Status', content='In Delivery')),\n        Section(\n            'Location',\n            Image(image_url='https://maps.googleapis.com/...')),\n        Section(\n            ButtonList(\n                TextButton(text='OPEN ORDER').add_link(url='https://example.com/orders/...')))))\n```\n\nCalling `message.output()` produces a `dict` that can be converted to JSON... perfect for returning a response to a synchronous chat event, or sending a new message via the Hangouts Chat API.\n\n```javascript\n{\n    \"cards\": [\n        {\n            \"header\": {\n                \"imageUrl\": \"https://goo.gl/aeDtrS\",\n                \"subtitle\": \"pizzabot@example.com\",\n                \"title\": \"Pizza Bot Customer Support\"\n            },\n            \"sections\": [\n                {\n                    \"widgets\": [\n                        {\n                            \"keyValue\": {\n                                \"content\": \"12345\",\n                                \"topLabel\": \"Order No.\"\n                            }\n                        },\n                        {\n                            \"keyValue\": {\n                                \"content\": \"In Delivery\",\n                                \"topLabel\": \"Status\"\n                            }\n                        }\n                    ]\n                },\n                {\n                    \"header\": \"Location\",\n                    \"widgets\": [\n                        {\n                            \"image\": {\n                                \"imageUrl\": \"https://maps.googleapis.com/...\"\n                            }\n                        }\n                    ]\n                },\n                {\n                    \"widgets\": [\n                        {\n                            \"buttons\": [\n                                {\n                                    \"textButton\": {\n                                        \"onClick\": {\n                                            \"openLink\": {\n                                                \"url\": \"https://example.com/orders/...\"\n                                            }\n                                        },\n                                        \"text\": \"OPEN ORDER\"\n                                    }\n                                }\n                            ]\n                        }\n                    ]\n                }\n            ]\n        }\n    ]\n}\n```\n\nChat Handler\n============\n\nThe library also includes a class to help with handling incoming chat events. The methods contained in `HangoutsChatHandler` correspond to the different event types you can expect to receive. Each method should return a message response.\n\nExample\n-------\n\n```python\nfrom enum import Enum\n\nfrom hangouts_helper.handler import HangoutsChatHandler, SpaceType\nfrom hangouts_helper.message import Message\n\n\nclass ActionMethod(Enum):\n    BUTTON_CLICKED = 'BUTTON_CLICKED'\n\n\nclass MyHangoutsChatHandler(HangoutsChatHandler):\n    ActionMethod = ActionMethod\n\n    def handle_added_to_space(self, space_type, event):\n        if space_type == SpaceType.DM:\n            return Message(text=\"Thanks for DM'ing me!\")\n        elif space_type == SpaceType.ROOM:\n            return Message(text=\"Thanks adding me to your room!\")\n\n    def handle_message(self, message, event):\n        return Message(text=\"Thanks for your message!\")\n\n    def handle_card_clicked(self, action_method, action_parameters, event):\n        if action_method == ActionMethod.BUTTON_CLICKED:\n            return Message(text=\"I've processed your button click!\")\n\n    def handle_removed_from_space(self, event):\n        pass\n\n```\n\nA Flask app that repsonds to Hangouts Chat events might look like:\n\n```python\nfrom flask import Flask, jsonify\napp = Flask(__name__)\n\n@app.route('/')\ndef bot_handler():\n    event = request.json\n    handler = MyHangoutsChatHandler()\n    response_message = handler.handle_event(event)\n    return jsonify(response_message.output())\n\n```\n\nTODO\n====\n- Add examples for each component type in README\n- Document and add examples for adding OnClick events to widgets\n- Document Enums (`SpaceType`, `EventType`, `ActionMethod`, `Icon`, `ImageStyle`, `ResponseType`)\n- Document usage scenarios for `HangoutsChatHandler`\n- Add methods for interacting with Hangouts Chat API to `HangoutsChatHandler`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchristippett%2Fhangouts-helper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchristippett%2Fhangouts-helper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchristippett%2Fhangouts-helper/lists"}