Beispiel #1
0
def from_external():
    called = str(request.form["To"])
    caller = str(request.form["Caller"]).replace("client:", "")
    response = twilio.twiml.Response()
    mqtt_log_call(direction="incoming",
                  category="prefilter",
                  from_number=caller,
                  to_number=called)
    # should we reject it? spam?
    reject = is_rejected_number(number=caller)
    if reject is not None:
        mqtt_log_call(direction="incoming",
                      category="rejected",
                      from_number=caller,
                      to_number=called)
        response.reject()
        return twiml(response)

    #    response.say("Thank you for calling, please hold.", voice="alice", language="en-GB")

    # lookup caller id
    callerid = lookup_number(number=caller)
    if callerid is None:
        callerid = caller
    response.dial(callerId=str(callerid).replace(" ", ""),
                  action=url_for('apiv1.from_external_dial_action',
                                 _external=True),
                  method="POST").sip("*****@*****.**")
    mqtt_log_call(direction="incoming",
                  category="ringing",
                  from_number=caller,
                  to_number=called)
    return twiml(response)
Beispiel #2
0
def _redirect_welcome():
    response = twilio.twiml.Response()
    response.say(
        "Returning to the main menu.", voice="alice", language="en-gb")
    response.redirect(url_for("ivr.welcome"))

    return twiml(response)
Beispiel #3
0
def complaint():
    
    response = twilio.twiml.Response()
    _lookup_complaint(response, request.form['Digits'])
    return twiml(response)

    return _redirect_welcome()
Beispiel #4
0
def welcome():
    from_number = request.values.get("From")
    to_number = request.values.get("To")

    p_from = phonenumbers.parse(from_number)

    from_user = User.get_user_from_phone_number(
        str(p_from.country_code), str(p_from.national_number))

    if from_user:
        current_app.logger.info(
            "Incoming call from %s to Staffjoy number %s by user %s" %
            (from_number, to_number, from_user))
    else:
        current_app.logger.info(
            "Incoming call from %s to Staffjoy number %s (unknown user) " %
            (from_number, to_number))

    response = twilio.twiml.Response()
    with response.gather(
            numDigits=1, action=url_for("ivr.menu"), method="POST") as g:
        g.say(
            "Thank you for calling Staffjoy. " + "For sales, press 1. " +
            "For support, press 2. " + "For billing, press 3. " +
            "For corporate matters, press 4.",
            loop=3,
            voice="alice",
            language="en-gb")
    return twiml(response)
Beispiel #5
0
def _sales(response):
    SALES_NUMBER = "+1<phonenumber>"

    response.say(
        "Now connecting you to Staffjoy sales. " +
        "You may also send an email to sales at staffjoy dot com.",
        voice="alice",
        language="en-gb")
    response.dial(SALES_NUMBER)
    return twiml(response)
Beispiel #6
0
def menu():
    selected_option = request.form['Digits']
    option_actions = {'700': _give_instructions}

    if option_actions in (selected_option):
        response = twilio.twiml.Response()
        option_actions[selected_option](response)
        return twiml(response)

    return _redirect_welcome()
Beispiel #7
0
def welcome():
    response = twilio.twiml.Response()
    with response.gather(timeout=30,
                         finishOnKey="#",
                         action=url_for('menu'),
                         method="POST") as g:
        g.say(
            "how much wood would a woodchuck chuck if a woodchuck could chuck wood?  "
            + "Enter your response, followed by the pound key")
    return twiml(response)
Beispiel #8
0
def from_internal():
    called = str(request.form["Called"])
    number = called.split("@")[0].split("sip:")[1]
    (fullnumber, describednumber) = parse_dialed_number(number=number)
    response = twilio.twiml.Response()
    response.say("Calling %s" % (describednumber),
                 voice="alice",
                 language="en-GB")
    response.dial(number=fullnumber, callerId="+441437766027")
    return twiml(response)
def menu():
    selected_option = request.form['Digits']
    option_actions = {'1': _give_instructions,
                      '2': _list_planets}

    if option_actions.has_key(selected_option):
        response = twilio.twiml.Response()
        option_actions[selected_option](response)
        return twiml(response)

    return _redirect_welcome()
Beispiel #10
0
def sms_to():
  selected_option = request.form['Digits']
  option_texts = {'1': "Click2Protect - http://bit.ly/2jOrBnz",
                  '2': "Click2Invest - http://bit.ly/TrjSgf",
                  '3': "Easy Health Plan - http://bit.ly/2j1YpvW"}

  if option_texts.has_key(selected_option):
        response = twilio.twiml.Response()
        _send_sms(response, option_texts[selected_option])
        return twiml(response)

  return _redirect_welcome()
def planets():
    selected_option = request.form['Digits']
    option_actions = {'2': "+12024173378",
                      '3': "+12027336386",
                      "4": "+12027336637"}

    if option_actions.has_key(selected_option):
        response = twilio.twiml.Response()
        response.dial(option_actions[selected_option])
        return twiml(response)

    return _redirect_welcome()
Beispiel #12
0
def _support(response):
    response.say(
        "Staffjoy support operates over email. Please send your question to " +
        "help at staffjoy dot com for prompt help. To see the system " +
        "status, visit status dot staffjoy dot com. You may also find answers to common "
        +
        "questions at help dot staffjoy.com. Thank you for calling Staffjoy. "
        + "Bye!",
        voice="alice",
        language="en-gb")

    response.hangup()
    return twiml(response)
Beispiel #13
0
def planets():
    selected_option = request.form['Digits']
    option_actions = {
        '2': "+12024173378",
        '3': "+12027336386",
        "4": "+12027336637"
    }

    if option_actions in (selected_option):
        response = twilio.twiml.Response()
        response.dial(option_actions[selected_option])
        return twiml(response)

    return _redirect_welcome()
Beispiel #14
0
def menu():
    selected_option = request.form['Digits']
    option_actions = {'1': _check_complaint_status,
                      '2': _record_message,
                      '3': _talk_to_executive,
                      '4': _sms_plans,
                      '5': _download_app}

    if option_actions.has_key(selected_option):
        response = twilio.twiml.Response()
        option_actions[selected_option](response)
        return twiml(response)

    return _redirect_welcome()
Beispiel #15
0
def from_internal():
    called = str(request.form["Called"])
    number = called.split("@")[0].split("sip:")[1]
    (fullnumber, describednumber) = parse_dialed_number(number=number)
    mqtt_log_call(direction="outgoing",
                  category="dialing",
                  from_number="+441437766027",
                  to_number=fullnumber)
    response = twilio.twiml.Response()
    # response.say("Calling %s" % (describednumber), voice="alice", language="en-GB")
    response.dial(number=fullnumber,
                  callerId="+441437766027",
                  action=url_for('apiv1.from_internal_dial_action',
                                 _external=True))
    return twiml(response)
Beispiel #16
0
def menu():
    selected_option = request.form["Digits"]
    option_actions = {
        "1": _sales,
        "2": _support,
        "3": _billing,
        "4": _corporate,
    }

    if selected_option in option_actions:
        response = twilio.twiml.Response()
        option_actions[selected_option](response)
        return twiml(response)

    return _redirect_welcome()
Beispiel #17
0
def _corporate(response):
    CORPORATE_NUMBER = "+1<phonenumber>"  # Phone number
    if _business_open():
        response.say(
            "Now connecting you to Staffjoy corporate.",
            voice="alice",
            language="en-gb")
        response.dial(CORPORATE_NUMBER)
    else:
        response.say(
            "Staffjoy headquarters is currently closed. Please " +
            "email help at Staffjoy dot com for prompt service. " +
            "Thanks for calling Staffjoy - Bye!",
            voice="alice",
            language="en-gb")

        response.hangup()

    return twiml(response)
Beispiel #18
0
def welcome():

    # Experiment

    callerNum = request.form['From']
    print(callerNum)

    # Experiment close

    response = twilio.twiml.Response()
    with response.gather(numDigits=1, action=url_for('menu'), method="POST") as g:
        g.say("Welcome to HDFC Life mate. Your twenty-four-seven Helpline. "+
              "To check status of your complaint, press 1. . "+
              "To send us a voice feedback or complaint, press 2. . "
              "To talk to our executive, press 3. . "+
              "To know more about our plans. press 4.  . "+
              "To get a download link for our app, press 5. . "+
              "   ",
              voice='alice', language="en-US", loop=3)
    return twiml(response)
Beispiel #19
0
def _billing(response):
    BILLING_NUMBER = "+1<phonenumber>"  # Phone number

    if _business_open():
        response.say(
            "Now connecting you to Staffjoy billing.  " +
            "You may also send an email to billing at staffjoy dot com.",
            voice="alice",
            language="en-gb")
        response.dial(BILLING_NUMBER)
    else:
        response.say(
            "The Staffjoy billing office is currently closed. Please email " +
            "billing at Staffjoy dot com for prompt service. " +
            "Thanks for calling Staffjoy - Bye!",
            voice="alice",
            language="en-gb")

        response.hangup()

    return twiml(response)
Beispiel #20
0
def confirm_reservation():
    form = ReservationConfirmationForm()
    sms_response_text = "Sorry, it looks like you don't have any reservations to respond to."

    user = User.query.filter(User.phone_number == form.From.data).first()
    reservation = Reservation.query.filter(
        Reservation.status == "pending" and Reservation.vacation_property.host.id == user.id
    ).first()

    if reservation is not None:

        if "yes" in form.Body.data or "accept" in form.Body.data:
            reservation.confirm()
        else:
            reservation.reject()

        db.session.commit()

        sms_response_text = "You have successfully {0} the reservation".format(reservation.status)
        reservation.notify_guest()

    return twiml(_respond_message(sms_response_text))
Beispiel #21
0
def send_message():
    recording_url = request.values.get("RecordingUrl", None)
    callerNum = request.form['From']

    print(recording_url)

    job_id = post_to_haven(recording_url)

    print("Caller Number : "+callerNum)
    print("Job ID : "+job_id)

    response = twilio.twiml.Response()
    response.say("Thank you. Your response has been duly noted. "+
                  "You will now be redirected to the main menu", voice="alice", language="en-US")

    #text_to_send = getData(job_id)

    #ans = update_dashboard(job_id)

    #ans = sendToBluemix(text_to_send, callerNum)

    response.redirect(url_for('welcome'))
    return twiml(response)
Beispiel #22
0
def from_external():
    caller = str(request.form["Caller"]).replace("client:", "")
    #response = twilio.twiml.Response()
    #response.say("Thank you for calling Claire and Nat, please hold.", voice="alice", language="en-GB")
    #response.dial(callerId=caller).sip("*****@*****.**").sip("*****@*****.**")
    #return twiml(response)

    x = """<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Say language="en-GB" voice="alice">Please hold</Say>
<Dial callerId="TEST" action="https://phones.gorras.hw.esgob.com/v1/call_action/">
    <Sip>[email protected]</Sip>
</Dial>
<Dial callerId="TEST" action="https://phones.gorras.hw.esgob.com/v1/call_action/">
    <Sip>[email protected]</Sip>
</Dial>
</Response>"""
    #resp = Response(x)
    #resp.headers['Content-Type'] = 'text/xml'
    #return resp
    response = twilio.twiml.Response()
    response.say("please hold")
    response.enqueue(name="inbound")
    return twiml(response)
Beispiel #23
0
def status_callback():
    response = twilio.twiml.Response()
    return twiml(response)
def _redirect_welcome():
    response = twilio.twiml.Response()
    response.say("Returning to the main menu", voice="alice", language="en-GB")
    response.redirect(url_for('welcome'))

    return twiml(response)
def welcome():
    response = twilio.twiml.Response()
    with response.gather(numDigits=1, action=url_for('menu'), method="POST") as g:
        g.play(url="http://howtodocs.s3.amazonaws.com/et-phone.mp3", loop=3)
    return twiml(response)
Beispiel #26
0
def from_internal_dial_action():
    response = twilio.twiml.Response()
    return twiml(response)