Firebase Cloud Function using Event for document change AttributeError: ‘Event’ object has no attribute ‘after’

I deployed the following Python Firebase cloud function that’s supposed to be triggered on change to document from Collection Appointments, then send an FCM accordingly to associated user.

# The Cloud Functions for Firebase SDK to create Cloud Functions and set up triggers.
from firebase_functions import firestore_fn, https_fn

# The Firebase Admin SDK to access Cloud Firestore.
from firebase_admin import initialize_app, firestore, messaging
import google.cloud.firestore


app = initialize_app()

db = firestore.client

@firestore_fn.on_document_updated(document="Appointments/{appointmentId}")
def send_appointment_notification(event: firestore_fn.Event[firestore_fn.DocumentSnapshot | None]):
    # Get the updated data after the update operation
    updated_data = event.after.data()

    # Access the status field from the updated data
    status = updated_data.get("status")

    if status in ['Approved', 'Declined']:
        # Get the clientId from the appointment document
        client_id = updated_data.get("clientId")

        # Retrieve user document to get the fcmtoken
        user_ref = db.collection('Users').document(client_id)
        user_doc = user_ref.get()

        if user_doc.exists:
            user_data = user_doc.to_dict()
            if 'fcmToken' in user_data:
                fcmtoken = user_data['fcmToken']

                # Compose notification message
                if status == 'Approved':
                    notification_title = f'Appointment Approved'
                elif status == 'Declined':
                    notification_title = f'Appointment Declined'

                message = messaging.Message(
                    data={
                        'appointmentId': updated_data.get("appointmentId")
                    },
                    notification={
                        'title': notification_title,
                        'body': f'Appointment on {updated_data.get("startDateTime")} has been {status.lower()}'
                    },
                    token=fcmtoken
                )

                # Send the notification
                response = messaging.send(message)
                print('Notification sent successfully:', response)
            else:
                print('No fcmtoken found for the user.')
        else:
            print(f'User document with ID {client_id} does not exist.')

    else:
        print(f'Status {status} is not Approved or Declined.')

I get the following error in my logs when it’s triggered

Traceback (most recent call last):
File “/layers/google.python.pip/pip/lib/python3.12/site-packages/flask/app.py”, line 1473, in wsgi_app
response = self.full_dispatch_request()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/layers/google.python.pip/pip/lib/python3.12/site-packages/flask/app.py”, line 882, in full_dispatch_request
rv = self.handle_user_exception(e)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/layers/google.python.pip/pip/lib/python3.12/site-packages/flask/app.py”, line 880, in full_dispatch_request
rv = self.dispatch_request()
^^^^^^^^^^^^^^^^^^^^^^^
File “/layers/google.python.pip/pip/lib/python3.12/site-packages/flask/app.py”, line 865, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) # type: ignore[no-any-return]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/layers/google.python.pip/pip/lib/python3.12/site-packages/functions_framework/execution_id.py”, line 106, in wrapper
return view_function(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/layers/google.python.pip/pip/lib/python3.12/site-packages/functions_framework/init.py”, line 188, in view_func
function(event)
File “/layers/google.python.pip/pip/lib/python3.12/site-packages/firebase_functions/firestore_fn.py”, line 255, in on_document_updated_wrapped
return _firestore_endpoint_handler(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/layers/google.python.pip/pip/lib/python3.12/site-packages/firebase_functions/firestore_fn.py”, line 176, in _firestore_endpoint_handler
func(database_event)
File “/workspace/main.py”, line 35, in send_appointment_notification
updated_data = event.after.data()
^^^^^^^^^^^
AttributeError: ‘Event’ object has no attribute ‘after’

previously I would use even.data.get(“status”) and I would get

status = event.data.get("status") ^^^^^^^^^^^^^^ AttributeError: 'Change' object has no attribute 'get'

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật