{"id":24073784,"url":"https://github.com/antonmyronyuk/aioviberbot","last_synced_at":"2025-04-28T16:48:51.609Z","repository":{"id":45185936,"uuid":"431616096","full_name":"antonmyronyuk/aioviberbot","owner":"antonmyronyuk","description":"Viber Python Bot Async API","archived":false,"fork":false,"pushed_at":"2024-08-30T09:07:58.000Z","size":191,"stargazers_count":10,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-11T21:04:29.033Z","etag":null,"topics":["aio-libs","aiohttp","aioviberbot","asyncio","python","python3","viber","viber-api","viber-bot","viber-bot-api","viberbot"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/aioviberbot/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/antonmyronyuk.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-11-24T20:13:40.000Z","updated_at":"2024-11-05T01:48:23.000Z","dependencies_parsed_at":"2023-02-18T23:20:26.704Z","dependency_job_id":null,"html_url":"https://github.com/antonmyronyuk/aioviberbot","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antonmyronyuk%2Faioviberbot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antonmyronyuk%2Faioviberbot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antonmyronyuk%2Faioviberbot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antonmyronyuk%2Faioviberbot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/antonmyronyuk","download_url":"https://codeload.github.com/antonmyronyuk/aioviberbot/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251348529,"owners_count":21575291,"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":["aio-libs","aiohttp","aioviberbot","asyncio","python","python3","viber","viber-api","viber-bot","viber-bot-api","viberbot"],"created_at":"2025-01-09T17:56:49.341Z","updated_at":"2025-04-28T16:48:51.580Z","avatar_url":"https://github.com/antonmyronyuk.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Viber Python Bot Async API\n\nThis is async version of [viberbot](https://github.com/Viber/viber-bot-python) package. Fully compatible with sync package version.\nUse this library to develop a bot for Viber platform.\n\nThe library is available on [GitHub](https://github.com/antonmyronyuk/aioviberbot) as well as a package on [PyPI](https://pypi.org/project/aioviberbot/).\n\nThis package can be imported using pip by adding the following to your `requirements.txt`:\n\n```python\naioviberbot==0.7.0\n```\n\n## License\n\nThis library is released under the terms of the Apache 2.0 license. See [License](https://github.com/antonmyronyuk/aioviberbot/blob/main/LICENSE.md) for more information.\n\n## Library Prerequisites\n\n1. python \u003e= 3.7.0\n1. An Active Viber account on a platform which supports Public Accounts/ bots (iOS/Android). This account will automatically be set as the account administrator during the account creation process.\n1. Active Public Account/bot - Create an account [here](https://partners.viber.com/account/create-bot-account).\n1. Account authentication token - unique account identifier used to validate your account in all API requests. Once your account is created your authentication token will appear in the account’s “edit info” screen (for admins only). Each request posted to Viber by the account will need to contain the token.\n1. Webhook - Please use a server endpoint URL that supports HTTPS. If you deploy on your own custom server, you'll need a trusted (ca.pem) certificate, not self-signed. Read our [blog post](https://developers.viber.com/blog/2017/05/24/test-your-bots-locally) on how to test your bot locally.\n\n## Contributing\n\nIf you think that there's a bug or there's anything else needed to be changed and you want to change it yourself, you can always create a new Pull request.  \nPlease make sure that your change doesn't break anything and all the unit tests passes.  \nAlso, please make sure that the current tests cover your change, if not please add tests.  \n  \nWe are using pytest, so if you want to run the tests from the commandline just follow the relevant steps after cloning the repo and creating your branch:  \n\n\n```\n# installing the dependencies:  \npython setup.py develop\n\n# run the unit tests\npytest tests/\n``` \n\n## Let's get started!\n\n\n### Installing\n\nCreating a basic Viber bot is simple:\n\n1. Install the library with pip `pip install aioviberbot`\n2. Import `aioviberbot.api` library to your project\n3. Create a Public Account or bot and use the API key from [https://developers.viber.com](https://developers.viber.com)\n4. Configure your bot as described in the documentation below\n5. Start your web server\n6. Call `set_webhook(url)` with your web server url\n\n## A simple Echo Bot\n\n### Firstly, let's import and configure our bot\n\n```python\nfrom aioviberbot import Api\nfrom aioviberbot.api.bot_configuration import BotConfiguration\n\nbot_configuration = BotConfiguration(\n    name='PythonSampleBot',\n    avatar='http://viber.com/avatar.jpg',\n    auth_token='YOUR_AUTH_TOKEN_HERE',\n)\nviber = Api(bot_configuration)\n```\n\n### Create an HTTPS server\n\nNext thing you should do is starting a https server.\nand yes, as we said in the prerequisites it has to be https server. Create a server however you like, for example with `aiohttp`:\n\n```python\nfrom aiohttp import web\n\n\nasync def webhook(request: web.Request) -\u003e web.Response:\n    request_data = await request.read()\n    logger.debug('Received request. Post data: %s', request_data)\n    # handle the request here\n    return web.json_response({'ok': True})\n\n\nif __name__ == '__main__':\n    app = web.Application()\n    app.router.add_route('POST', '/webhook', webhook),\n    web.run_app(app)\n```\n\n### Setting a webhook\n\nAfter the server is up and running you can set a webhook.\nViber will push messages sent to this URL. web server should be internet-facing.\n\n```python\nawait viber.set_webhook('https://mybotwebserver.com:443/')\n```\n\n### Logging\n\nThis library uses the standard python logger. If you want to see its logs you can configure the logger:\n\n```python\nlogger = logging.getLogger('aioviberbot')\nlogger.setLevel(logging.DEBUG)\nhandler = logging.StreamHandler()\nformatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')\nhandler.setFormatter(formatter)\nlogger.addHandler(handler)\n```\n\n### Do you supply a basic types of messages?\nWell, funny you ask. Yes we do. All the Message types are located in `aioviberbot.api.messages` package. Here's some examples:\n\n```python\nfrom aioviberbot.api.messages import (\n    TextMessage,\n    ContactMessage,\n    PictureMessage,\n    VideoMessage,\n)\nfrom aioviberbot.api.messages.data_types.contact import Contact\n\n# creation of text message\ntext_message = TextMessage(text='sample text message!')\n\n# creation of contact message\ncontact = Contact(name='Viber user', phone_number='0123456789')\ncontact_message = ContactMessage(contact=contact)\n\n# creation of picture message\npicture_message = PictureMessage(text='Check this', media='http://site.com/img.jpg')\n\n# creation of video message\nvideo_message = VideoMessage(media='http://mediaserver.com/video.mp4', size=4324)\n```\n\nHave you noticed how we created the `TextMessage`? There's all bunch of message types you should get familiar with.\n\n* [Text Message](#TextMessage)\n* [Url Message](#UrlMessage)\n* [Contact Message](#ContactMessage)\n* [Picture Message](#PictureMessage)\n* [Video Message](#VideoMessage)\n* [Location Message](#LocationMessage)\n* [Sticker Message](#StickerMessage)\n* [Rich Media Message](#RichMediaMessage)\n* [Keyboard Message](#KeyboardMessage)\n\nCreating them is easy! Every message object has it's own unique constructor corresponding to it's API implementation, click on them to see it!\nCheck out the full API documentation for more advanced uses.\n\n### Let's add it all up and reply with a message!\n\n```python\nfrom aiohttp import web\n\nfrom aioviberbot import Api\nfrom aioviberbot.api.bot_configuration import BotConfiguration\nfrom aioviberbot.api.messages.text_message import TextMessage\nfrom aioviberbot.api.viber_requests import ViberConversationStartedRequest\nfrom aioviberbot.api.viber_requests import ViberMessageRequest\nfrom aioviberbot.api.viber_requests import ViberSubscribedRequest\n\nviber = Api(BotConfiguration(\n    name='PythonSampleBot',\n    avatar='http://viber.com/avatar.jpg',\n    auth_token='YOUR_AUTH_TOKEN_HERE'\n))\n\n\nasync def webhook(request: web.Request) -\u003e web.Response:\n    request_data = await request.read()\n    signature = request.headers.get('X-Viber-Content-Signature')\n    if not viber.verify_signature(request_data, signature):\n        raise web.HTTPForbidden\n\n    viber_request = viber.parse_request(request_data)\n    if isinstance(viber_request, ViberMessageRequest):\n        # echo message\n        await viber.send_messages(\n            viber_request.sender.id,\n            [viber_request.message],\n        )\n    elif isinstance(viber_request, ViberSubscribedRequest):\n        await viber.send_messages(\n            viber_request.user.id,\n            [TextMessage(text='Thanks for subscribing!')],\n        )\n    elif isinstance(viber_request, ViberConversationStartedRequest):\n        await viber.send_messages(\n            viber_request.user.id,\n            [TextMessage(text='Thanks for starting conversation!')],\n        )\n\n    return web.json_response({'ok': True})\n\n\nasync def set_webhook_signal(app: web.Application):\n    await viber.set_webhook('https://mybotwebserver.com/webhook')\n\n\nif __name__ == '__main__':\n    app = web.Application()\n    app.on_startup.append(set_webhook_signal)\n    app.router.add_route('POST', '/webhook', webhook),\n    web.run_app(app)\n```\n\nAs you can see there's a bunch of `Request` types here's a list of them.\n\n## Viber API\n\n### Api class\n\n`from aioviberbot import Api`\n\n* Api\n    * [init(bot\\_configuration, client\\_session)](#new-Api())\n    * [.set\\_webhook(url, webhook_events)](#set_webhook) ⇒ `List of registered event_types`\n    * [.unset\\_webhook()](#unset_webhook) ⇒ `None`\n    * [.get\\_account_info()](#get_account_info) ⇒ `object`\n    * [.verify\\_signature(request\\_data, signature)](#verify_signature) ⇒ `boolean`\n    * [.parse\\_request(request\\_data)](#parse_request) ⇒ `ViberRequest`\n    * [.send\\_messages(to, messages)](#send_messages) ⇒ `list of message tokens sent`\n    * [.broadcast\\_messages(broadcast\\_list, messages)](#broadcast_messages) ⇒ `list of message tokens sent`\n    * [.get\\_online(viber\\_user\\_ids)](#get_online) ⇒ `dictionary of users status`\n    * [.get\\_user_details(viber\\_user\\_id)](#get_user_details) ⇒ `dictionary of user's data`\n    * [.post\\_messages\\_to\\_public\\_account(to, messages)](#post_to_pa) ⇒ `list of message tokens sent`\n\n\u003ca name=\"new-Api()\"\u003e\u003c/a\u003e\n\n### New Api()\n\n| Param              | Type     | Description                                                                                 |\n|--------------------|----------|---------------------------------------------------------------------------------------------|\n| bot\\_configuration | `object` | `BotConfiguration`                                                                          |\n| client\\_session    | `object` | Optional `aiohttp.ClientSession`, pass if you want to use your own session for api requests |\n\n\u003ca name=\"set_webhook\"\u003e\u003c/a\u003e\n\n### Api.set\\_webhook(url)\n\n| Param | Type | Description |\n| --- | --- | --- |\n| url | `string` | Your web server url |\n| webhook\\_events | `list` | optional list of subscribed events |\n| send\\_name | `bool` | optional should receive the user name |\n| send\\_photo | `bool` | optional should receive the user photo |\n\nReturns `List of registered event_types`. \n\n```python\nevent_types = await viber.set_webhook('https://example.com/webhook')\n```\n\n\u003ca name=\"unset_webhook\"\u003e\u003c/a\u003e\n\n### Api.unset\\_webhook()\n\nReturns `None`. \n\n```python\nawait viber.unset_webhook()\n```\n\n\u003ca name=\"get_account_info\"\u003e\u003c/a\u003e\n\n### Api.get\\_account\\_info()\n\nReturns an `object` [with the following JSON](https://developers.viber.com/docs/api/rest-bot-api/#get-account-info). \n\n```python\naccount_info = await viber.get_account_info()\n```\n\n\u003ca name=\"verify_signature\"\u003e\u003c/a\u003e\n\n### Api.verify\\_signature(request\\_data, signature)\n\n| Param | Type | Description |\n| --- | --- | --- |\n| request\\_data | `string` | the post data from request |\n| signature | `string` | sent as header `X-Viber-Content-Signature` |\n\n\nReturns a `boolean` suggesting if the signature is valid. \n\n```python\nif not viber.verify_signature(await request.read(), request.headers.get('X-Viber-Content-Signature')):\n    raise web.HTTPForbidden\n```\n\n\u003ca name=\"parse_request\"\u003e\u003c/a\u003e\n\n### Api.parse\\_request(request\\_data)\n\n| Param | Type | Description |\n| --- | --- | --- |\n| request\\_data | `string` | the post data from request |\n\nReturns a `ViberRequest` object. \n\nThere's a list of [ViberRequest objects](#ViberRequest)\n\n```python\nviber_request = viber.parse_request(await request.read())\n```\n\n\u003ca name=\"send_messages\"\u003e\u003c/a\u003e\n\n### Api.send\\_messages(to, messages)\n\n| Param | Type | Description |\n| --- | --- | --- |\n| to | `string` | Viber user id |\n| messages | `list` | list of `Message` objects |\n\nReturns `list` of message tokens of the messages sent. \n\n```python\ntokens = await viber.send_messages(\n    to=viber_request.sender.id,\n    messages=[TextMessage(text='sample message')],\n)\n```\n\n\u003ca name=\"broadcast_messages\"\u003e\u003c/a\u003e\n\n### Api.broadcast\\_messages(broadcast_list, messages)\n\n| Param | Type   | Description               |\n| --- |--------|---------------------------|\n| broadcast_list | `list` | list of Viber user ids    |\n| messages | `list` | list of `Message` objects |\n\nReturns `list` of message tokens of the messages sent. \n\n```python\ntokens = await viber.broadcast_messages(\n    broadcast_list=[  \n        \"ABB102akPCRKFaqxWnafEIA==\",\n        \"ABB102akPCRKFaqxWna111==\",\n        \"ABB102akPCRKFaqxWnaf222==\",\n    ],\n    messages=[TextMessage(text='sample message')],\n)\n```\n\n\u003ca name=\"post_to_pa\"\u003e\u003c/a\u003e\n\n### Api.post\\_messages\\_to\\_public\\_account(to, messages)\n\n| Param | Type | Description |\n| --- | --- | --- |\n| sender | `string` | Viber user id |\n| messages | `list` | list of `Message` objects |\n\nReturns `list` of message tokens of the messages sent. \n\n```python\ntokens = await viber.post_messages_to_public_account(\n    sender=viber_request.sender.id,\n    messages=[TextMessage(text='sample message')],\n)\n```\n\n\u003ca name=\"get_online\"\u003e\u003c/a\u003e\n\n### Api.get\\_online(viber\\_user\\_ids)\n\n| Param | Type | Description |\n| --- | --- | --- |\n| viber\\_user\\_ids | `array of strings` | Array of Viber user ids |\n\nReturns a `dictionary of users`.\n\n```python\nusers = await viber.get_online(['user1id', 'user2id'])\n```\n\n\u003ca name=\"get_user_details\"\u003e\u003c/a\u003e\n\n### Api.get\\_user\\_details(viber\\_user\\_id)\n\n| Param | Type | Description |\n| --- | --- | --- |\n| viber\\_user\\_ids | `string` | Viber user id |\n\nThe `get_user_details` function will fetch the details of a specific Viber user based on his unique user ID. The user ID can be obtained from the callbacks sent to the account regarding user's actions. This request can be sent twice during a 12 hours period for each user ID.\n\n```python\nuser_data = await viber.get_user_details('userId')\n```\n\n\u003ca name=\"ViberRequest\"\u003e\u003c/a\u003e\n\n### Request object\n\n| Param | Type | Notes |\n| --- | --- | --- |\n| event\\_type | `string` | according to `EventTypes` enum |\n| timestamp | `long` | Epoch of request time |\n\n* ViberRequest\n    * .event\\_type ⇒ `string `\n    * .timestamp ⇒ `long`\n\n\u003ca name=\"ConversationStarted\"\u003e\u003c/a\u003e\n\n#### ViberConversationStartedRequest object\n\nInherits from [ViberRequest](#ViberRequest)\n\nConversation started event fires when a user opens a conversation with the Public Account/ bot using the “message” button (found on the account’s info screen) or using a [deep link](https://developers.viber.com/docs/tools/deep-links).\n\nThis event is **not** considered a subscribe event and doesn't allow the account to send messages to the user; however, it will allow sending one \"welcome message\" to the user. See [sending a welcome message](#SendingWelcomeMessage) below for more information. \n\n| Param | Type | Notes |\n| --- | --- | --- |\n| event\\_type | `string` | always equals to the value of `EventType.CONVERSATION_STARTED` |\n| message\\_token | `string` | Unique ID of the message |\n| type | `string` | The specific type of `conversation_started` event. |\n| context | `string` | Any additional parameters added to the deep link used to access the conversation passed as a string |\n| user | `UserProfile` | the user started the conversation [UserProfile](#UserProfile) |\n| subscribed | `boolean` | Indicates whether a user is already subscribed |\n\n* ViberConversationStartedRequest\n    * message\\_token ⇒ `string`\n    * type ⇒ `string`\n    * context ⇒ `string`\n    * user ⇒ `UserProfile`\n\n#### ViberDeliveredRequest object\n\nInherits from [ViberRequest](#ViberRequest)\n\n| Param | Type | Notes |\n| --- | --- | --- |\n| event\\_type | `string` | always equals to the value of `EventType.DELIVERED` |\n| message\\_token | `string` | Unique ID of the message |\n| user\\_id | `string` | Unique Viber user id |\n\n* ViberDeliveredRequest\n    * message\\_token ⇒ `string`\n    * user\\_id ⇒ `string`\n\n#### ViberFailedRequest object\n\nInherits from [ViberRequest](#ViberRequest)\n\n| Param | Type | Notes |\n| --- | --- | --- |\n| event\\_type | `string` | always equals to the value of `EventType.FAILED` |\n| message\\_token | `string` | Unique ID of the message |\n| user\\_id | `string` | Unique Viber user id |\n| desc | `string` | Failure description |\n\n* ViberFailedRequest\n    * message\\_token ⇒ `string`\n    * user\\_id ⇒ `string`\n    * desc ⇒ `string`\n\n#### ViberMessageRequest object\n\nInherits from [ViberRequest](#ViberRequest)\n\n| Param | Type | Notes |\n| --- | --- | --- |\n| event\\_type | `string` | always equals to the value of `EventType.MESSAGE` |\n| message\\_token | `string` | Unique ID of the message |\n| message | `Message` | `Message` object |\n| sender | `UserProfile` | the user started the conversation [UserProfile](#UserProfile) |\n\n* ViberMessageRequest\n    * message\\_token ⇒ `string`\n    * message ⇒ `Message`\n    * sender ⇒ `UserProfile`\n\n#### ViberSeenRequest object\n\nInherits from [ViberRequest](#ViberRequest)\n\n| Param | Type | Notes |\n| --- | --- | --- |\n| event\\_type | `string` | always equals to the value of `EventType.SEEN` |\n| message\\_token | `string` | Unique ID of the message |\n| user\\_id | `string` | Unique Viber user id |\n\n* ViberSeenRequest\n    * message\\_token ⇒ `string`\n    * user\\_id ⇒ `string`\n\n#### ViberSubscribedRequest object\n\nInherits from [ViberRequest](#ViberRequest)\n\n| Param | Type | Notes |\n| --- | --- | --- |\n| event\\_type | `string` | always equals to the value of `EventType.SUBSCRIBED` |\n| user | `UserProfile` | the user started the conversation [UserProfile](#UserProfile) |\n\n* ViberSubscribedRequest\n    * user ⇒ `UserProfile`\n\n#### ViberUnsubscribedRequest object\n\nInherits from [ViberRequest](#ViberRequest)\n\n| Param | Type | Notes |\n| --- | --- | --- |\n| event\\_type | `string` | always equals to the value of `EventType.UNSUBSCRIBED` |\n| user\\_id | `string` | Unique Viber user id |\n\n* ViberUnsubscribedRequest\n    * get\\_user\\_id() ⇒ `string`\n\n\u003ca name=\"UserProfile\"\u003e\u003c/a\u003e\n\n### UserProfile object\n\n| Param | Type | Notes |\n| --- | --- | --- |\n| id | `string` | --- |\n| name | `string` | --- |\n| avatar | `string` | Avatar URL |\n| country | `string` | **currently set in `CONVERSATION_STARTED` event only** |\n| language | `string` | **currently set in `CONVERSATION_STARTED` event only** |\n\n\u003ca name=\"MessageObject\"\u003e\u003c/a\u003e\n\n### Message Object\n\n**Common Members for `Message` interface**:\n\n| Param | Type | Description |\n| --- | --- | --- |\n| timestamp | `long` | Epoch time |\n| keyboard | `JSON` | keyboard JSON |\n| trackingData | `JSON` | JSON Tracking Data from Viber Client |\n\n**Common Constructor Arguments `Message` interface**:\n\n| Param | Type | Description |\n| --- | --- | --- |\n| optionalKeyboard | `JSON` | [Writing Custom Keyboards](https://developers.viber.com/docs/tools/keyboards) |\n| optionalTrackingData | `JSON` | Data to be saved on Viber Client device, and sent back each time message is received |\n\n\u003ca name=\"TextMessage\"\u003e\u003c/a\u003e\n\n#### TextMessage object\n\n| Member | Type\n| --- | --- |\n| text | `string` |\n\n```python\nmessage = TextMessage(text='my text message')\n```\n\n\u003ca name=\"UrlMessage\"\u003e\u003c/a\u003e\n\n#### URLMessage object\n\n| Member | Type | Description |\n| --- | --- | --- |\n| media | `string` | URL string |\n\n```python\nmessage = URLMessage(media='http://my.siteurl.com')\n```\n\n\u003ca name=\"ContactMessage\"\u003e\u003c/a\u003e\n\n#### ContactMessage object\n\n| Member | Type\n| --- | --- |\n| contact | `Contact` |\n\n```python\nfrom aioviberbot.api.messages.data_types.contact import Contact\n\ncontact = Contact(name='Viber user', phone_number='+0015648979', avatar='http://link.to.avatar')\ncontact_message = ContactMessage(contact=contact)\n```\n\n\u003ca name=\"PictureMessage\"\u003e\u003c/a\u003e\n\n#### PictureMessage object\n\n| Member | Type | Description |\n| --- | --- | --- |\n| media | `string` | url of the message (jpeg only) |\n| text | `string` |  |\n| thumbnail | `string` |  |\n\n```python\nmessage = PictureMessage(media='http://www.thehindubusinessline.com/multimedia/dynamic/01458/viber_logo_JPG_1458024f.jpg', text='Viber logo')\n```\n\n\u003ca name=\"VideoMessage\"\u003e\u003c/a\u003e\n\n#### VideoMessage object\n\n| Member | Type | Description |\n| --- | --- | --- |\n| media | `string` | url of the video |\n| size | `int` |  |\n| thumbnail | `string` |  |\n| duration | `int` |  |\n\n```python\nmessage = VideoMessage(media='http://site.com/video.mp4', size=21499)\n```\n\n\u003ca name=\"LocationMessage\"\u003e\u003c/a\u003e\n\n#### LocationMessage object\n\n| Member | Type\n| --- | --- |\n| location | `Location` |\n\n```python\nfrom aioviberbot.api.messages.data_types.location import Location\n\nlocation = Location(lat=0.0, lon=0.0)\nlocation_message = LocationMessage(location=location)\n```\n\n\u003ca name=\"StickerMessage\"\u003e\u003c/a\u003e\n\n#### StickerMessage object\n\n| Member | Type\n| --- | --- |\n| sticker\\_id | `int` |\n\n```python\nmessage = StickerMessage(sticker_id=40100)\n```\n\n\u003ca name=\"FileMessage\"\u003e\u003c/a\u003e\n\n#### FileMessage object\n\n| Member | Type\n| --- | --- |\n| media | `string` |\n| size | `long` |\n| file\\_name | `string` |\n\n```python\nmessage = FileMessage(media=url, size=size_in_bytes, file_name=file_name)\n```\n\n\u003ca name=\"RichMediaMessage\"\u003e\u003c/a\u003e\n\n#### RichMediaMessage object\n\n| Member | Type\n| --- | --- |\n| rich\\_media | `string` (JSON) |\n\n```python\nSAMPLE_RICH_MEDIA = \"\"\"{\n  \"BgColor\": \"#69C48A\",\n  \"Buttons\": [\n    {\n      \"Columns\": 6,\n      \"Rows\": 1,\n      \"BgColor\": \"#454545\",\n      \"BgMediaType\": \"gif\",\n      \"BgMedia\": \"http://www.url.by/test.gif\",\n      \"BgLoop\": true,\n      \"ActionType\": \"open-url\",\n      \"Silent\": true,\n      \"ActionBody\": \"www.tut.by\",\n      \"Image\": \"www.tut.by/img.jpg\",\n      \"TextVAlign\": \"middle\",\n      \"TextHAlign\": \"left\",\n      \"Text\": \"\u003cb\u003eexample\u003c/b\u003e button\",\n      \"TextOpacity\": 10,\n      \"TextSize\": \"regular\"\n    }\n  ]\n}\"\"\"\n\nSAMPLE_ALT_TEXT = 'upgrade now!'\n\nmessage = RichMediaMessage(rich_media=SAMPLE_RICH_MEDIA, alt_text=SAMPLE_ALT_TEXT)\n```\n\n\u003ca name=\"KeyboardMessage\"\u003e\u003c/a\u003e\n\n#### KeyboardMessage object\n\n| Member | Type\n| --- | --- |\n| keyboard | `JSON` |\n| tracking_data | `JSON` |\n\n```python\nmessage = KeyboardMessage(tracking_data=tracking_data, keyboard=keyboard)\n```\n\n\u003ca name=\"SendingWelcomeMessage\"\u003e\u003c/a\u003e\n\n### Sending a welcome message\n\nThe Viber API allows sending messages to users only after they subscribe to the account. However, Viber will allow the account to send one “welcome message” to a user as the user opens the conversation, before the user subscribes.\n\nThe welcome message will be sent as a response to a `conversation_started` callback, which will be received from Viber once the user opens the conversation with the account. To learn more about this event and when is it triggered see [`Conversation started`](#ConversationStarted) in the callbacks section.\n\n#### Welcome message flow\n\nSending a welcome message will be done according to the following flow:\n\n1. User opens 1-on-1 conversation with account.\n2. Viber server send `conversation_started` even to PA’s webhook.\n3. The account receives the `conversation_started` and responds with an HTTP response which includes the welcome message as the response body.\n\nThe welcome message will be a JSON constructed according to the send_message requests structure, but without the `receiver` parameter. An example welcome message would look like this:\n\n```python\nasync def webhook(request: web.Request) -\u003e web.Response:\n    request_data = await request.read()\n    viber_request = viber.parse_request(request_data)\n\n    if isinstance(viber_request, ViberConversationStartedRequest):\n        await viber.send_messages(\n            viber_request.user.id,\n            [TextMessage(text='Welcome!')],\n        )\n\n    return web.json_response({'ok': True})\n```\n\n## Community\n\nJoin the conversation on **[Gitter](https://gitter.im/viber/bot-python)**.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantonmyronyuk%2Faioviberbot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fantonmyronyuk%2Faioviberbot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantonmyronyuk%2Faioviberbot/lists"}