Skip to content

Instantly share code, notes, and snippets.

@easterapps
Created July 30, 2018 21:30
Show Gist options
  • Save easterapps/91044dd672f23f5136668108b92801ed to your computer and use it in GitHub Desktop.
Save easterapps/91044dd672f23f5136668108b92801ed to your computer and use it in GitHub Desktop.
Simple PHP Webhook for Dialogflow v1
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