community.general.telegram – module for sending notifications via telegram
Note
This plugin is part of the community.general collection (version 3.8.3).
You might already have this collection installed if you are using the ansible
package.
It is not included in ansible-core
.
To check whether it is installed, run ansible-galaxy collection list
.
To install it, use: ansible-galaxy collection install community.general
.
To use it in a playbook, specify: community.general.telegram
.
Synopsis
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 api_method argument.
Parameters
Parameter |
Comments |
---|---|
Any parameters for the method. For reference to default method, |
|
(Deprecated) Telegram group or user chat_id. |
|
(Deprecated) What message you wish to send. |
|
(Deprecated) Message format. Formatting options Choices:
|
|
Token identifying your telegram bot. |
Notes
Note
You will require a telegram account and create telegram bot to use this module.
The options msg, msg_format and chat_id have been deprecated and will be removed in community.general 4.0.0. Use the corresponding variables in api_args instead. See the examples for how that works.
Examples
- 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
- 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 }}'
- name: Send a message to chat in playbook (deprecated old style)
community.general.telegram:
token: '9999999:XXXXXXXXXXXXXXXXXXXXXXX'
chat_id: 000000
msg: Ansible task finished
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
---|---|
The message you attempted to send Returned: success Sample: “Ansible task finished” |
|
Error message gotten from Telegram API Returned: failure Sample: “Bad Request: message text is empty” |
Authors
Artem Feofanov (@tyouxa)
Nikolai Lomov (@lomserman)