0
나는 php webhook을 가지고 있습니다. Heroku에서 호스팅하고 있습니다. 내가 api.ai에서 테스트 할 때 로봇은 내가 원하는 방식대로 응답하므로 작동합니다. 내 질문은 : webhook에서 이메일을 보내거나 텍스트를 데이터베이스에 삽입하려면 어떻게해야합니까? 당신은 부품의 대부분은 당신이 필요로하는 것을 합친 것 같다Api.ai는 php webhook에서 이메일을 보냅니다.
<?php
$method = $_SERVER['REQUEST_METHOD'];
//$msg = "First line of text\nSecond line of text";
// use wordwrap() if lines are longer than 70 characters
//$msg = wordwrap($msg,70);
// send email
//mail("[email protected]","My subject",$msg);
// Process only when method is POST
if($method == 'POST'){
$requestBody = file_get_contents('php://input');
$json = json_decode($requestBody);
$equis = $json->result->parameters->equis;
switch ($equis) {
case 'hi':
$speech = "Hi, Nice to meet you";
break;
case 'bye':
$speech = "Bye, good night";
break;
case 'anything':
$speech = "Yes, you can type anything here.";
break;
default:
$speech = "Sorry, I didnt get that. Please ask me something
else.";
break;
}
$response = new \stdClass();
$response->speech = $speech;
$response->displayText = $speech;
$response->source = "Alex";
echo json_encode($response);
}
else
{
echo "Method not allowed";
}
?>
이메일이 콜백에 의해 매개 변수로 보내지 는가? * PHP로 이메일을 보내려면 어떻게해야합니까? 아니면 컨텍스트 액션 *에서 이메일을 어떻게 일치 시키나요? –
btw 이행은 데이터를 수집했거나 추가 데이터를 쿼리해야하는 경우를위한 것이며 기본 봇 응답이 아니라 의도로 수행해야합니다. –
이메일에 $ spech를 보내고 싶지만 어떻게 할 수 있는지 잘 모릅니다. –