def createACContactChannelAnalyticsSalesforceObject(contactId, recordingPath): pnamespace = os.environ['SF_ADAPTER_NAMESPACE'] if not pnamespace or pnamespace == '-': logger.info("SF_ADAPTER_NAMESPACE is empty") pnamespace = '' else: pnamespace = pnamespace + "__" sfRequest = {'Details': {'Parameters': {}}} sfRequest['Details']['Parameters']['sf_operation'] = 'create' sfRequest['Details']['Parameters'][ 'sf_object'] = pnamespace + 'AC_ContactChannelAnalytics__c' sfRequest['Details']['Parameters'][pnamespace + 'ContactId__c'] = contactId ACContactChannelAnalyticsId = invokeSfAPI(sfRequest)['Id'] logger.info('SF Object Created, with ID: %s' % ACContactChannelAnalyticsId) #add ACContactChannelAnalyticsId to lock file metadata oMetadata = {} oMetadata['ACContactChannelAnalyticsId'] = ACContactChannelAnalyticsId updateLockMetadata(contactId, oMetadata) #attch the call recording file logger.info('Retrieving and attaching call recodring file: %s' % recordingPath) attachFileSaleforceObject('CallRecording.wav', 'audio/wav', 'Call Recording', ACContactChannelAnalyticsId, getBase64fileFromS3(recordingPath)) logger.info('SF Recording Attached') return
def createACContactChannelAnalyticsSalesforceObject(contactId, recordingPath=None): pnamespace = os.environ['SF_ADAPTER_NAMESPACE'] if not pnamespace or pnamespace == '-': logger.info("SF_ADAPTER_NAMESPACE is empty") pnamespace = '' else: pnamespace = pnamespace + "__" sfRequest = {'Details': {'Parameters': {}}} sfRequest['Details']['Parameters']['sf_operation'] = 'create' sfRequest['Details']['Parameters'][ 'sf_object'] = pnamespace + 'AC_ContactChannelAnalytics__c' sfRequest['Details']['Parameters'][pnamespace + 'ContactId__c'] = contactId if recordingPath is not None: sfRequest['Details']['Parameters'][pnamespace + 'RecordingPath__c'] = recordingPath ACContactChannelAnalyticsId = invokeSfAPI(sfRequest)['Id'] logger.info('SF Object Created, with ID: %s' % ACContactChannelAnalyticsId) #add ACContactChannelAnalyticsId to lock file metadata oMetadata = {} oMetadata['ACContactChannelAnalyticsId'] = ACContactChannelAnalyticsId updateLockMetadata(contactId, oMetadata) return
def createACContactChannelAnalyticsSalesforceObject(contactId, recordingPath): pnamespace = os.environ['SF_ADAPTER_NAMESPACE'] if not pnamespace or pnamespace == '-': logger.info("SF_ADAPTER_NAMESPACE is empty") pnamespace = '' else: pnamespace = pnamespace + "__" sfRequest = {'Details': {'Parameters': {}}} sfRequest['Details']['Parameters']['sf_operation'] = 'create' sfRequest['Details']['Parameters'][ 'sf_object'] = pnamespace + 'AC_ContactChannelAnalytics__c' sfRequest['Details']['Parameters'][pnamespace + 'ContactId__c'] = contactId ACContactChannelAnalyticsId = invokeSfAPI(sfRequest)['Id'] logger.info('SF Object Created, with ID: %s' % ACContactChannelAnalyticsId) #add ACContactChannelAnalyticsId to lock file metadata oMetadata = {} oMetadata['ACContactChannelAnalyticsId'] = ACContactChannelAnalyticsId updateLockMetadata(contactId, oMetadata) if get_arg(os.environ, "INVOKE_MUTE_CALL_RECORDING_LAMBDA_ENABLED") == 'true': arn = get_arg(os.environ, "INVOKE_MUTE_CALL_RECORDING_LAMBDA_ARN") input_params = {'contact_id': contactId} logger.info('calling: %s, contactId=%s' % (arn, contactId)) try: client = boto3.client('lambda') response = client.invoke(FunctionName=arn, InvocationType='RequestResponse', Payload=json.dumps(input_params)) logger.info('response: success') except Exception as e: logger.error('exception: %s' % e) return #attch the call recording file logger.info('Retrieving and attaching call recodring file: %s' % recordingPath) attachFileSaleforceObject('CallRecording.wav', 'audio/wav', 'Call Recording', ACContactChannelAnalyticsId, getBase64fileFromS3(recordingPath)) logger.info('SF Recording Attached') return
def createSalesforceObject(contactId, customerTranscripts, agentTranscripts, comprehendResults, mACContactChannelAnalyticsId): pnamespace = os.environ['SF_ADAPTER_NAMESPACE'] if not pnamespace or pnamespace == '-': logger.info("SF_ADAPTER_NAMESPACE is empty") pnamespace = '' else: pnamespace = pnamespace + "__" sfRequest = {'Details': {'Parameters': {}}} if mACContactChannelAnalyticsId is not None: logger.info('SF Object Already Created, with ID: %s' % mACContactChannelAnalyticsId) sfRequest['Details']['Parameters']['sf_operation'] = 'update' sfRequest['Details']['Parameters'][ 'sf_id'] = mACContactChannelAnalyticsId else: sfRequest['Details']['Parameters']['sf_operation'] = 'create' sfRequest['Details']['Parameters'][ 'sf_object'] = pnamespace + 'AC_ContactChannelAnalytics__c' sfRequest['Details']['Parameters'][pnamespace + 'ContactId__c'] = contactId sfRequest['Details']['Parameters'][ pnamespace + 'Sentiment__c'] = comprehendResults[ 'FormattedSentiment'] if 'FormattedSentiment' in comprehendResults else '' sfRequest['Details']['Parameters'][ pnamespace + 'Keywords__c'] = comprehendResults[ 'FormattedKeywords'] if 'FormattedKeywords' in comprehendResults else '' sfRequest['Details']['Parameters'][ pnamespace + 'DominantLanguage__c'] = comprehendResults[ 'FormattedDominantLanguage'] if 'FormattedDominantLanguage' in comprehendResults else '' sfRequest['Details']['Parameters'][ pnamespace + 'NamedEntities__c'] = comprehendResults[ 'FormattedNamedEntities'] if 'FormattedNamedEntities' in comprehendResults else '' ACContactChannelAnalyticsId = mACContactChannelAnalyticsId if mACContactChannelAnalyticsId is not None: logger.info("Updating the SF Object: %s" % sfRequest) invokeSfAPI(sfRequest) else: logger.info('SF Object does not exist, creating a new one: %s' % sfRequest) ACContactChannelAnalyticsId = invokeSfAPI(sfRequest)['Id'] logger.info('SF Object Created, with ID: %s' % ACContactChannelAnalyticsId) if len(customerTranscripts) > 0: logger.info('Attaching SF Transcript - Customer Side') attachFileSaleforceObject( 'CustomerTranscripts.json', 'application/json', 'Call Recording Transcription - Customer Side', ACContactChannelAnalyticsId, getBase64String(customerTranscripts)) logger.info('SF Transcript Attached - Customer Side') if len(agentTranscripts) > 0: logger.info('Attaching SF Transcript - Agent Side') attachFileSaleforceObject('AgentTranscripts.json', 'application/json', 'Call Recording Transcription - Agent Side', ACContactChannelAnalyticsId, getBase64String(agentTranscripts)) logger.info('SF Transcript Attached - Agent Side') if 'FormattedSyntax' in comprehendResults: logger.info('Attaching Comprehend Syntax') attachFileSaleforceObject( 'ComprehendSyntax.json', 'application/json', 'Comprehend Syntax', ACContactChannelAnalyticsId, getBase64String(comprehendResults['FormattedSyntax'])) logger.info('SF Comprehend Syntax Attached')
def createSalesforceObject(contactId, customerTranscripts, agentTranscripts, contactLensConversationCharacteristics, mACContactChannelAnalyticsId): pnamespace = os.environ['SF_ADAPTER_NAMESPACE'] if not pnamespace or pnamespace == '-': logger.info("SF_ADAPTER_NAMESPACE is empty") pnamespace = '' else: pnamespace = pnamespace + "__" sfRequest = {'Details': {'Parameters': {}}} if mACContactChannelAnalyticsId is not None: logger.info('SF Object Already Created, with ID: %s' % mACContactChannelAnalyticsId) sfRequest['Details']['Parameters']['sf_operation'] = 'update' sfRequest['Details']['Parameters'][ 'sf_id'] = mACContactChannelAnalyticsId else: sfRequest['Details']['Parameters']['sf_operation'] = 'create' sfRequest['Details']['Parameters'][ 'sf_object'] = pnamespace + 'AC_ContactChannelAnalytics__c' sfRequest['Details']['Parameters'][pnamespace + 'ContactId__c'] = contactId sfRequest['Details']['Parameters'][ pnamespace + 'ContactLensCustomerSentiment__c'] = contactLensConversationCharacteristics[ 'contactLensCustomerSentiment'] sfRequest['Details']['Parameters'][ pnamespace + 'ContactLensAgentSentiment__c'] = contactLensConversationCharacteristics[ 'contactLensAgentSentiment'] sfRequest['Details']['Parameters'][ pnamespace + 'ContactLensInterruptions__c'] = contactLensConversationCharacteristics[ 'contactLensInterruptions'] sfRequest['Details']['Parameters'][ pnamespace + 'ContactLensNonTalkTime__c'] = contactLensConversationCharacteristics[ 'contactLensNonTalkTime'] sfRequest['Details']['Parameters'][ pnamespace + 'ContactLensTalkSpeedCustomer__c'] = contactLensConversationCharacteristics[ 'contactLensTalkSpeedCustomer'] sfRequest['Details']['Parameters'][ pnamespace + 'ContactLensTalkSpeedAgent__c'] = contactLensConversationCharacteristics[ 'contactLensTalkSpeedAgent'] sfRequest['Details']['Parameters'][ pnamespace + 'ContactLensTalkTimeTotal__c'] = contactLensConversationCharacteristics[ 'contactLensTalkTimeTotal'] sfRequest['Details']['Parameters'][ pnamespace + 'ContactLensTalkTimeCustomer__c'] = contactLensConversationCharacteristics[ 'contactLensTalkTimeCustomer'] sfRequest['Details']['Parameters'][ pnamespace + 'ContactLensTalkTimeAgent__c'] = contactLensConversationCharacteristics[ 'contactLensTalkTimeAgent'] ACContactChannelAnalyticsId = mACContactChannelAnalyticsId if mACContactChannelAnalyticsId is not None: logger.info("Updating the SF Object: %s" % sfRequest) invokeSfAPI(sfRequest) else: logger.info('SF Object does not exist, creating a new one: %s' % sfRequest) ACContactChannelAnalyticsId = invokeSfAPI(sfRequest)['Id'] logger.info('SF Object Created, with ID: %s' % ACContactChannelAnalyticsId) if len(customerTranscripts) > 0: logger.info('Attaching SF Transcript - Customer Side') attachFileSaleforceObject( 'CustomerTranscripts.json', 'application/json', 'Call Recording Transcription - Customer Side', ACContactChannelAnalyticsId, getBase64String(customerTranscripts)) logger.info('SF Transcript Attached - Customer Side') if len(agentTranscripts) > 0: logger.info('Attaching SF Transcript - Agent Side') attachFileSaleforceObject('AgentTranscripts.json', 'application/json', 'Call Recording Transcription - Agent Side', ACContactChannelAnalyticsId, getBase64String(agentTranscripts)) logger.info('SF Transcript Attached - Agent Side')