스킬서버를 구축하여 카카오톡 챗봇을 사용하면 더 자유롭게 사용할 수 있다.

php로 아주 간단히 simpletext로 응답을 보내는 방법을 설명하겠다.

 

1. 블록 수정

 

2. 응답 예시

- 응답은 다음과 같은 json 형태로 올 것이다.

3. 코드

~~/kakaochat/index.php

<?
$json_data = file_get_contents("php://input"); 
$obj_json = json_decode($json_data);
$singer = $obj_json->action->detailParams->singer->value;
$num_album = $obj_json->action->detailParams->num_album->origin;


$text = '주문확인 : '.$singer.'의 '.$num_album.'을 주문하셨습니다.';
$jayParsedAry = [
	"version" => "2.0", 
	"template" => [
		"outputs" => [
			[
				"simpleText" => [
					"text" => $text
				]
			]
		]
	]
];

echo json_encode($jayParsedAry,JSON_UNESCAPED_UNICODE);
?>

 

 

4. 카카오톡 챗봇 > 스킬 > 스킬 명 및 스킬서버 URL 입력 

 

 

5. 예시

 


WRITTEN BY
beautifulhill

,