Jump to content


Chat BOT - Usage


12 replies to this topic

#1 Oleh Vasylyev

    Advanced Member

  • Members
  • PipPipPip
  • 44 posts

Posted 31 May 2017 - 08:42 AM

Hi LiveZilla team!

LZ 7.0.4.0

I am trying to setup Chat Bot using your manual. Example from manual is working for me.

Please advice me how to setup following:

For example we have 'EN_Sales', 'ES_Sales', 'EN_Support', 'ES_Support' groups. Client start Chat... (Bot in "Welcome Manager Mode")

1.Step
Bot: "Choose your language"
Button "English" --> go to 2.step
Button "Spanish" --> go to 2.step

2.Step
Bot: "Choose department"
Button "Sales" (direct start chat with TARGET group)
Button "Support" (direct start chat with TARGET group)

#2 Oleh Vasylyev

    Advanced Member

  • Members
  • PipPipPip
  • 44 posts

Posted 31 May 2017 - 09:41 AM

Ok, I have find out how to catch user-response value, but I still need your advice how to call some TARGET group. Thank You.


$requestObject = json_decode($_POST["livezilla_user_api_request"]);

$responseObject = array();
$responseObject["Value"] = "";
$responseObject["Id"] = rand(1111111,9999999);
$responseObject["SearchKB"] = false;

if($requestObject->RequestNumber==0){
$responseObject["Select"] = array();
$responseObject["Select"][] = array("title"=>"English","return"=>"English");
$responseObject["Select"][] = array("title"=>"Spanish","return"=>"Spanish");

$responseObject["Value"] = "Thanks for contacting us. Please choose your language:";
}

if($requestObject->RequestNumber==1){

$rqv = $requestObject->Value;

if ($rqv == 'English'){

$responseObject["Select"] = array();

if($requestObject->HumanAvailable){
$responseObject["Select"][] = array("title"=>"Chat with Sales EN","livezilla"=>"human","return"=>"Hello human ...");
$responseObject["Select"][] = array("title"=>"Chat with Support EN","livezilla"=>"human","return"=>"Hello human ...");
} else {
$responseObject["Select"][] = array("title"=>"Leave a Message Sales EN","livezilla"=>"message","return"=>"");
$responseObject["Select"][] = array("title"=>"Leave a Message Support EN","livezilla"=>"message","return"=>"");
}

$responseObject["Value"] = "Please choose department you want contact with:";

} elseif ($rqv == 'Spanish'){

$responseObject["Select"] = array();

if($requestObject->HumanAvailable){
$responseObject["Select"][] = array("title"=>"Chat with Sales ES","livezilla"=>"human","return"=>"Hello human ...");
$responseObject["Select"][] = array("title"=>"Chat with Support ES","livezilla"=>"human","return"=>"Hello human ...");
} else {
$responseObject["Select"][] = array("title"=>"Leave a Message Sales ES","livezilla"=>"message","return"=>"");
$responseObject["Select"][] = array("title"=>"Leave a Message Support ES","livezilla"=>"message","return"=>"");
}

$responseObject["Value"] = "Please choose department you want contact with:";

}
}

if(!empty($responseObject["Value"])){
echo json_encode($responseObject);
}



#3 Patrick Keil

    Administrator

  • Administrators
  • 3187 posts
  • LocationSingen, Germany

Posted 01 June 2017 - 06:47 AM

Hi,

Thanks for your feedback.

The CHAT Bot API currently lacks a "pass to group x operator y" function. We will add that in the near future.

#4 Oleh Vasylyev

    Advanced Member

  • Members
  • PipPipPip
  • 44 posts

Posted 01 June 2017 - 07:13 AM

Hi Patrick,

It is also possible to do this through "Javascript Button".
I have done for calling external window:

$responseObject["Select"][] = array("title"=>"Sales. Chat with us (EN)","script"=>"window.open('https://xxxxxxxxxxxxxx.xxx/chat.php?utm_campaign=chat&utm_source=xxxxxxxx.xxx&utm_medium=Espanol-gsmserver&acid=11c8f&intgroup=RXNwYW5vbC1nc21zZXJ2ZXI_&hg=Pw__&ckf=Z3Ntc2VydmVyLmNvbS1lcw==&hcgs=MQ__&htgs=MQ__&eh=aHR0cHM6Ly9saXZlemlsbGEucHJvc3RlZXJncm91cC5jb20vaW1hZ2VzL2hlYWRlcnMvZW4tZ3Ntc2VydmVyLmNvbS5wbmc=&{tail}','','width=590,height=590,left=0,top=0,resizable=yes,menubar=no,location=no,status=yes,scrollbars=yes');","return"=>"");

But calling external window from 'overlay' it's nonsense.
Could you advise me code that will works in same window?

#5 Oleh Vasylyev

    Advanced Member

  • Members
  • PipPipPip
  • 44 posts

Posted 27 June 2017 - 07:48 AM

Hi LiveZilla Team!
You have done the great work.

I have upgraded server to 7.0.5.0
Please provide here a short example how to use this:
Action		chat | message	No	 Start chat with human or leave a message	 chat
Operator	string				   No	 Action target operator (ID)							   john_doe
Group		string				   No	 Action target group (ID)								   support

(pass to target group or operator)

Thank You

#6 Patrick Keil

    Administrator

  • Administrators
  • 3187 posts
  • LocationSingen, Germany

Posted 27 June 2017 - 08:02 AM

LiveZilla 7.0.5.0 adds the missing routing parameters. The API documentation seems incomplete, we will correct that ASAP.

Here's an example for an routing button selector:

$responseNode["Value"] = "";
$responseNode["Select"] = array();
$responseNode["Select"][] = array("title"=>"Talk to Isabel","action"=>"chat","operator"=>"ibeloni","group"=>"tech");
$responseNode["Select"][] = array("title"=>"Talk to Admin","action"=>"chat","operator"=>"administrator","group"=>"support");
$responseNode["Select"][] = array("title"=>"Message to Isabel","action"=>"message","operator"=>"ibeloni","group"=>"tech");
$responseNode["Select"][] = array("title"=>"Message to Admin","action"=>"message","operator"=>"administrator","group"=>"support");


#7 Oleh Vasylyev

    Advanced Member

  • Members
  • PipPipPip
  • 44 posts

Posted 27 June 2017 - 08:08 AM

Thank you for quick response.

It is possible to pass to the whole group?

#8 Patrick Keil

    Administrator

  • Administrators
  • 3187 posts
  • LocationSingen, Germany

Posted 27 June 2017 - 08:12 AM

Sure, just leave the operator away.

#9 Oleh Vasylyev

    Advanced Member

  • Members
  • PipPipPip
  • 44 posts

Posted 27 June 2017 - 08:30 AM

Thank you. It works!

I see also you have updated API documentation.
In one example you are using responseObject (QuickStart Example) but in another responseNode (PizzaBot Example)
What is the difference?

#10 Patrick Keil

    Administrator

  • Administrators
  • 3187 posts
  • LocationSingen, Germany

Posted 27 June 2017 - 08:57 AM

It's just a variable name, you can use whatever you want.

#11 Oleh Vasylyev

    Advanced Member

  • Members
  • PipPipPip
  • 44 posts

Posted 30 June 2017 - 07:46 AM

I have tested ChatBot API on your "pizza"-based example.

And I have a questions (or I don't understood all on 100%):


A )

It looks like Bot know only about previous answer.

For example:

1. Select language
2. Select department
3. What is your name? - (here Bot will nothing know which Language I selected)

Maybe exists some array with all previous answers?

B )

How to make if customer press "I want to speak with Human" - some data (what customer has answered) will pass to chat. Like "Name" or "First question".

Customers will be angry when operator ask him again "How can I help you?" This happen often on practice.

C )
This numbers in array should be exactly or can be random?
$responseNode["Data"]["114"]
$responseNode["Data"]["111"]
$responseNode["Data"]["115"]
.....
.....


My example:

$requestobj = json_decode($_POST["livezilla_user_api_request"]);

$responseNode = array();
$responseNode["Value"] = "";
$responseNode["ResponseTo"] = "";
$responseNode["SearchKB"] = false;

if($requestobj->Value != "[__[EXIT]__]"){
	
	// language
	if($requestobj->ResponseTo == ""){
		// store initial question
		$responseNode["Id"] = "action:request_language";
		
		$responseNode["Data"] = array();
		$responseNode["Data"]["111"] = $requestobj->Value;
	  
		$responseNode["Select"] = array();
		$responseNode["Select"][] = array("title"=>"English","return"=>"English");
		$responseNode["Select"][] = array("title"=>"Spanish","return"=>"Spanish");

		$responseNode["Value"] = "Thanks for contacting us. Please choose your language:";
		
		$responseNode["Block"] = true;
	}

	// name
	if($requestobj->ResponseTo == "action:request_language"){
		// store initial question
		
		$responseNode["Data"] = array();
		$responseNode["Data"]["114"] = $requestobj->Value;
		$responseNode["Id"] = "action:request_name";

		if ($requestobj->Value == 'English'){
			$responseNode["Value"] = "Ok. What's your name please?";
		} elseif ($requestobj->Value == 'Spanish'){
			$responseNode["Value"] = "¿Cuál es tu nombre por favor?";
		}
		
		$responseNode["Block"] = false;
	}
	
	
	
	// department
	if($requestobj->ResponseTo == "action:request_name"){
		$responseNode["Id"] = "action:request_department";
		
		$responseNode["Data"]["111"] = $requestobj->Value;
		$responseNode["Select"] = array();
		
		if ($responseNode["Data"]["114"] == 'English'){
			$responseNode["Select"][] = array("title"=>"Sales","return"=>"Sales");
			$responseNode["Value"] = "Great, nice to meet you <b>" . $requestobj->Value . "</b>.";
			$responseNode["Value"] .= "Please choose department you want contact with:";
			
			if($requestobj->HumanAvailable){
				$responseNode["Select"][] = array("title"=>"Start a Chat","action"=>"chat","operator"=>"","group"=>"TEST");
			} else {
				$responseNode["Select"][] = array("title"=>"Leave a Message","action"=>"message","group"=>"TEST");
			}
			
		} elseif ($responseNode["Data"]["114"] == 'Spanish'){
			$responseNode["Select"][] = array("title"=>"Sales","return"=>"Sales");
			$responseNode["Value"] = " ES Great, nice to meet you <b>" . $requestobj->Value . "</b>.";
			$responseNode["Value"] .= "ES Please choose department you want contact with:";
			
			if($requestobj->HumanAvailable){
				$responseNode["Select"][] = array("title"=>"Start a Chat ES","action"=>"chat","operator"=>"","group"=>"TEST");
			} else {
				$responseNode["Select"][] = array("title"=>"Leave a Message ES","action"=>"message","group"=>"TEST");
			}
		}
		
		$responseNode["Block"] = true;
		
	}

	if($requestobj->ResponseTo == "action:request_customer_number")
	{
		// and so on ...
		$responseNode["Value"] = "This demo ends here ...";
		$responseNode["Block"] = false;
	}
}
else
{
	// say good bye
	$responseNode["Id"] = "action:end_chat";
	$responseNode["Value"] = "Take care, bye!";
}
echo json_encode($responseNode);


#12 Oleh Vasylyev

    Advanced Member

  • Members
  • PipPipPip
  • 44 posts

Posted 10 July 2017 - 11:32 AM

Hi,

I want to remind about last question:

A )

It looks like Bot know only about previous answer.

For example:

1. Select language
2. Select department
3. What is your name? - (here Bot will nothing know which Language I selected)

Maybe exists some array with all previous answers?

B )

How to make if customer press "I want to speak with Human" - some data (what customer has answered) will pass to chat. Like "Name" or "First question".

Customers will be angry when operator ask him again "How can I help you?" This happen often on practice.

C )
This numbers in array should be exactly or can be random?
$responseNode["Data"]["114"]
$responseNode["Data"]["111"]
$responseNode["Data"]["115"]
.....
.....


#13 Patrick Keil

    Administrator

  • Administrators
  • 3187 posts
  • LocationSingen, Germany

Posted 10 July 2017 - 12:15 PM

Hi,

A.) No, we don't plan to pass all data again. You will need to store that on your side.

B.) Please store the data as shown in our examples and all information will be shown to the operator.

C.) It's not random. Please find the ID's in your Input Field configuration (Server Configuration -> Input Fields)





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users