Newer Version Available

This content describes an older version of this product. View Latest

InvokeSalesforceRestApiFunction Lambda Function

Use this Lambda function to call the Salesforce REST API from a contact flow. You can create, update, and query records using this function.

To learn more about programmatically managing Salesforce records, refer to the Object Reference for Salesforce and Lightning Platform and the Salesforce REST API Developer Guide.

Each action is defined by the “methodName” key in the input attributes. To see some examples of how this function is used, review the Sample Contact Flows that are in the REST API section.

Table 1. Input Attributes
Action methodName Value Other Required Attributes
Create a Salesforce record createRecord
  • objectApiName containing the name of the Salesforce object.
  • A list of fields as required to create the record. Each key name is the field name.
Update an existing Salesforce record updateRecord
  • objectApiName containing the name of the Salesforce object.
  • recordId containing the ID of the record.
  • The list of fields that you want to update. Each key name is the field name.
Query for a Salesforce record queryRecord soql containing the desired SOQL query. For example:
1SELECT Id FROM Contact 
2WHERE Phone = '$.CustomerEndpoint.Address'
For details about the $ variable, see the Amazon documentation on contact attributes.
Table 2. Output Attributes
methodName Output Attribute Name Description
createRecord recordId ID of the newly created record.
updateRecord None N/A
queryRecord

Names match the names of the fields you queried.

A list of the selected fields. Each attribute contains a different field. Note that regardless of your query, only the first resulting record is returned.

TIP: To check that the function returned information successfully, add a condition to a Check contact attributes block to check an output attribute based on some detail you expect to see in the result. For instance, let’s say you’re performing a query that returns a contact ID. A contact ID always contains “003” in the ID value, so you can use that information to check the success or failure of the call.

Conditions to check

And then build your contact flow logic based on this result.

Check contact attributes