Skip to content

Instantly share code, notes, and snippets.

@HaQadosch
Created April 10, 2023 06:55
Show Gist options
  • Save HaQadosch/af6a54d3618a5976de7c256887466502 to your computer and use it in GitHub Desktop.
Save HaQadosch/af6a54d3618a5976de7c256887466502 to your computer and use it in GitHub Desktop.

The issue you're experiencing might be caused by the fact that the custom CCP is not receiving the tokens needed to authenticate the agent. It appears that the SAML response is redirected to the default Amazon Connect CCP, and the custom CCP does not receive the required information.

To resolve this issue, you can try the following approach:

  1. Modify your loginUrl to include the custom CCP URL in the RelayState parameter. You should encode the custom CCP URL before appending it to the RelayState parameter. Replace http://127.0.0.0:5500/ccp-v2.html with the actual custom CCP URL when you host it publicly.
  var customCcpUrl = encodeURIComponent("http://127.0.0.0:5500/ccp-v2.html");
  var loginUrl = "https://<domain>.uk.auth0.com/samlp/<app>?RelayState=https://<region>.console.aws.amazon.com/connect/federate/<instanceId>?destination=%2Fconnect%2Fccp-v2&customCcpUrl=" + customCcpUrl;
  1. In the AWS Lambda function that handles the SAML response, check if there is a customCcpUrl query parameter present in the RelayState. If it exists, update the Lambda function to redirect the agent to the custom CCP URL with the appropriate tokens.
import json
import urllib.parse

def lambda_handler(event, context):
  # Your existing Lambda code
  
  # Get the RelayState URL
  relay_state = event.get('RelayState', '')
  relay_state_url = urllib.parse.urlparse(relay_state)
  relay_state_query = urllib.parse.parse_qs(relay_state_url.query)

  # Check if customCcpUrl query parameter is present
  if 'customCcpUrl' in relay_state_query:
      custom_ccp_url = relay_state_query['customCcpUrl'][0]
      
      # Modify the response to redirect to the custom CCP URL with the required tokens
      response = {
          'statusCode': 302,
          'headers': {
              'Location': f'{custom_ccp_url}?token={YOUR_TOKEN}'
          }
      }
      return response

  # Your existing Lambda response

Replace YOUR_TOKEN with the appropriate token or credentials needed for your custom CCP to authenticate the agent.

Please note that this is just an example to guide you, and you should adjust the code according to your specific requirements and implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment