Repository: apache/airflow
Pull request: Fix the AttributeError with text field in TelegramOperator
closes: #13989

Problem statement:
AttributeError: 'TelegramOperator' object has no attribute 'text'
Hi there 👋

I was playing with the **TelegramOperator** and stumbled upon a bug with the `text` field. It is supposed to be a template field but in reality the instance of the **TelegramOperator** does not have this attribute thus every time I try to execute code I get the error:

> AttributeError: 'TelegramOperator' object has no attribute 'text'

```python
TelegramOperator(
        task_id='send_message_telegram',
        telegram_conn_id='telegram_conn_id',
        text='Hello from Airflow!'
    )
```

Hints from issue discussion:

Commit message: Fix the AttributeError with text field 

text now is a template field

Patch to review:
diff --git a/airflow/providers/telegram/operators/telegram.py b/airflow/providers/telegram/operators/telegram.py
index ae01be8434013..d32ed3641c623 100644
--- a/airflow/providers/telegram/operators/telegram.py
+++ b/airflow/providers/telegram/operators/telegram.py
@@ -63,9 +63,10 @@ def __init__(
         self.chat_id = chat_id
         self.token = token
         self.telegram_kwargs = telegram_kwargs or {}
+        self.text = text
 
-        if text is not None:
-            self.telegram_kwargs['text'] = text
+        if self.text is not None:
+            self.telegram_kwargs['text'] = self.text
 
         if telegram_conn_id is None:
             raise AirflowException("No valid Telegram connection id supplied.")


Code review comments:
diff_hunk: @@ -63,9 +63,10 @@ def __init__(
         self.chat_id = chat_id
         self.token = token
         self.telegram_kwargs = telegram_kwargs or {}
+        self.text = text
 
-        if text is not None:
-            self.telegram_kwargs['text'] = text
+        if self.text is not None:
path: airflow/providers/telegram/operators/telegram.py
text: @user1:
Can you add telegram_kwargs to template fields?

diff_hunk: @@ -63,9 +63,10 @@ def __init__(
         self.chat_id = chat_id
         self.token = token
         self.telegram_kwargs = telegram_kwargs or {}
+        self.text = text
 
-        if text is not None:
-            self.telegram_kwargs['text'] = text
+        if self.text is not None:
+            self.telegram_kwargs['text'] = self.text
path: airflow/providers/telegram/operators/telegram.py
text: @user1:
```suggestion
            self.telegram_kwargs['text'] = text
```

diff_hunk: @@ -63,9 +63,10 @@ def __init__(
         self.chat_id = chat_id
         self.token = token
         self.telegram_kwargs = telegram_kwargs or {}
+        self.text = text
 
-        if text is not None:
-            self.telegram_kwargs['text'] = text
+        if self.text is not None:
path: airflow/providers/telegram/operators/telegram.py
text: @user1:
```suggestion
        if text is not None:
```