You are here:
Configure a Gateway API for External Storage Search
Expose Amazon Bedrock or Amazon Kendra through an AWS API that accepts Salesforce search requests and returns supported search results.
Before you begin, set up and test an Amazon Bedrock knowledge base or Amazon Kendra index.
- Create a Lambda function that accepts the External Storage Search request.
- Configure the function to accept a natural-language query, Salesforce ContentDocument IDs, additional filters, a maximum result count, and a search handle, as applicable.
- Configure the function to query the selected AWS search service and apply supported filters.
-
Transform each result into the response fields expected by Salesforce.
The response must include these values, as applicable:
Field Type Description contentDocumentIds String array Normalized IDs from the contentDocumentId metadata field contentType String or null File type excerpt String Matched chunk's content.text externalDocumentInfo2 String Amazon S3 URI relevanceScore Number Relevance score returned by the search service sourceUrl String Amazon S3 URI title String File name derived from the Amazon S3 URI pageNumber String or null Page number from chunk metadata startTimeMs Number or null Relevant media start time in milliseconds endTimeMs Number or null Relevant media end time in milliseconds - Grant the Lambda execution role permission to query the selected search service.
- In API Gateway, create a REST API.
-
Create a search resource, such as
/search. - Create a POST method that uses the Lambda function as its integration target.
- Enable Lambda proxy integration.
- Set the method authorization to AWS_IAM.
-
Deploy the API to a stage, such as
prod. - Record the invoke URL.
- Create an IAM principal with permission to invoke the gateway API.
- Send a test request.
- Verify the response schema, Salesforce file IDs, relevance scores, excerpts, and source locations.
- The gateway API is ready to connect to Salesforce.
Sample Input and Output Response
Here is a sample input:
{
"searchQuery": "Jason image",
"contentDocumentIds": [
"069xx0000004Dea",
"069LT000001BuuL",
"069xx0000004Deb",
"069LT000001Bv41"
],
"additionalFilters": {},
"maxResults": 100,
"searchHandle": null
}
Here is a sample output:
{
"executionTimeMs": 1720,
"hasMore": false,
"nextSearchHandle": null,
"results": [
{
"contentDocumentIds": [
"069xx0000004Dea",
"069xx0000004CIi"
],
"contentType": "PDF",
"excerpt": "Jason...",
"externalDocumentInfo2": "s3://my-bucket/Stockholm-Resume-Template-Simple.pdf",
"relevanceScore": 0.3837699,
"sourceUrl": "s3://my-bucket/Stockholm-Resume-Template-Simple.pdf",
"title": "Stockholm-Resume-Template-Simple.pdf",
"pageNumber": "1",
"startTimeMs": null,
"endTimeMs": null
},
{
"contentDocumentIds": [
"069LT000001BuuL"
],
"contentType": "MP3",
"excerpt": "",
"externalDocumentInfo2": "s3://my-bucket/__sfdcroot__/Case/500LT00000K5Ty5YAF/Hyde_1783590525379.mp3",
"relevanceScore": 0.3344161,
"sourceUrl": "s3://my-bucket/__sfdcroot__/Case/500LT00000K5Ty5YAF/Hyde_1783590525379.mp3",
"title": "Hyde_1783590525379.mp3",
"pageNumber": null,
"startTimeMs": 730,
"endTimeMs": 55110
},
{
"contentDocumentIds": [
"069xx0000004Deb"
],
"contentType": "MP4",
"excerpt": "",
"externalDocumentInfo2": "s3://my-bucket/Multi-File Edit.mp4",
"relevanceScore": 0.34692305,
"sourceUrl": "s3://my-bucket/Multi-File Edit.mp4",
"title": "Multi-File Edit.mp4",
"pageNumber": null,
"startTimeMs": 0,
"endTimeMs": 27849
},
{
"contentDocumentIds": [
"069LT000001Bv41"
],
"contentType": "PNG",
"excerpt": "The image describes...",
"externalDocumentInfo2": "s3://my-bucket/__sfdcroot__/Case/500LT00000K5Ty5YAF/image_1783590602375.png",
"relevanceScore": 0.3374139,
"sourceUrl": "s3://my-bucket/__sfdcroot__/Case/500LT00000K5Ty5YAF/image_1783590602375.png",
"title": "image_1783590602375.png",
"pageNumber": null,
"startTimeMs": null,
"endTimeMs": null
}
]
}
For detailed instructions for Bedrock service, see these AWS documentation references:
For detailed instructions for Kendra service, see these AWS documentation references:
- Sample Input and Output Response
Review sample request and response payloads for the External Storage Search gateway API.
