Here are a few sample bots which demonstrate some of the use cases that can be achieved with the SDK. Before getting started with any of these examples, you must check that you have the following prerequisites:
-
You must have a Conversational Cloud account.
-
You must be able to configure an agent in your Conversational Cloud account.
-
You must have the latest version of Node.js installed on your machine. Here's a guide on how to do so: Mac / Windows.
Greeting Bot
The greeting bot is a very simple implementation of the SDK in which the bot joins every conversation as a manager and sends the line "welcome from bot".
Pre-requisites:
- A LivePerson Account
- A user with Agent Manager permissions
To run the greeting bot example:
- Provide the following
env
variables:-
LP_ACCOUNT
- Your LivePerson account ID -
LP_USER
- Your LivePerson agent username -
LP_PASS
- Your LivePerson agent password
-
- Run:
- Unix Shell
LP_ACCOUNT=1234567 LP_USER=BotUserName LP_PASS=b0tpa55word node examples/greeting-bot/greeting-bot.js
- Windows Shell
set LP_ACCOUNT=1234567 set LP_USER=BotUserName set LP_PASS=b0tpa55word node examples/greeting-bot/greeting-bot.js
- Unix Shell
Agent Bot
The agent bot is an example SDK implementation in which the bot accepts incoming conversations as the assigned agent. It listens for messages from the consumer and upon receipt marks them as read and echos them back to the consumer. This example extends the Agent class.
Pre-requisites:
- A LivePerson Account
- A user with Agent permissions
To run the agent bot example
- Provide the following
env
variables:-
LP_ACCOUNT
- Your LivePerson account ID -
LP_USER
- Your LivePerson agent username -
LP_PASS
- Your LivePerson agent password
-
- Run:
- Unix Shell
LP_ACCOUNT=1234567 LP_USER=BotUserName LP_PASS=b0tpa55word node examples/agent-bot/main.js
- Windows Shell
set LP_ACCOUNT=1234567 set LP_USER=BotUserName set LP_PASS=b0tpa55word node examples/agent-bot/main.js
- Unix Shell
Survey Bot
The survey bot is an example SDK implementation in which the bot waits on a survey dialog, validates the application id with its own and joins the dialog.
It automatically starts a survey of one question, listens on responses and upon correct response, closes the dialog. This example extends the Agent class.
Pre-requisites:
- A LivePerson Account
- A user with Agent permissions
- Application installation id with
ms_survey
capability — ask your LivePerson account representative (other contact options: chat with us on this page, or message Support) to create one for you and provide you with the id - Assign your application installation id to a specific skill(s) that if the conversation ends on your bot will start operating — not your bot skill (ask your LivePerson account representative to assign it for you)
To run the survey bot example
- Provide the following
env
variables:-
LP_ACCOUNT
- Your LivePerson account ID -
LP_USER
- Your LivePerson agent username -
LP_PASS
- Your LivePerson agent password -
APP_INST
- Your bot app installation id
-
- Run:
- Unix Shell
APP_INST=1234-3454-34657 LP_ACCOUNT=1234567 LP_USER=BotUserName LP_PASSWORD=b0tpa55word node examples/survey-bot/main.js
- Windows Shell
set APP_INST=1234-3454-34657 set LP_ACCOUNT=1234567 set LP_USER=BotUserName set LP_PASSWORD=b0tpa55word node examples/survey-bot/main.js
- Unix Shell
Return To Same Agent Bot
The Return to Same Agent bot is an example SDK implementation which showcases transfer to agent capabilities. The bot performs the following actions:
- Listens for any incoming conversations, on a pre-configured skill.
- Accepts the conversation.
- Waits for a notification which says that a bot has joined the conversation.
- The bot then uses the Messaging Interactions API method, Get Conversations by Consumer id, in order to get all conversation for the current consumer.
- The conversation with the best MCS record is retrieved.
- From that conversation the bot extracts the agent id.
- Using the Agent Metrics API method, Agent Status, the bot checks if that agent is ONLINE.
- In case the answer is yes, it transfers the conversation to that agent.
This example extends the Agent class.
Pre-requisites:
- A LivePerson Account
- Account should have the ac-feature
Messaging.Transfer_To_Agent
enabled.
- Account should have the ac-feature
- A user with Agent permissions. These permissions also need to be edited. To edit the agent permission:
- Login to your account using administrator/agent manager permissions.
- Navigate to the users tab.
- Click the Profiles option and then click the Agent profile or create a new profile based on the Agent role and there enable the following:
Transfer messaging conversations to a specific agent in 'online' or 'back soon' state
To run the return to same agent bot example
-
Provide the following
env
variables:-
LP_ACCOUNT
- Your LivePerson account ID -
LP_USER
- Your LivePerson agent username -
LP_PASS
- Your LivePerson agent password
-
-
Run:
- Unix Shell ```sh LP_ACCOUNT=1234567 LP_USER=BotUserName LP_PASSWORD=b0tpa55word node examples/transfer2same-agent-bot/main.js
- Windows Shell
set LP_ACCOUNT=1234567 set LP_USER=BotUserName set LP_PASS=b0tpa55word node examples/transfer2same-agent-bot/main.js
The connector on back-end will use the fields replyFromAccountId. The fallback mechanism when the replyFromAccountId is not provided is to use the conversationState.dmChatId attribute.
Social Messaging Bot
The agent bot is an example SDK implementation in which the bot accepts incoming social messaging conversations as the assigned agent. It listens for messages from the consumer and upon receipt marks them as read and echos them back to the consumer. This example extends the Agent class.
Pre-requisites:
- A LivePerson Account with Messaging & Social Messaging
- A LivePerson Account with Feature "Sent_Consumer_Message_Metadata" enabled
- A user with Agent permissions
- Social Messaging configured on your LivePerson account
To run the agent bot example
- Provide the following
env
variables:-
LP_ACCOUNT
- Your LivePerson account ID -
LP_USER
- Your LivePerson agent username -
LP_PASS
- Your LivePerson agent password
-
- Run:
- Unix Shell
LP_ACCOUNT=1234567 LP_USER=BotUserName LP_PASS=b0tpa55word node examples/social-bot/main.js
- Windows Shell
set LP_ACCOUNT=1234567 set LP_USER=BotUserName set LP_PASS=b0tpa55word node examples/social-bot/main.js
- Unix Shell
Bot Cluster
See Bot Cluster Example documentation
Extending the Agent Class
The best way to use the SDK is to extend the Agent class with your own logic and then instantiate this object in your projects, as demonstrated in a very basic way in the agent bot example.
For more extensive bot examples, all of which extend the Agent class, check out the extended messaging bot samples repository.