skip to Main Content

I am currently tasked to send realtime data that I stored in firestore to telegram. When I watch online tutorials, I mainly see people using realtime database to send data to telegram instead of firestore. I would like to know, is it possible to send data that is stored in firestore to telegram?

2

Answers


  1. There is nothing in the Firebase APIs that automatically sends data in Firestore to Telegram, but since both have Firestore and Telegram have APIs you can build this functionality yourself.

    A common approach would be to create this as a Cloud Function, which is a piece of code that automatically gets triggered when you write to Firestore (in this case). In that Cloud Function you then take the data from Firestore and call the Telegram API. When I search for this, there are some promising results here.

    Login or Signup to reply.
  2. So, yes you can do it. Here the simple example on Python language.
    Look the all docs here: https://firebase.google.com/docs/firestore/query-data/get-data and
    https://firebase.google.com/docs/firestore/quickstart

    default_app = firebase_admin.initialize_app()
    db = firestore.client()
    users_ref = db.collection(u'users')
    docs = users_ref.stream()
    users=[]
    for doc in docs:
        doc = doc.to_dict()
        a = f'{"Name:", doc.get("name")}'
        users.append(a)
    print(users)
    

    Dont forge to create telegram bot and add code there)

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search