0
私はphoku 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";
}
?>
電子メールはコールバックによってparamとして送信されていますか?* PHPで質問を送信するにはどうしたらいいですか?または*それはコンテキストアクション*でメールをどのように一致させますか? –
btwフルフィルメントは、データを収集したか、追加のデータを照会する必要がある場合に使用します。基本的なボットレスポンスではなく、インテントで行う必要があります。 –
私は電子メールで$ spechを送信したいが、どうすればよいのか分からない –