from twilio.rest import Client
import tkinter as tk
from tkinter import messagebox
import random 

otp=random.randint(100,10000)
otp=str(otp)

def verify():
    userentry=y.get()
    if otp==userentry:
         messagebox.showinfo("showinfo","Success...")
    else:
         messagebox.showinfo("showinfo","Error...")
        


def send():
    
    number=x.get()
    client = Client('SSID','Token')
    client.messages.create(from_='your number from twilio website account',to=number, body="Your OTP is " + otp)
    
    messagebox.showinfo("showinfo","OTP Sent...")
    root.destroy()
    
    win=tk.Tk()
    win.geometry("300x200")
    global y
    y=tk.StringVar()
    l1=tk.Label(win,text="Enter OTP: ")
    l1.place(x=10,y=5)
    e1=tk.Entry(win,textvariable=y)
    e1.place(x=10,y=30,height=30,width=250)
    b1=tk.Button(win,text="Verify",fg="white",bg="#fbc531",command=verify)
    b1.place(x=10,y=70)


root = tk.Tk()
root.geometry('300x200')
root.title("OTP Verification")
x=tk.StringVar()
l=tk.Label(root,text="Enter you mobile no.: ")
l.place(x=10,y=5)
e=tk.Entry(root,textvariable=x)
e.place(x=10,y=30,height=30,width=250)
b=tk.Button(root,text="Send OTP",fg="white",bg="##fbc531",command=send)
b.place(x=10,y=70)


root.mainloop()
