Use the LivePerson Functions integration to invoke a function (lambda) that is deployed to the LivePerson Functions (Function as a Service or FaaS) platform. There are no constraints here; if there is some custom logic (a function) you want to invoke with a bot, you can do it with a LivePerson Functions integration.

Enabling the use of LivePerson's Function (FaaS) integrations requires a configuration change made by LivePerson. Contact your LivePerson account representative for assistance.

LivePerson Conversation Builder waits a certain amount of time for a response from the LivePerson function, where that value differs based on environment:

  • VA = 47 seconds
  • GCP US = 47 seconds
  • LO = 20 seconds
  • SY = 20 seconds

LivePerson Functions versus API integrations

Wondering when to leverage which? See this discussion.

Add a LivePerson Functions integration

  1. Open the bot, and click Integrations in the upper-left corner.
  2. Configure the integration settings:
    • Integration Name: Enter the name of integration. Enter a name that's meaningful (it describes well the integration's purpose), concise, and follows a consistent pattern. This helps with organization, and it makes it easier for bot developers to work with the integration during bot development.
    • Response Data Variable Name: Enter the name of the response data variable.
    • Integration Type: Select FaaS.
    • Function: Select the function (lambda) to invoke via this integration. You can select from all functions added under your LivePerson account. Each is listed with its status. Selecting a function The Function list provides an easy pass-through to the Functions UI in case you still need to create or modify the relevant function. Clicking Create New Function or Pencil icon (pencil icon) beside a function name opens a new browser window and prompt you to log into the Functions UI where you can do the work. Once done, return here and click Reload icon (reload icon) to refresh the Function list if needed.
    • Function Headers: Add the necessary data in key/value pairs to pass into the request via the header.
    • Function Payload: Enter the payload to pass into the function.
    • Transform Result Script: If applicable, use this section to write JavaScript code that transforms the raw result (typically in JSON format), so you can use the information in the bot's dialogs. For more on this, see Transform an API result.
    • Custom Data Fields: Add the fields that will store the result data in key/value pairs. Users who are tasked with creating bots can use and display this data in interactions by referencing these fields.
  3. Click Save.

Example guide

Step 1: LivePerson Functions — Configure the function

  1. In Conversational Cloud, open the menu on the left side of the page, and select Automate > Functions.

    This opens LivePerson Functions in a separate tab in the browser.

  2. Create and configure a function with the custom JavaScript logic that you need for your use case. As an example, the following function takes item and price from the input Object, and, based on the value of price, it decides which sentence to send back to the bot. (This sentence is subsequently displayed in the conversation.)

    An example function

  3. Once you’re happy with your function, deploy it.

    You should see the status of the function change from Modified to Productive.

Step 2: Conversation Builder — Configure the integration

  1. Within Conversational Cloud, open the bot in Conversation Builder, and click the Integrations tab.
  2. Provide a name for the function’s integration. In our example, we'll use UnsolicitedCommentFunction.
  3. Set the Integration Type to FaaS.
  4. Select the Productive function that you want to integrate.
  5. Function Headers: This is where you should set particular key/value pairs like bot variables or slots.
  6. Function Payload: This is where you should set a specific JSON body to send to the function. Note: In the example below, for demonstration purposes, the two slots are being set in both the headers and the payload. By doing this, you’re able to understand the correct notation to use. In a real world scenario, the best practice is to use slots, custom variables, and bot variables as Function Headers and a JSON body to be set as the Function Payload.
  7. Transform Result Script: To process the response coming from the function, you can set the following code to extract it in a JSON format and then send the sentence (in this case, it's a string) directly as a bot message.
var faasData = botContext.getBotVariable("api_UnsolicitedCommentFunction");
var faasJsonData = JSON.parse(faasData.jsonData);
var jsonResponse = faasJsonData.api_UnsolicitedCommentFunction;

In this scenario the Transform Result Script is used because the function is simply returning a string. In the case where a function returns a complex JSON structure, it's up to you to use the same or to take advantage of the Custom Data Fields. For instance, if the response from the function were:

{“response”: “200$ is way too much for a bag!”}

You could set the following as Custom Data Fields:

An example custom data field that's been configured

Then, you could use the response within a dialog’s interaction by using the following notation:


Here’s a visual summary of what needs to be done within the Integrations tab:

The configuration of the integration in the Integration Settings

Step 3: Conversation Builder — Configure the dialog

  1. Create an interaction of type Integration, and select from the dropdown the function’s integration.
  2. Save the change.

Adding the Integration interaction and selecting the function's integration from the dropdown

Step 4: Conversation Builder — Preview

This is the end user's experience in a conversation:

Previewing the conversational experience using the Preview tool