김예미

Edit Template 3

......@@ -26,11 +26,14 @@ exports.handlePostback = (sender_psid, received_postback) => {
if(payload === 'Greeting'){
response = template.greetingTemplate();
callSendAPI(sender_psid, response);
}else if(payload === 'CHOICE_BY_PROF'){
}
let first_choice = payload.first_choice;
if(first_choice=== 'CHOICE_BY_PROF'){
handlePostback_choiceByProf(sender_psid, received_postback);
}else if(payload === 'CHOICE_BY_LECT'){
}else if(first_choice=== 'CHOICE_BY_LECT'){
handlePostback_choiceByLect(sender_psid, recieved_postback);
}else if(payload === 'HELP'){
}else if(first_choice=== 'HELP'){
handlePostback_help(sender_psid, recieved_postback);
}
}
......@@ -38,7 +41,7 @@ exports.handlePostback = (sender_psid, received_postback) => {
const handlePostback_choiceByProf = (sender_psid, received) => {
let response;
let stat = received.stat;
let stat = received.payload.stat;
if(stat === 'stat_0'){
response = template.getProfNameTemplate(received);
......@@ -76,7 +79,7 @@ const handlePostback_help = (sender_psid, received) => {
if(stat === 'stat_0'){
response = template.howToTemplate(received);
}else if(stat ==== 'stat_1'){
}else if(stat === 'stat_1'){
response = template.goToGreetTemplate(received);
}
callSendAPI(sender_psid, response);
......@@ -84,7 +87,7 @@ const handlePostback_help = (sender_psid, received) => {
// Sends response messages via the Send API
const callSendAPI = (sender_psid, response, cb = null) => {
console.log('response:'+response);
// Send the HTTP request to the Messenger Platform
request({
"url": "https://graph.facebook.com/v2.6/me/messages",
......
......@@ -13,23 +13,26 @@ exports.greetingTemplate = () => {
{
"type":"postback",
"title":greetingTitle[0],
"payload":"CHOICE_BY_PROF",
"stat":"stat_0",
"rate":{}
"payload":{
first_choice:"CHOICE_BY_PROF",
stat:"stat_0"
}
},
{
"type":"postback",
"title":greetingTitle[1],
"payload":"CHOICE_BY_LECT",
"stat":"stat_0",
"rate":{}
"payload":{
first_choice:"CHOICE_BY_LECT",
stat: "stat_0"
}
},
{
"type":"postback",
"title":greetingTitle[2],
"payload":"HELP",
"stat":"stat_0",
"rate":{}
"payload":{
first_choice:"HELP",
stat: "stat_0"
}
}
]
}
......@@ -49,9 +52,11 @@ exports.getProfNameTemplate = (received) => {
{
"type":"postback",
"title":"처음으로",
"payload":'Greeting',
"stat": 'stat_0',
"rate":{}
"payload":{
first_choice:'Greeting',
stat:'stat_0',
rate:{}
}
}
]
}
......@@ -61,6 +66,8 @@ exports.getProfNameTemplate = (received) => {
exports.choiceLectOfProfTemplate = (received) => {
//메세지
return{text: "성공"}
}
exports.rateTemplate = (received) => {
......