Last active
December 12, 2019 18:42
-
-
Save craigsdennis/de6c4e66d0b31ab759a189fa6cbab86c to your computer and use it in GitHub Desktop.
Delete all calls and messages from your Twilio logs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import sys | |
# TODO: pip install twilio | |
from twilio.rest import Client | |
# TODO: Set environment variables TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN | |
client = Client() | |
# TODO: Flip this to False to turn off the safety. | |
SAFETY_ON = True | |
answer = input( | |
f"Are you sure you want to delete all calls and messages from your logs for account {os.environ['TWILIO_ACCOUNT_SID']}? (y/N) > ") | |
if answer.lower() != "y": | |
print("Exiting") | |
sys.exit() | |
print("Gathering calls...") | |
for call in client.calls.list(): | |
print(f"Deleting call {call.sid}") | |
if SAFETY_ON: | |
print("SAFETY is on") | |
else: | |
call.delete() | |
print("Gathering messages...") | |
for message in client.messages.list(): | |
print(f"Deleting message {message.sid}") | |
if SAFETY_ON: | |
print("SAFETY is on") | |
else: | |
message.delete() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment