- AWS Environment
- Active AWS Account with appropriate access
- AWS CLI installed and configured
- AWS CDK CLI installed
- Target region access and permissions
- Amazon Connect
- Active Amazon Connect instance
- Configured Connect queue
- Connect administrator access
- Salesforce
- Salesforce org with API access
- Knowledge base implementation
- Appropriate Salesforce access
- Connected App setup permissions - https://help.salesforce.com/articleView?id=connected_app_overview.htm
- AppFlow
- Salesforce Connector for AppFlow - https://docs.aws.amazon.com/appflow/latest/userguide/salesforce.html#salesforce-setup
- Development Environment
- Python 3.x
- Git
- Code editor
- AWS CDK development experience
- Security Access
- Appropriate IAM permissions
- Appropriate Salesforce access
- Amazon AppFlow Service access
{
"account": "Your-AWS-Account-ID",
"region": "Your-Target-Region",
"env_name": "Environment-Name"
}
{
"connect": {
"instance_id": "Your-Connect-Instance-ID",
"queue_id": "Your-Connect-Queue-ID"
}
}
* Create AppFlow connection
* Required permissions for Salesforce:
a. Knowledge object read access
b. API access enabled
c. OAuth scopes configured
* Define your Lines of Business (LOBs)
"LOBs": [
"LOB1",
"LOB2",
"LOB3"
]
* Map required fields:
"businessUnitFilters": {
"YourLOB1": {
"field": "Your-Classification-Field",
"value": "LOB1-Value"
}
// Add more LOBs as needed
}
{
"connection_name": "dev-sf-connection", // Replace with your AppFlow connection name
"object_name": "Knowledge__kav",
}
"projections": [
// System Required Fields
{"field": "Id", "data_type": "id"},
{"field": "LastModifiedDate", "data_type": "datetime"},
{"field": "ArticleNumber", "data_type": "string"},
{"field": "PublishStatus", "data_type": "picklist"},
{"field": "UrlName", "data_type": "string"}
// Custom Fields - Replace with your actual fields
{"field": "Your-Title-Field", "data_type": "string"},
{"field": "Your-Content-Field", "data_type": "textarea"},
// Add additional fields as needed
]
"filters": [
{
"field": "PublishStatus",
"operator": "EQUAL_TO",
"values": ["Online", "Archived"]
}
// Add additional filters as needed
]
"validations": [
{
"field": "Your-Content-Field", // Replace with your content field. Must be in the list of Projections above
"operator": "VALIDATE_NON_NULL",
"action": "DropRecord"
}
// Add additional validations as needed
]
- The connection_name must match your Amazon AppFlow-Salesforce connection name exactly
- The object_name should be Knowledge__kav
- Ensure the AppFlow connection has proper permissions to access the specified object
- Test connection and object access before deployment
- Document any custom object names or connection names used
- Keep configuration consistent across environments
- Validate object permissions and field accessibility
# Clone the repository
git clone <repository-url>
cd <project folder>
pip install -r requirements.txt
pip install -r requirements-dev.txt
If this is your first time using CDK in this account/region:
cdk bootstrap aws://ACCOUNT-NUMBER/REGION
cdk diff
cdk deploy
The deployment will create the following resources:
- Amazon AppFlow flow for Salesforce integration
- Lambda functions for data processing
- IAM roles and policies
- Amazon Q knowledge bases
- Amazon Connect integration components
After deployment completes:
- Check AWS CloudFormation console for stack status
- Verify AppFlow flow creation
- Confirm Lambda functions deployment
- Check Amazon Q knowledge bases setup
- Validate Amazon Connect integration
-
Run the AppFlows
- Sign in the AWS Management Console and open the Amazon AppFlow console at https://console.aws.amazon.com/appflow/
- In the navigation pane on the left, choose Flows. The console shows the Flows page. This page contains a table that summarizes the flows that are created.
- To initiate a flow, you activate or run it. We have 2 types of flows created: OnDemand and Scheduled
- For each LOB, Select the OnDemand flow and choose View Details.
- Choose Run flow to run the flow.

- For each LOB, Select the Scheduled flow and choose View Details
- Choose Activate to activate the flow

-
Review and update the Amazon Connect contact flow
- Log in to your Amazon Connect instance
- Under Routing, choose Contact Flows.
- Choose the flow named: qic-sf-contact-flow
- Navigate to the Get customer input Block
- Update the Prompts to include your BUs or LOBs
- Update the Set contact attributes block for each options. The LOB attribute is mandatory, and the value should be the same as the ones provided in the CDK configuration at the time of deployment

- Click Save to save the flow
- Click Publish to publish the flow
-
Verify the AppFlow flow status.
- Trigger the OnDemand Flow first - to retrieve the existing knowledge content from Salesforce
- Start the Scheduled Flow - to periodically poll Salesforce Knowledge too import any additions/updates to the Salesforce Knowledge.
-
Verify target s3 buckets for Salesforce data synchronization
-
Monitor CloudWatch logs
- AppFlow Connection Issues
- Verify connection_name in config
- Check Salesforce credentials
- Validate OAuth token
- Permission Errors
- Review IAM roles
- Verify Salesforce API access
- Knowledge Base Sync Issues
- Validate object_name configuration
- Check field mappings
To avoid incurring future charges, delete the resources using following steps:
- Ensure to unmap the Contact Flow created by the deployment from the phone number.
- In your terminal, ensure you are in the project folder
- Run command: cdk destroy