So I am creating a click2call app, using Tropo and Nexmo, and at this point, I need help setting a webhook. They both provide a place to point a webhook, but now, I don't understand what to include there. Is it a php file? or a json? I've already tried to create a php and had the following:
<?php
header('Content-Type: application/json');
ob_start();
$json = file_get_contents('php://input');
$request = json_decode($json, true);
$action = $request["result"]["action"];
$parameters = $request["result"]["parameters"];
$output["contextOut"] = array(array("name" => "$next-context", "parameters" =>
array("param1" => $param1value, "param2" => $param2value)));
$output["speech"] = $outputtext;
$output["displayText"] = $outputtext;
$output["source"] = "whatever.php";
ob_end_clean();
echo json_encode($output);
?>
how can I later retrieve the information from my webhook and store it in a DB? I've seen pieces of code, but I have no idea where to include it... is it in my api, in the php file that my webhook points?? Thank you in advance.
A webhook url is a place on your server where the above providers will send data from time to time when something happens and you need to know about, for example you might get a request each time a sms is sent, or each time a sms fails sending and based on that info you can take further actions, like marking the fact that user phone number isn't valid anymore.
Let's say your webhook url is something like https://www.yoursite.com/webhooks.php
which means in your webhooks.php
file you have to place some PHP code that will read the incoming request and will do something with the information that it contains.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With