김예미

Edit Template 3

...@@ -26,11 +26,14 @@ exports.handlePostback = (sender_psid, received_postback) => { ...@@ -26,11 +26,14 @@ exports.handlePostback = (sender_psid, received_postback) => {
26 if(payload === 'Greeting'){ 26 if(payload === 'Greeting'){
27 response = template.greetingTemplate(); 27 response = template.greetingTemplate();
28 callSendAPI(sender_psid, response); 28 callSendAPI(sender_psid, response);
29 - }else if(payload === 'CHOICE_BY_PROF'){ 29 + }
30 +
31 + let first_choice = payload.first_choice;
32 + if(first_choice=== 'CHOICE_BY_PROF'){
30 handlePostback_choiceByProf(sender_psid, received_postback); 33 handlePostback_choiceByProf(sender_psid, received_postback);
31 - }else if(payload === 'CHOICE_BY_LECT'){ 34 + }else if(first_choice=== 'CHOICE_BY_LECT'){
32 handlePostback_choiceByLect(sender_psid, recieved_postback); 35 handlePostback_choiceByLect(sender_psid, recieved_postback);
33 - }else if(payload === 'HELP'){ 36 + }else if(first_choice=== 'HELP'){
34 handlePostback_help(sender_psid, recieved_postback); 37 handlePostback_help(sender_psid, recieved_postback);
35 } 38 }
36 } 39 }
...@@ -38,7 +41,7 @@ exports.handlePostback = (sender_psid, received_postback) => { ...@@ -38,7 +41,7 @@ exports.handlePostback = (sender_psid, received_postback) => {
38 const handlePostback_choiceByProf = (sender_psid, received) => { 41 const handlePostback_choiceByProf = (sender_psid, received) => {
39 let response; 42 let response;
40 43
41 - let stat = received.stat; 44 + let stat = received.payload.stat;
42 45
43 if(stat === 'stat_0'){ 46 if(stat === 'stat_0'){
44 response = template.getProfNameTemplate(received); 47 response = template.getProfNameTemplate(received);
...@@ -76,7 +79,7 @@ const handlePostback_help = (sender_psid, received) => { ...@@ -76,7 +79,7 @@ const handlePostback_help = (sender_psid, received) => {
76 79
77 if(stat === 'stat_0'){ 80 if(stat === 'stat_0'){
78 response = template.howToTemplate(received); 81 response = template.howToTemplate(received);
79 - }else if(stat ==== 'stat_1'){ 82 + }else if(stat === 'stat_1'){
80 response = template.goToGreetTemplate(received); 83 response = template.goToGreetTemplate(received);
81 } 84 }
82 callSendAPI(sender_psid, response); 85 callSendAPI(sender_psid, response);
...@@ -84,7 +87,7 @@ const handlePostback_help = (sender_psid, received) => { ...@@ -84,7 +87,7 @@ const handlePostback_help = (sender_psid, received) => {
84 87
85 // Sends response messages via the Send API 88 // Sends response messages via the Send API
86 const callSendAPI = (sender_psid, response, cb = null) => { 89 const callSendAPI = (sender_psid, response, cb = null) => {
87 - 90 + console.log('response:'+response);
88 // Send the HTTP request to the Messenger Platform 91 // Send the HTTP request to the Messenger Platform
89 request({ 92 request({
90 "url": "https://graph.facebook.com/v2.6/me/messages", 93 "url": "https://graph.facebook.com/v2.6/me/messages",
......
...@@ -13,23 +13,26 @@ exports.greetingTemplate = () => { ...@@ -13,23 +13,26 @@ exports.greetingTemplate = () => {
13 { 13 {
14 "type":"postback", 14 "type":"postback",
15 "title":greetingTitle[0], 15 "title":greetingTitle[0],
16 - "payload":"CHOICE_BY_PROF", 16 + "payload":{
17 - "stat":"stat_0", 17 + first_choice:"CHOICE_BY_PROF",
18 - "rate":{} 18 + stat:"stat_0"
19 + }
19 }, 20 },
20 { 21 {
21 "type":"postback", 22 "type":"postback",
22 "title":greetingTitle[1], 23 "title":greetingTitle[1],
23 - "payload":"CHOICE_BY_LECT", 24 + "payload":{
24 - "stat":"stat_0", 25 + first_choice:"CHOICE_BY_LECT",
25 - "rate":{} 26 + stat: "stat_0"
27 + }
26 }, 28 },
27 { 29 {
28 "type":"postback", 30 "type":"postback",
29 "title":greetingTitle[2], 31 "title":greetingTitle[2],
30 - "payload":"HELP", 32 + "payload":{
31 - "stat":"stat_0", 33 + first_choice:"HELP",
32 - "rate":{} 34 + stat: "stat_0"
35 + }
33 } 36 }
34 ] 37 ]
35 } 38 }
...@@ -49,9 +52,11 @@ exports.getProfNameTemplate = (received) => { ...@@ -49,9 +52,11 @@ exports.getProfNameTemplate = (received) => {
49 { 52 {
50 "type":"postback", 53 "type":"postback",
51 "title":"처음으로", 54 "title":"처음으로",
52 - "payload":'Greeting', 55 + "payload":{
53 - "stat": 'stat_0', 56 + first_choice:'Greeting',
54 - "rate":{} 57 + stat:'stat_0',
58 + rate:{}
59 + }
55 } 60 }
56 ] 61 ]
57 } 62 }
...@@ -61,6 +66,8 @@ exports.getProfNameTemplate = (received) => { ...@@ -61,6 +66,8 @@ exports.getProfNameTemplate = (received) => {
61 66
62 exports.choiceLectOfProfTemplate = (received) => { 67 exports.choiceLectOfProfTemplate = (received) => {
63 //메세지 68 //메세지
69 + return{text: "성공"}
70 +
64 } 71 }
65 72
66 exports.rateTemplate = (received) => { 73 exports.rateTemplate = (received) => {
......