community.general.telegram (8.5.0) — module

Send notifications via telegram

Authors: Artem Feofanov (@tyouxa), Nikolai Lomov (@lomserman)

Install collection

Install with ansible-galaxy collection install community.general:==8.5.0


Add to requirements.yml

  collections:
    - name: community.general
      version: 8.5.0

Description

Send notifications via telegram bot, to a verified group or user.

Also, the user may try to use any other telegram bot API method, if you specify O(api_method) argument.

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.

- name: Send notify to Telegram
  community.general.telegram:
    token: '9999999:XXXXXXXXXXXXXXXXXXXXXXX'
    api_args:
      chat_id: 000000
      parse_mode: "markdown"
      text: "Your precious application has been deployed: https://example.com"
      disable_web_page_preview: true
      disable_notification: true
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Forward message to someone
  community.general.telegram:
    token: '9999999:XXXXXXXXXXXXXXXXXXXXXXX'
    api_method: forwardMessage
    api_args:
      chat_id: 000000
      from_chat_id: 111111
      disable_notification: true
      message_id: '{{ saved_msg_id }}'

Inputs

    
token:
    description:
    - Token identifying your telegram bot.
    required: true
    type: str

api_args:
    description:
    - Any parameters for the method.
    - For reference to default method, V(SendMessage), see U(https://core.telegram.org/bots/api#sendmessage).
    type: dict
    version_added: 2.0.0
    version_added_collection: community.general

api_method:
    default: SendMessage
    description:
    - Bot API method.
    - For reference, see U(https://core.telegram.org/bots/api).
    type: str
    version_added: 2.0.0
    version_added_collection: community.general

Outputs

msg:
  description: The message you attempted to send
  returned: success
  sample: Ansible task finished
  type: str
telegram_error:
  description: Error message gotten from Telegram API
  returned: failure
  sample: 'Bad Request: message text is empty'
  type: str