예제 #1
0
def connect_dgf():
    response = VoiceResponse()
    farward_to = ccConfig['settings']['GDF_connection']
    # print(farward_to)
    response.dial(farward_to, action=url_for('quit_call'))
    # print(farward_to)
    return str(response)
예제 #2
0
def lookup_session():

    # Initialize SignalWire Client
    client = signalwire_client(
        os.environ['SIGNALWIRE_PROJECT'],
        os.environ['SIGNALWIRE_TOKEN'],
        signalwire_space_url=os.environ['SIGNALWIRE_SPACE'])

    # Read proxy number from request
    proxy_number = request.values.get("To")

    # Read participant number from request
    leg_1 = request.values.get("From")

    # read proxy sessions from json file
    with open('proxy_sessions.json') as f:
        sessions = json.load(f)

    # Lookup session, find session that has proxy number and participant that matches
    for session in sessions:

        # Lookup the second session participant, if A is calling
        if session["Proxy_Number"] == proxy_number and session[
                "Participant_A_Number"] == leg_1:
            leg_2 = session["Participant_B_Number"]
            found = True
            break

        # Lookup the second session participant, if B is calling
        elif session["Proxy_Number"] == proxy_number and session[
                "Participant_B_Number"] == leg_1:
            leg_2 = session["Participant_A_Number"]
            found = True
            break

        # We did not find anything yet
        found = False

    if found == True:
        # Check if a CallSid exists, if it does, it is a voice call
        if "CallSid" in request.values.keys():
            # Bridge legs voice
            response = VoiceResponse()
            response.dial(leg_2, callerId=proxy_number)
            return str(response)
        # Check if a MessageSid exists, if it does it is a text message
        elif "MessageSid" in request.values.keys():
            # Send a message, with challenge code to phone number provided.
            message = client.messages.create(from_=proxy_number,
                                             body=request.values.get("Body"),
                                             to=leg_2)
            return "200"
    else:
        # No session found
        response = VoiceResponse()
        response.say(
            "We are sorry but your call can not be completed at this time. Good Bye!"
        )
        return str(response)
예제 #3
0
def transfer_call():
    response = VoiceResponse()
    farward_to = ccConfig['settings']['callTransferTo_']
    # print(farward_to)
    response.say("please wait your call is connecting....")
    response.dial(farward_to, action=url_for('quit_call'))
    print(farward_to)
    return str(response)
예제 #4
0
def dial_verify():

    # Initialize VoiceResponse
    response = VoiceResponse()

    if "SpeechResult" in request.values:
        if request.values.get("SpeechResult") == "Yes.":

            # Read the passed in number to dial from the request
            number_to_dial = request.values.get("number_to_dial")

            # Append the gather
            response.dial(number_to_dial)
            return str(response)

    response.say("OK. Thank you for calling goodbye!")
    return str(response)