{"action":"created","issue":{"url":"https://api.github.com/repos/home-assistant/home-assistant/issues/5793","repository_url":"https://api.github.com/repos/home-assistant/home-assistant","labels_url":"https://api.github.com/repos/home-assistant/home-assistant/issues/5793/labels{/name}","comments_url":"https://api.github.com/repos/home-assistant/home-assistant/issues/5793/comments","events_url":"https://api.github.com/repos/home-assistant/home-assistant/issues/5793/events","html_url":"https://github.com/home-assistant/home-assistant/pull/5793","id":205994821,"number":5793,"title":"Telegram webhooks","user":{"login":"scipioni","id":3766283,"avatar_url":"https://avatars.githubusercontent.com/u/3766283?v=3","gravatar_id":"","url":"https://api.github.com/users/scipioni","html_url":"https://github.com/scipioni","followers_url":"https://api.github.com/users/scipioni/followers","following_url":"https://api.github.com/users/scipioni/following{/other_user}","gists_url":"https://api.github.com/users/scipioni/gists{/gist_id}","starred_url":"https://api.github.com/users/scipioni/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scipioni/subscriptions","organizations_url":"https://api.github.com/users/scipioni/orgs","repos_url":"https://api.github.com/users/scipioni/repos","events_url":"https://api.github.com/users/scipioni/events{/privacy}","received_events_url":"https://api.github.com/users/scipioni/received_events","type":"User","site_admin":false},"labels":[{"id":527909495,"url":"https://api.github.com/repos/home-assistant/home-assistant/labels/cla-needed","name":"cla-needed","color":"ffff00","default":false},{"id":534390537,"url":"https://api.github.com/repos/home-assistant/home-assistant/labels/component:%20telegram_webhooks","name":"component: telegram_webhooks","color":"ededed","default":false},{"id":526146744,"url":"https://api.github.com/repos/home-assistant/home-assistant/labels/new-platform","name":"new-platform","color":"ededed","default":false},{"id":534390536,"url":"https://api.github.com/repos/home-assistant/home-assistant/labels/platform:%20notify.telegram","name":"platform: notify.telegram","color":"ededed","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2017-02-07T19:48:33Z","updated_at":"2017-02-07T19:48:35Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/home-assistant/home-assistant/pulls/5793","html_url":"https://github.com/home-assistant/home-assistant/pull/5793","diff_url":"https://github.com/home-assistant/home-assistant/pull/5793.diff","patch_url":"https://github.com/home-assistant/home-assistant/pull/5793.patch"},"body":"Telegram webhooks support as described in https://core.telegram.org/bots/webhooks.\r\n\r\nWith new component telegram_webhooks it is possible to send commands to home assistant via telegram bot. It works well with telegram notification: webhooks receive comm\r\nands from user and notify send messages to user. \r\nWebhook responds only to users listed in configuration, in telegram user_id format.\r\n\r\nTo expose webhooks a reverse proxy with https must expose /api/telegram_webhooks url as https://\\<public-host\\>/api/telegram_webhooks (api_url config parameter).\r\nSee below a note about security of this kind of access.\r\n\r\n```yaml\r\n# simpler configuration (manual webhook registration needed)\r\ntelegram_webhooks:\r\n  api_url: https://<PUBLIC_HOST>/api/telegram_webhooks\r\n  user_id:\r\n    user1: USER_ID\r\n    user2: USER_ID\r\n```\r\n```yaml\r\n# automatic configuration with webhooks registration in telegram bot\r\ntelegram_webhooks:\r\n  api_key: ABCDEFGHJKLMNOPQRSTUVXYZ\r\n  api_url: https://<PUBLIC_HOST>/api/telegram_webhooks\r\n  user_id:\r\n    user1: USER_ID\r\n    user2: USER_ID\r\n```\r\n\r\nAutomation example that realize simple test to command/notify interaction\r\n```yaml\r\nalias: 'telegram bot that reply pong to ping'\r\nhide_entity: true\r\ntrigger:                                                                                                                                                         [0/400]\r\n  platform: state\r\n  entity_id: telegram_webhooks.command\r\n  to: '/ping'\r\naction:\r\n  - service: notify.telegram\r\n    data:\r\n      message: 'pong'\r\n```\r\n\r\nThis pull request has also a change to notify/telegram.py to support keyboard display. See an example to display a keyboard on BOT start ...\r\n```yaml\r\nalias: 'telegram bot start'\r\nhide_entity: true\r\ntrigger:\r\n  platform: state\r\n  entity_id: telegram_webhooks.command\r\n  to: '/start'\r\naction:\r\n  - service: notify.telegram\r\n    data:\r\n      message: 'commands'\r\n      data:\r\n        keyboard:\r\n          - '/ping, /alarm'\r\n          - '/siren'\r\n```\r\n\r\n... and an automation to trigger a related command\r\n```yaml\r\nhide_entity: true\r\ntrigger:\r\n  platform: state\r\n  entity_id: telegram_webhooks.command\r\n  to: '/siren'\r\naction:\r\n  - service: homeassistant.turn_on\r\n    entity_id: switch.vision_zm1601eu5_battery_operated_siren_switch_9_0\r\n  - delay: \r\n      seconds: 10\r\n  - service: homeassistant.turn_off\r\n    entity_id: switch.vision_zm1601eu5_battery_operated_siren_switch_9_0\r\n```\r\n\r\n### Note about security\r\n\r\nWeb service /api/telegram_webhooks has to be filtered by reverse proxy in front of home assistant to permit access only from telegram servers.\r\nValid telegram IP addresses are described at https://core.telegram.org/bots/webhooks.\r\nExample nginx configuration:\r\n\r\n```\r\n  location /api/telegram_webhooks {\r\n    proxy_pass http://localhost:8123/api/telegram_webhooks;\r\n    proxy_http_version 1.1;\r\n    proxy_set_header Host $host;\r\n    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\r\n    proxy_set_header Upgrade $http_upgrade;\r\n    proxy_set_header Connection $connection_upgrade;\r\n    allow 149.154.167.197/32;\r\n    allow 149.154.167.198/31;\r\n    allow 149.154.167.200/29;\r\n    allow 149.154.167.208/28;\r\n    allow 149.154.167.224/29;\r\n    allow 149.154.167.232/31;\r\n    deny all;  \r\n    }\r\n```\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/home-assistant/home-assistant/issues/comments/278118967","html_url":"https://github.com/home-assistant/home-assistant/pull/5793#issuecomment-278118967","issue_url":"https://api.github.com/repos/home-assistant/home-assistant/issues/5793","id":278118967,"user":{"login":"homeassistant","id":23041403,"avatar_url":"https://avatars.githubusercontent.com/u/23041403?v=3","gravatar_id":"","url":"https://api.github.com/users/homeassistant","html_url":"https://github.com/homeassistant","followers_url":"https://api.github.com/users/homeassistant/followers","following_url":"https://api.github.com/users/homeassistant/following{/other_user}","gists_url":"https://api.github.com/users/homeassistant/gists{/gist_id}","starred_url":"https://api.github.com/users/homeassistant/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/homeassistant/subscriptions","organizations_url":"https://api.github.com/users/homeassistant/orgs","repos_url":"https://api.github.com/users/homeassistant/repos","events_url":"https://api.github.com/users/homeassistant/events{/privacy}","received_events_url":"https://api.github.com/users/homeassistant/received_events","type":"User","site_admin":false},"created_at":"2017-02-07T19:48:35Z","updated_at":"2017-02-07T19:48:35Z","body":"Hi @scipioni, \n\nIt seems you haven't yet signed a CLA. Please do so [here](https://home-assistant.io/developers/cla_sign_start/?pr=home-assistant&#x2F;home-assistant#5793).\n\nOnce you do that we will be able to review and accept this pull request.\n\nThanks!\n"}}
{"actor":{"display_login":"homeassistant"}}