Jump to content


LiveZilla and Program-O chat bot


6 replies to this topic

#1 thomas.stock

    Newbie

  • Members
  • Pip
  • 9 posts

Posted 01 February 2018 - 04:52 PM

Hi all,

I have successfully set up Program-O and also set up the chat bot in LZ.
I ran into some issues as not every message was passed on to Program-O (Error in PHP log: ERR# 128 Error connecting USER API: http://<url>/bot/program-o.php () IN LINE 0)

After some digging I found that any message with spaces (basically any sentence) caused issues.

I modified the program-o demo script in line 8 as follows:

$url = "http://chatbot.domain.com/chatbot/conversation_start.php?say=".rawurlencode($requestobj->Value)."&convo_id=".$requestobj->VisitorId."&format=json";

So far everything is working fine and maybe worth to update the demo script.

Now, I have the following problem:

While everything is now sent correctly to the chat bot I would also like the KB resources to be considered.
Ideally: search KB first, if no response forward to chat bot and let him respond.

If I set $responseNode["SearchKB"] = true; I will get search results IN ADDITION to the chat bot response or a message that no resource could be found. Not nice!

Any idea how to accomplish this? I'm not a programmer so I'm kind of stuck ;)

Thanks,
Thomas

#2 Patrick Keil

    Administrator

  • Administrators
  • 3871 posts
  • LocationSingen, Germany

Posted 02 February 2018 - 08:32 AM

Hi Thomas,

Thanks for your feedback, highly appreciated.

Quote

rawurlencode

Thanks for bringing this to our attention. We will update the API example right away.

Quote

Ideally: search KB first, if no response forward to chat bot and let him respond.

I agree, that would be an improvement. We will add a new REQUEST Attribute called "KBMatchCount" which will indicate the number of matching entries found in the knowledgebase to your script. It will be included in the next update 7.0.9.2.

Cheers.

#3 thomas.stock

    Newbie

  • Members
  • Pip
  • 9 posts

Posted 07 February 2018 - 02:39 PM

Great! Sounds good to me!

#4 thomas.stock

    Newbie

  • Members
  • Pip
  • 9 posts

Posted 15 February 2018 - 12:56 PM

Quick confirmation: Works like a charm ;)

Here's my code in case anyone is interested:

<?php
$requestobj = json_decode($_POST["livezilla_user_api_request"]);
$responseNode = array();
$responseNode["ResponseTo"] = "";
$responseNode["Id"] = rand(1111111,9999999);
$responseNode["SearchKB"] = true;
if($requestobj->KBMatchCount==0) {
$responseNode["SearchKB"] = false;
$url = "http://domain.com/chatbot/conversation_start.php?say=".rawurlencode($requestobj->Value)."&convo_id=".$requestobj->VisitorId."&format=json";
$sdata = json_decode(file_get_contents($url));
$responseNode["Value"] = $sdata->botsay;
if(!empty($responseNode["Value"]))
echo json_encode($responseNode);
}
?>

Thanks again!

#5 jimmy_LGS

    Newbie

  • Members
  • Pip
  • 9 posts

Posted 23 May 2019 - 07:53 AM

View Postthomas.stock, on 15 February 2018 - 12:56 PM, said:

Quick confirmation: Works like a charm ;) Here's my code in case anyone is interested:
 KBMatchCount==0) { $responseNode["SearchKB"] = false; $url = "http://domain.com/chatbot/conversation_start.php?say=".rawurlencode($requestobj->Value)."&convo_id=".$requestobj->VisitorId."&format=json"; $sdata = json_decode(file_get_contents($url)); $responseNode["Value"] = $sdata->botsay; if(!empty($responseNode["Value"])) echo json_encode($responseNode); } ?> 
Thanks again!


can your program-o bot transfer the chat to human operator ?

#6 Patrick Keil

    Administrator

  • Administrators
  • 3871 posts
  • LocationSingen, Germany

Posted 23 May 2019 - 10:26 AM

Yes, absolutely.

Please see API docs for details:

https://www.livezill.../chatbotapi/en/

#7 jimmy_LGS

    Newbie

  • Members
  • Pip
  • 9 posts

Posted 10 June 2019 - 02:58 AM

View PostPatrick Keil, on 23 May 2019 - 10:26 AM, said:

Yes, absolutely.

Please see API docs for details:

https://www.livezill.../chatbotapi/en/


Should the script programmed like this ?
So when the public chatting with my bot and type any word in 'operator'
my .aiml file will detect word 'operator' and pass data value to here ?

<?php
$requestobj = json_decode($_POST["livezilla_user_api_request"]);
$responseNode = array();
$responseNode["ResponseTo"] = "";
$responseNode["Id"] = rand(1111111,9999999);
$responseNode["SearchKB"] = false;

$url = "http://api.program-o.com/v2/chatbot/?bot_id=6&say=".rawurlencode($requestobj->Value)."&convo_id=".$requestobj->VisitorId."&format=json";
$sdata = json_decode(file_get_contents($url));
$responseNode["Value"] = $sdata->botsay;

if(!empty($responseNode["Value"])){

echo json_encode($responseNode);
}
else($requestobj->Value == 'operator'){

$responseObject["Select"] = array();
$responseObject["Select"][] = array("title"=>"Enter something","return"=>"something");
$responseObject["Select"][] = array("title"=>"Link (go to website)","url"=>"http://www.livezilla.net","return"=>"");
$responseObject["Select"][] = array("title"=>"Run some Javascript (JS)","script"=>"alert(123);","return"=>"");
$responseObject["Select"][] = array("title"=>"Start a Chat","action"=>"chat","operator"=>"administrator","group"=>"support");
$responseObject["Select"][] = array("title"=>"Leave a Message","action"=>"message","group"=>"support");
$responseObject["Value"] = "Thanks for testing me. Here's a list of options, please click something or type 'list' to reset.";
}

?>





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users