Created
July 30, 2018 21:30
-
-
Save easterapps/91044dd672f23f5136668108b92801ed to your computer and use it in GitHub Desktop.
Simple PHP Webhook for Dialogflow v1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function processMessage($update) { | |
if($update["result"]["action"] == "test.welcome"){ | |
sendMessage(array( | |
"source" => $update["result"]["source"], | |
"speech" => "Hello World!", | |
"displayText" => "Hello World!", | |
"contextOut" => array() | |
)); | |
} | |
} | |
function sendMessage($parameters) { | |
echo json_encode($parameters); | |
} | |
$update_response = file_get_contents("php://input"); | |
$update = json_decode($update_response, true); | |
if (isset($update["result"]["action"])) { | |
processMessage($update); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment