Jump to content


LiveZilla and Program-O chat bot


3 replies to this topic

#1 thomas.stock

    Newbie

  • Members
  • Pip
  • 3 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
  • 3377 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
  • 3 posts

Posted 07 February 2018 - 02:39 PM

Great! Sounds good to me!

#4 thomas.stock

    Newbie

  • Members
  • Pip
  • 3 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!





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users