InvokeTelephonyIntegrationApiFunction Lambda Function

The invokeTelephonyIntegrationApi function contains actions which orchestrate voice call handling and routing. The function integrates telephony events with Salesforce, ensuring calls are properly processed and directed through the appropriate Omni-Channel logic. It also calls Voice integration APIs directly from an Amazon Connect contact flow. It receives request parameters from the flow, invokes the appropriate voice API endpoint, and returns the structured response back to the contact flow for further logic processing.

Configuration: This function is available to Salesforce Voice with Amazon Connect and Salesforce Voice with Partner Telephony from Amazon Connect customers who are using an Amazon Connect instance that’s provided by Salesforce. No additional configuration is necessary. See a sample version of the invokeTelephonyIntegrationApi Lambda function in GitHub.

Description: Use this Lambda function to create a VoiceCall record, execute an Omni-Channel flow, cancel an omni channel flow execution, create a ContactRequest record for a callback, or route a voice call to a rep, queue, or flow. Creating a VoiceCall is essential to get the call working, which is why this function is typically one of the first blocks in your contact flow for an inbound call. You can also use this function to retrieve a rep’s default outbound phone number, the pre-recorded voicemail message, or the personal voicemail greeting associated with the phone number. This Lambda is invoked to perform the following actions:

  • Create a VoiceCall for an inbound call. This action occurs when a customer calls into the call center.
  • Create a VoiceCall for a call transfer. This action occurs when a rep transfers to another rep or queue.
  • Create a ContactRequest for a callback. This action occurs when a customer requests a callback and provides their phone number for a rep to return their call.
  • Execute an Omni-Channel flow. This action occurs when work is ready to be routed.
  • Cancel an Omni-Channel flow. This action occurs when an existing flow needs to be canceled.
  • Route a voice call. This action occurs when a voice call or transferred voice call is ready to be routed through Omni-Channel Unified Routing with Salesforce as the routing engine.
  • Retrieve a rep’s default outbound phone number. Use the number selected by the rep as the caller ID for an outbound call.
  • Retrieve a prerecorded voicemail message. Use a message selected by the rep for voicemail drop instead of requiring the rep to record a message during the call.
  • Retrieve a personal voicemail greeting. Use the voicemail greeting associated with the phone number that the customer called.

For Agentforce Voice on Amazon Connect, the function includes two API endpoints to support dynamic routing.

reserveRoutableNumber

Dynamically allocates a Direct Inward Dialing (DID) Public Switched Telephone Network (PSTN) number based on the provided country and caller number. See Reserve a Routable Number.

createVoiceCallContext

Allocates a server-minted correlation-id handle for a voice call transfer to Agentforce Voice. The partner telephony system places the returned correlation ID in a SIP X-header on the outbound SIP-address transfer leg. See Create Voice Call Context.

When a Lambda function hasn’t been invoked after a period of time, the AWS framework unloads the function from memory. The next time the function is invoked, it is “cold” and takes longer to load into memory. This delay can cause a timeout in the contact flow. To avoid this behavior, learn how to keep this function warm.

Usage: Place this Lambda within one of the relevant contact flows (either for an inbound call or a transfer). This Lambda takes a methodName attribute as an argument. This attribute indicates the specific action that the Lambda must perform. Use the attribute keys and values to configure the request parameters.

ActionAttribute KeyAttribute Value
Create a voice call for an inbound callmethodNamecreateVoiceCall
Create a voice call for a transfermethodNamecreateTransferVC
Request routing instructions from an Omni-Channel flow and create a PendingServiceRequest.
Calls routed with this method appear in the Queue Backlog tab of Command Center for Service. If a PendingServiceRequest isn’t created and the voice call isn’t routed by Omni-Channel, then the Queue Backlog tab doesn’t show the call. For example, calls that are manually assigned to a rep don’t appear in that tab.
Optionally, provide these inputs:
  • flowDevName. Set the Omni-Channel flow using its developer name.
  • fallbackQueue. Set the fallback queue using its Salesforce queue developer name or ID.
  • Custom parameters with prefix flowInput-. Set additional inputs to the Omni-Channel flow.

By default, Salesforce Voice uses the Omni-Channel flow (or fallback queue) specified for the phone channel that matches the dialed number. If the dialed number doesn’t match an existing phone channel, you can optionally set the Omni-Channel flow or fallback queue in these input parameters. The fallback queue is used only if the specified flow doesn’t exist or one isn’t specified.
methodNameexecuteOmniFlow
Cancels an Omni-Channel flow that was previously executed. This method also calls the Clear Routing REST API to clear the PendingServiceRouting (PSR) record.methodNamecancelOmniFlowExecution
Creates a callback request for a voice call by creating a ContactRequest record. Omni-Channel routes the contact request based on the contact center channel’s Callback Routing selection. For Omni-Channel Unified Routing only.methodNamecallbackExecution
Routes or transfers a voice call to a rep, agent, queue, or flow. Creates a PendingServiceRequest. For Omni-Channel Unified Routing only.
Provide these inputs:
  • routingTarget. Specify the Omni-Channel routing target using a Salesforce agent ID, queue ID, or Omni-Channel flow ID. Required.
  • fallbackQueue. Set the fallback queue using its ID, if a flow is the routingTarget. Optional.
  • Custom parameters with prefix flowInput-. Set additional inputs to the Omni-Channel flow, if a flow is the routingTarget. Optional.
methodNamerouteVoiceCall
Get Default NumberagentARNAgent ARN
Get Default NumbermethodNamegetDefaultOutboundPhoneNumber
Get Voicemail DropmethodNamegetVoicemailDrop
Get Voicemail GreetingmethodNamegetVoicemailGreeting

When creating a voice call record, you can also specify custom data to be added to fields on the VoiceCall record. To add custom data, create a Set contact attributes block before the Lambda call. For the destination attribute, specify the name of the custom field with the “sfdc-” prefix added. The value of this attribute is the data to pass into the custom field For an example, see Pass Data from the Interactive Voice Response (IVR) System.

Output Attribute NameDescription
voiceCallIdID of the voice call.
Output Attribute NameDescription
agentThe rep to route the call to
queueThe queue to route the call to
errorsList of errors why the call couldn’t be routed
Output Attribute NameDescription
recordIdID of the contact request for a callback.
  • Keep the InvokeTelephonyIntegrationApiFunction Lambda Function Warm

    When a Lambda function hasn’t been invoked after a period of time, the AWS framework unloads the function from memory. The next time the function is invoked, it is “cold” and takes longer to load into memory. This delay can cause a timeout in the contact flow. These instructions describe how to keep your Lambda function “warm” using a Lambda function trigger.

See Also