There are 2 ways to deal with this:
Have a redirect action after the get digits action. The redirect action will transfer the flow of your call to another script(could be your default action).
from flask import Flask
app = Flask(__name__)
@app.route('/', methods=["GET", "POST"])
response = '<Response>'
response += '<GetDigits timeout="6" finishOnKey="#">'
response += '<Say> Please enter your account number followed by hash.</Say>'
response += '</GetDigits>'
# If doesn't enter a digit, I will move the flow of the call to my script at default.py(my default response/flow)
response += '<Redirect> https://www.anotherhandler.com/default.py </Redirect>'
response += '</Response>'
# Anything after redirect will not be executed because the API will be handling events from default.py script.
Add a default action after the GetDigits action. (From the example below, "If the user doesn’t enter any digit, the say action after GetDigits will be played).
<GetDigits timeout="30" finishOnKey="#" callbackUrl="http://mycallbackURL.com">
<Say>Please enter your account number followed by the hash sign</Say>
<Say>We did not get your account number. Good bye</Say> </Response>