Jump to content


ChatBot API with Javascript


  • You cannot reply to this topic
No replies to this topic

#1 cstanleyhns

    Advanced Member

  • Members
  • PipPipPip
  • 46 posts

Posted 13 November 2018 - 02:42 PM

Hi All,

I want to retrieve some stored values either from a cookie or run so javascript to get the values. Is it possible to call a JS function for the chatbot php script or to fetch cookie values from the php script?

Here is a basic script with where i would have thought the JS could go:

<?php

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

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

if($requestobj->Value != "[__[EXIT]__]")
{
// first user interaction
if($requestobj->ResponseTo == "")
{
// Call a JS function from here
}
}
else
{
say good bye
$responseNode["Id"] = "action:end_chat";
$responseNode["Value"] = "Take care, bye!";
$responseNode["Block"] = false;
}
echo json_encode($responseNode);
?>


<script>
// Here would be the JS function(){}
</script>





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users