Get LivePerson service domain
Use the getLPDomain function in a bot to dynamically retrieve the base URI for a given service.
Internally, this function makes a call to LivePerson’s Domain API. Within a bot, you can’t call that API directly, so we offer this scripting function. Take advantage of it to avoid hard coding domains.
| Function Name | Arguments | Returns |
|---|---|---|
getLPDomain(serviceName) |
serviceName - The name of the service. You can find service names in the relevant documentation for the API. Alternatively, retrieve the service name using the Domain Retrieval Tool. | String representing the base URI for the provided service |
Best practices
- Always check the output for null values and empty strings. While the call is retried, it’s still an external call that might fail.
- Never hard code a domain in your code; always retrieve it dynamically because the domains can change.
Example
The following code example retrieves the base URI for the “msgHistory” service for your account.
let msgHistoryDomain = botContext.getLPDomain("msgHistory"); //Example result - va-a.msghist.liveperson.net
if(msgHistoryDomain){ //Ensures value is present, is not null and not emtpy string
//Save it to bot variable or use it according to bot developer's use case
botContext.setBotVariable(“msgHistoryDomain”, msgHistoryDomain, true, false);
}