def postCheckDTMF(message): if DTMFwaitState(message): addLogEntry(voiceProxySettings.APP_NAME_LOGGING, logging_comp_name, 'Entering PostCheckDTMF', message) if 'input' in message: if 'text' in message['input']: if len(message['input']['text']) == 0: return message if 'context' in message: if 'cisDTMF' in message['context']['cisContext']: if 'Error' in message['context']['cisContext']['cisDTMF']: if message['context']['cisContext']['cisDTMF'][ 'Error'] == False: if message['context']['cisContext']['cisDTMF'][ 'captureComplete'] == False: digits = message['context']['cisContext'][ 'cisDTMF'] #addLogEntry(voiceProxySettings.APP_NAME_LOGGING, logging_comp_name, 'DTMF Capture', message) message = setEarlyReturn( message, 'DTMF Capture -> Return to Gateway') return message else: if message['context']['cisContext']['cisDTMF'][ 'Error_Code'] == 3: message = handleDTMFErrorCodeThree(message) addLogEntry(voiceProxySettings.APP_NAME_LOGGING, logging_comp_name, 'DTMF ErrorCode 3', message) message = setEarlyReturn( message, 'DTMF ErrorCode 3 -> Return to Gateway') return message return message
def callConversationService(message): message = preCallConversation(message) if earlyReturn(message): addLogEntry(voiceProxySettings.APP_NAME_LOGGING, logging_comp_name, 'preCallConversation -> Returning to Gateway', message) return message message = callConversation(message) if earlyReturn(message): addLogEntry(voiceProxySettings.APP_NAME_LOGGING, logging_comp_name, 'callConversation -> Returning to Gateway', message) return message # $$$$$$$ message = fromConversation(message) if earlyReturn(message): addLogEntry(voiceProxySettings.APP_NAME_LOGGING, logging_comp_name, 'fromConversation -> Returning to Gateway', message) return message message = postCallConversation(message) if earlyReturn(message): addLogEntry(voiceProxySettings.APP_NAME_LOGGING, logging_comp_name, 'postCallConversation -> Returning to Gateway', message) return message message = checkPollingAfterConversation(message) if earlyReturn(message): addLogEntry(voiceProxySettings.APP_NAME_LOGGING, logging_comp_name, 'checkPollingAfterConversation -> Returning to Gateway', message) return message return message
def callConversation(message): # talk to the conversation Service addLogEntry(voiceProxySettings.APP_NAME_LOGGING, logging_comp_name, "Sent to Conversation", message) message = converse(message) addLogEntry(voiceProxySettings.APP_NAME_LOGGING, logging_comp_name, "Back from Conversation", message) return message
def returningEarlyCleanup(message, logmessage): earlyMsg = voiceProxyUtilities.getCisAttribute('earlyReturnMsg',message) if earlyMsg and len(earlyMsg)>0: weblogger.addLogEntry(voiceProxySettings.APP_NAME_LOGGING, logging_comp_name, earlyMsg, message) message = voiceProxyUtilities.clearCisAttribute('earlyReturn',message) message = voiceProxyUtilities.clearCisAttribute('earlyReturnMsg',message) else: weblogger.addLogEntry(voiceProxySettings.APP_NAME_LOGGING, logging_comp_name, logmessage, message) message = voiceProxyUtilities.clearCisAttribute('earlyReturn',message) message = voiceProxyUtilities.clearCisAttribute('earlyReturnMsg',message) message = outputFilter(message) return message
def fromGatewayFilter(message): if 'context' in message: if 'vgwSessionID' in message['context']: logging.info("API Call -> SessionID: " + message['context']['vgwSessionID']) else: logging.info( 'API Call -> Serious Error, no vgwSessionID in Context') addLogEntry(voiceProxySettings.APP_NAME_LOGGING, logging_comp_name, 'FromGatewayFilter Method', message) logging.debug(message) return message
def checkDTMF(message): if DTMFwaitState(message): addLogEntry(voiceProxySettings.APP_NAME_LOGGING, logging_comp_name, 'Entering checkDTMF', message) dtmf = dtmfCheck(message) message['context']['cisContext']['cisDTMF'] = dtmf if dtmf['Error']: logging.debug("DTMF Error: " + dtmf['Error_Message']) else: # ------ special logic for client ------- if 'connexusID' in message['context'] and len( message['context']['connexusID']) == 0: if dtmf['captureComplete']: logging.debug('Changing text to ConnexusID: ' + dtmf['Words'][0]) message['input']['text'] = dtmf['Words'][0] return message
def fromGatewayFilter(message): if 'context' in message: if 'cgwSessionID' in message['context']: logging.info("API Call -> SessionID: " + message['context']['cgwSessionID']) else: logging.info( 'API Call -> Serious Error, no cgwSessionID in Context') message = check_numbers(message) addLogEntry(voiceProxySettings.APP_NAME_LOGGING, logging_comp_name, 'FromGatewayFilter Method', message) logging.debug(message) # Signal for Conversation Service that messages are coming from Voice Gateway if 'context' in message: message['context']['voiceFlow'] = True return message
def checkGatewaySignal(message): if check_cgwPostResponseTimeout(message): logging.debug("RespTimeout") if inPollingState(message): logging.info("in Polling State with RespTimeout Message") #message = startPolling(message) message = setEarlyReturn( message, 'In Polling State and Gateway Signals ResTimeout -> Returning to Gateway' ) return message if DTMFwaitState(message): logging.info("Timeout while in DTMF WaitState") message = handleDTMFTimeout(message) message = setEarlyReturn( message, 'Gateway Signals RespTimeout in DTMF Waitstate -> Returning to Gateway' ) return message message = setEarlyReturn(message, 'Returning from RespTimeout') return message if check_cgwNoInputTurn(message) and inPollingState(message): logging.info("NoInputTurn") addLogEntry(voiceProxySettings.APP_NAME_LOGGING, logging_comp_name, 'Gateway Signals NoInputTurn and in Polling WaitState', message) time.sleep(pollingTimeLeft(message)) return message if check_cgwHangUp(message): logging.info("Hangup") message = setEarlyReturn( message, 'Gateway Signals Hangup -> Returning to Gateway') return message return message
def callSORBeforeConv(message): message = preCallSystemOfRecordBeforeConversation(message) if earlyReturn(message): addLogEntry( voiceProxySettings.APP_NAME_LOGGING, logging_comp_name, 'preCallSystemOfRecordBeforeConversation -> Returning to Gateway', message) return message message = callSystemOfRecordBeforeConversation(message) if earlyReturn(message): addLogEntry( voiceProxySettings.APP_NAME_LOGGING, logging_comp_name, 'callSystemOfRecordBeforeConversation -> Returning to Gateway', message) return message message = postCallSystemOfRecordBeforeConversation(message) if earlyReturn(message): addLogEntry( voiceProxySettings.APP_NAME_LOGGING, logging_comp_name, 'postCallSystemOfRecordBeforeConversation -> Returning to Gateway', message) return message return message
def voiceGatewayEntry(spaceid,msg): #Get data from post -- should be in the form of a conversation message message = json.loads(request.data) weblogger.addLogEntry(voiceProxySettings.APP_NAME_LOGGING, logging_comp_name, 'New API Call', message) message = inputFilters(message) message = signals(message) message = dtmf(message) message = callConversationService(message) message = wcsSignals(message) message = callSORAfterConv(message) message = outputFilter(message) # Finally Returning to Gateway #weblogger.addLogEntry(voiceProxySettings.APP_NAME_LOGGING, logging_comp_name, 'Normal Return to Gateway', message) return json.dumps(message, separators=(',',':'))
def outputFilter(message): message = preToGatewayFilter(message) if earlyReturn(message): addLogEntry(voiceProxySettings.APP_NAME_LOGGING, logging_comp_name, 'preToGatewayFilter -> Returning to Gateway', message) return message message = toGatewayFilter(message) if earlyReturn(message): addLogEntry(voiceProxySettings.APP_NAME_LOGGING, logging_comp_name, 'toGatewayFilter -> Returning to Gateway', message) return message message = postToGatewayFilter(message) if earlyReturn(message): addLogEntry(voiceProxySettings.APP_NAME_LOGGING, logging_comp_name, 'postToGatewayFilter -> Returning to Gateway', message) return message return message
def utterance(message): message = preCheckUtterance(message) if earlyReturn(message): addLogEntry(voiceProxySettings.APP_NAME_LOGGING, logging_comp_name, 'preCheckUtterance -> Returning to Gateway', message) return message message = checkUtterance(message) if earlyReturn(message): addLogEntry(voiceProxySettings.APP_NAME_LOGGING, logging_comp_name, 'checkUtterance -> Returning to Gateway', message) return message message = postCheckUtterance(message) if earlyReturn(message): addLogEntry(voiceProxySettings.APP_NAME_LOGGING, logging_comp_name, 'postCheckUtterance -> Returning to Gateway', message) return message return message
def pollBackend(message): message = preCheckPollingBackend(message) if earlyReturn(message): addLogEntry(voiceProxySettings.APP_NAME_LOGGING, logging_comp_name, 'preCheckPollingBackend -> Returning to Gateway', message) return message message = checkPollingBackend(message) if earlyReturn(message): addLogEntry(voiceProxySettings.APP_NAME_LOGGING, logging_comp_name, 'checkPollingBackend -> Returning to Gateway', message) return message message = postCheckPollingBackend(message) if earlyReturn(message): addLogEntry(voiceProxySettings.APP_NAME_LOGGING, logging_comp_name, 'postCheckPollingBackend -> Returning to Gateway', message) return message return message
def dtmf(message): if voiceProxySettings.DTMF_ENABLED: message = preCheckDTMF(message) if earlyReturn(message): addLogEntry(voiceProxySettings.APP_NAME_LOGGING, logging_comp_name, 'preCheckDTMF -> Returning to Gateway', message) return message message = checkDTMF(message) if earlyReturn(message): addLogEntry(voiceProxySettings.APP_NAME_LOGGING, logging_comp_name, 'checkDTMF -> Returning to Gateway', message) return message message = postCheckDTMF(message) if earlyReturn(message): addLogEntry(voiceProxySettings.APP_NAME_LOGGING, logging_comp_name, 'postcheckDTMF -> Returning to Gateway', message) return message return message
def wcsSignals(message): message = preCheckConversationSignal(message) if earlyReturn(message): addLogEntry(voiceProxySettings.APP_NAME_LOGGING, logging_comp_name, 'preCheckConversationSignal -> Returning to Gateway', message) return message message = checkConversationSignal(message) if earlyReturn(message): addLogEntry(voiceProxySettings.APP_NAME_LOGGING, logging_comp_name, 'checkConversationSignal -> Returning to Gateway', message) return message message = postCheckConversationSignal(message) if earlyReturn(message): addLogEntry(voiceProxySettings.APP_NAME_LOGGING, logging_comp_name, 'postCheckConversationSignal -> Returning to Gateway', message) return message return message
def voiceGatewayEntry(spaceid, msg): #Get data from post -- should be in the form of a conversation message message = json.loads(request.data) ##### First Check to see if the message passed to the Server is valid format ####### if not checkGatewayMessage(message): # Need to know how to signal the Gateway something is wrong message = returningEarlyCleanup( message, 'Gateway Message Check Failed -> Returning to Gateway') return json.dumps(message, separators=(',', ':')) addLogEntry(voiceProxySettings.APP_NAME_LOGGING, logging_comp_name, 'New API Call', message) message = inputFilters(message) if earlyReturn(message): message = returningEarlyCleanup( message, 'inputFilters -> Returning to Gateway') return json.dumps(message, separators=(',', ':')) message = signals(message) if earlyReturn(message): message = returningEarlyCleanup(message, 'signals -> Returning to Gateway') return json.dumps(message, separators=(',', ':')) message = waitState(message) if earlyReturn(message): message = returningEarlyCleanup(message, 'waitState -> Returning to Gateway') return json.dumps(message, separators=(',', ':')) message = dtmf(message) if earlyReturn(message): message = returningEarlyCleanup(message, 'dtmf -> Returning to Gateway') return json.dumps(message, separators=(',', ':')) message = utterance(message) if earlyReturn(message): message = returningEarlyCleanup(message, 'utterance -> Returning to Gateway') return json.dumps(message, separators=(',', ':')) message = pollBackend(message) if earlyReturn(message): message = returningEarlyCleanup(message, 'pollbackend -> Returning to Gateway') return json.dumps(message, separators=(',', ':')) message = callSORBeforeConv(message) if earlyReturn(message): message = returningEarlyCleanup( message, 'callBackend1 -> Returning to Gateway') return json.dumps(message, separators=(',', ':')) message = callConversationService(message) if earlyReturn(message): message = returningEarlyCleanup( message, 'callConversation -> Returning to Gateway') return json.dumps(message, separators=(',', ':')) message = wcsSignals(message) if earlyReturn(message): message = returningEarlyCleanup( message, 'callWcsSignal -> Returning to Gateway') return json.dumps(message, separators=(',', ':')) message = callSORAfterConv(message) if earlyReturn(message): message = returningEarlyCleanup( message, 'callBackend2 -> Returning to Gateway') return json.dumps(message, separators=(',', ':')) message = outputFilter(message) if earlyReturn(message): message = returningEarlyCleanup( message, 'outputFilters -> Returning to Gateway') return json.dumps(message, separators=(',', ':')) # Finally Returning to Gateway addLogEntry(voiceProxySettings.APP_NAME_LOGGING, logging_comp_name, 'Normal Return to Gateway', message) return json.dumps(message, separators=(',', ':'))