/var/www/doncode.com.ua/www/webhooks
NameSizeModeActions
newfile.txt240666editdlrm
webhook.php27450644editdlrm
Edit: /var/www/doncode.com.ua/www/webhooks/webhook.php (2745B)
$update["responseId"], "fulfillmentText"=>"Hello from webhook", "payload" => array( "items"=>[ array( "simpleResponse"=> array( "textToSpeech"=>"response from host" ) ) ], ), )); }else if($update["queryResult"]["action"] == "convert"){ if($update["queryResult"]["parameters"]["outputcurrency"] == "USD"){ $amount = intval($update["queryResult"]["parameters"]["amountToConverte"]["amount"]); $convertresult = $amount * 360; } sendMessage(array( "source" => $update["responseId"], "fulfillmentText"=>"The conversion result is".$convertresult, "payload" => array( "items"=>[ array( "simpleResponse"=> array( "textToSpeech"=>"The conversion result is".$convertresult ) ) ], ), )); }else{ sendMessage(array( "source" => $update["responseId"], "fulfillmentText"=>"Error", "payload" => array( "items"=>[ array( "simpleResponse"=> array( "textToSpeech"=>"Bad request" ) ) ], ), )); } } function sendMessage($parameters) { echo json_encode($parameters); } $update_response = file_get_contents("php://input"); $update = json_decode($update_response, true); if (isset($update["queryResult"]["action"])) { processMessage($update); $myfile = fopen("newfile.txt", "w") or die("Unable to open file!"); fwrite($myfile, $update["queryResult"]["action"]); fclose($myfile); }else{ file_put_contents("newfile.txt","RX ".$_SERVER['REMOTE_ADDR']."\n",FILE_APPEND); sendMessage(array( "source" => $update["responseId"], "fulfillmentText"=>"Hello from webhook", "payload" => array( "items"=>[ array( "simpleResponse"=> array( "textToSpeech"=>"Bad request" ) ) ], ), )); } ?>