Send notifications to mobile

Hi! I’m new with Streamlit, I’m wondering if it is possible to use Streamlit to send a notification (I’m using Jupyter notebook, however, it can be used in another tool such as Spyder or Pycharm) to a mobile. The idea is:
1- In JN, I’m running a code where an if-else statement notifies or not a given condition.
2- If the condition is true, I would like to show an alert (with a personalize graphical environment) to a given number of users to their mobile phones. I understand that the users might have the Streamlit app URL in their mobiles (as a Chrome, Firefox, etc. icon) but active.
3- When the user receives the notification with a given information, it should be displayed in their phones.

I don’t know if it is possible with Streamlit (freemium).


Hi @rex_perro, welcome to the Streamlit community!

I’m not sure I understand the use case here, but this doesn’t sound like a Streamlit functionality. If there is a Python package that sends phone notifications, it’s probably possible to do what you are intending (and possibly with a Streamlit GUI), but this isn’t something Streamlit supports out of the box.


Thanks. My idea is when a user enters a Streamlit URL (previously executed in python), receive an event (e.g. a text). For instance, the code below introduces a given background color whether i is odd or even. I would like to:
1- the background is green initially
2- if an event occurs, the background changes to red (and the user can receive a notification if he/she has the browser running in the background).
3- after the event, the square turns green

I also want to use this post to ask how can I clear the previous box color when a new image is triggered, in this case, the images goes one after the other. I want to clear the background at each iteration

import streamlit as st
from PIL import Image
import time
#from streamlit import caching
placeholder = st.empty()
#image ="green.jpg")
for i in range(1, 1000):
    if (i % 2) == 0:
        placeholder = st.empty()
        image ="green.jpg")
        st.image(image, use_column_width=True, output_format="jpg")
        #print("{0} is Even number". format(num))
        placeholder = st.empty()
        image ="red.jpg")
        st.image(image, use_column_width=True, output_format="jpg")
        #print("{0} is Odd number". format(num))


Like I said, if there’s a Python library that does this, it would be separate from Streamlit.

In your code, you are re-using placeholder by defining it inside your if statements, which is probably not what you want. You want to set placeholder to the value of your image using placeholder.image() not st.image

I am not sure about the input side, but you can send the alert to a mobile phone using an email account.

You would need lookup table for the recipients carrier gateway the information can be found at Sending SMS using Python - DEV Community

1 Like