projects/DynamicContactCenter/dynamic-attribute-routing.yaml [112:157]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
          import os
          import json
          import logging

          """ --- Set logging --- """

          logger = logging.getLogger()
          logger.setLevel(logging.INFO)

          """ --- Set dynamoDB resources --- """

          dynamodb = boto3.resource('dynamodb')

          """ --- Control Functions --- """

          def session_attributes_processor(event,response):

              #Establish a new session parameters var
              new_session_parameters = {}

              #If any exist, write the passed parameters from Connect to the new var
              if event['Details']['Parameters']:
                  for k,v in event['Details']['Parameters'].items():
                      new_session_parameters.update({k : v})

              #If any exist, write the previous session attributes from Connect to the new Var
              if 'sessionAttributes' in event['Details']['Parameters']:
                  new_session_parameters.pop('sessionAttributes')
                  passed_session_attributes = json.loads(event['Details']['Parameters']['sessionAttributes'])
                  for k,v in passed_session_attributes.items():
                      new_session_parameters.update({k : v})

              #Write the current response values to the new var
              for k,v in response.items():
                  new_session_parameters.update({k : v})

              #Create a new session attributes key with everything we have
              new_session_parameters.update({'sessionAttributes': json.dumps(new_session_parameters, )})

              #Return everything back
              return new_session_parameters


          """ --- Main handler --- """

          def lambda_handler(event, context):
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



projects/DynamicContactCenter/dynamic-attribute-routing.yaml [208:253]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
          import os
          import json
          import logging

          """ --- Set logging --- """

          logger = logging.getLogger()
          logger.setLevel(logging.INFO)

          """ --- Set dynamoDB resources --- """

          dynamodb = boto3.resource('dynamodb')


          """ --- Control Functions --- """

          def session_attributes_processor(event,response):

              #Establish a new session parameters var
              new_session_parameters = {}

              #If any exist, write the passed parameters from Connect to the new var
              if event['Details']['Parameters']:
                  for k,v in event['Details']['Parameters'].items():
                      new_session_parameters.update({k : v})

              #If any exist, write the previous session attributes from Connect to the new Var
              if 'sessionAttributes' in event['Details']['Parameters']:
                  new_session_parameters.pop('sessionAttributes')
                  passed_session_attributes = json.loads(event['Details']['Parameters']['sessionAttributes'])
                  for k,v in passed_session_attributes.items():
                      new_session_parameters.update({k : v})

              #Write the current response values to the new var
              for k,v in response.items():
                  new_session_parameters.update({k : v})

              #Create a new session attributes key with everything we have
              new_session_parameters.update({'sessionAttributes': json.dumps(new_session_parameters, )})

              #Return everything back
              return new_session_parameters

          """ --- Main handler --- """

          def lambda_handler(event, context):
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



