Pre-requisites:
1. Install OpenSSL to generate certificate.
2. Run the below command from MS Command in Windows or Terminal from Mac OS to generate server.pass.key file.
openssl genrsa -des3 -passout pass:SomePassword -out server.pass.key 2048
3. Run the below command from MS Command in Windows or Terminal from Mac OS to generate server.key file.
openssl rsa -passin pass:SomePassword -in server.pass.key -out server.key
4. Run the below command from MS Command in Windows or Terminal from Mac OS to generate server.csr file.
openssl req -new -key server.key -out server.csr
5. Run the below command from MS Command in Windows or Terminal from Mac OS to generate server.crt file.
openssl x509 -req -sha256 -days 365 -in server.csr -signkey server.key -out server.crt
6. Create a Connected App in Salesforce. Enable “Use digital signatures” and use the certificate created.
Callback URL should be http://localhost:1717/OauthRedirect.
7. Go to AWS Console. Go to Lambda –> Functions –> {Your contact center name}-InvokeSalesforceRestApiFunction.
8. Go to Configuration and select the Environment Variables. Update the Environment as following. Use your My Domain URL.
ACCESS_TOKEN_PARAM_NAME is InfallibleTechVoice-salesforce-rest-api-access-token
AUDIENCE is InfallibleTechVoice-salesforce-rest-api-audience
CONSUMER_KEY_PARAM_NAME is InfallibleTechVoice-salesforce-rest-api-auth-consumer-key
PRIVATE_KEY_PARAM_NAME is InfallibleTechVoice-salesforce-rest-api-auth-private-key
SALESFORCE_AUTH_ENDPOINT is https://infalliblescv.my.salesforce.com/services/oauth2/token
SALESFORCE_REST_API_ENDPOINT_BASE is https://infalliblescv.my.salesforce.com/services/data/v54.0
SUBJECT is InfallibleTechVoice-salesforce-rest-api-subject
Here InfallibleTechVoice is my Contact Center Name and infalliblescv.my.salesforce.com is my Salesforce My Domain URL.
9. Go to AWS System Manager. Select Parameter Store.
10. Update the values in the Parameter Store.
InfallibleTechVoice-salesforce-rest-api-access-token – Leave it with the default value generated or make it blank.
InfallibleTechVoice-salesforce-rest-api-audience is https://login.salesforce.com/.
InfallibleTechVoice-salesforce-rest-api-auth-consumer-key is Consumer Key from the Salesforce Connected App.
InfallibleTechVoice-salesforce-rest-api-auth-private-key – Value in the server.key file. Please include all the content of the file. Don’t ignore the first and last lines too.
InfallibleTechVoice-salesforce-rest-api-subject – [email protected].
Here, [email protected] is my Salesforce Username.
11. Test the Lambda.
Payload:
{
"Details": {
"Parameters": {
"methodName": "queryRecord",
"soql": "SELECT Id FROM Case WHERE ContactPhone = '+14155551234' AND IsClosed = false"
}
}
}
Output: