This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
} else if(event.message.text === 'revoke') { | |
let token = await admin.database().ref('token').child(event.source.userId).once('value'); | |
await initialLINE(token.val().token_type, token.val().access_token ); | |
await admin.database().ref('token').child(event.source.userId).remove(); | |
// 13. Reply result to User Chat Room | |
// 14. Revoke Access Token | |
} | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
} else if(event.message.text === 'revoke') { | |
let token = await admin.database().ref('token').child(event.source.userId).once('value'); | |
await initialLINE(token.val().token_type, token.val().access_token ); | |
await admin.database().ref('token').child(event.source.userId).remove(); | |
await reply(event.replyToken, { | |
type: 'text', | |
text: '\uDBC0\uDC9C ลบ token เรียบร้อยแล้ว จะใช้มาขอใหม่น้าา' | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const revoke_access_token = (access_token) => { | |
let params = { | |
access_token: access_token | |
}; | |
let formData = querystring.stringify(params); | |
return request.post({ | |
uri: `${LINE_OAUTH_API}/revoke`, | |
headers: { | |
"Content-Type": "application/x-www-form-urlencoded" | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
} else if(event.message.text === 'revoke') { | |
let token = await admin.database().ref('token').child(event.source.userId).once('value'); | |
await initialLINE(token.val().token_type, token.val().access_token ); | |
await admin.database().ref('token').child(event.source.userId).remove(); | |
await reply(event.replyToken, { | |
type: 'text', | |
text: '\uDBC0\uDC9C ลบ token เรียบร้อยแล้ว จะใช้มาขอใหม่น้าา' | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const REGION = 'asia-northeast1' | |
const runtimeOpts = { | |
timeoutSeconds: 10, | |
memory: "2GB" | |
} | |
const functions = require('firebase-functions') | |
const {WebhookClient, Payload} = require("dialogflow-fulfillment") | |
const message = require('./message') | |
let parameters |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exports.size_filling = () => ({ | |
"type": "text", | |
"text": "คุณต้องการซื้อเสื้อ size อะไร?", | |
"quickReply": { | |
"items": [{ | |
"type": "action", | |
"action": { | |
"type": "message", | |
"label": "S", | |
"text": "S" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"line": { | |
"type": "flex", | |
"altText": "Flex Message", | |
"contents": { | |
"type": "carousel", | |
"contents": [{ | |
"type": "bubble", | |
"direction": "ltr", | |
"hero": { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const region = 'asia-northeast1'; | |
const functions = require('firebase-functions'); | |
const request = require('request-promise'); | |
const LINE_MESSAGING_API = "https://api.line.me/v2/bot/message"; | |
const LINE_HEADER = { | |
"Content-Type": "application/json", | |
"Authorization": "Bearer CHANNEL_ACCESS_TOKEN" | |
}; | |
// 1. Import Dialogflow library | |
// 2. define dialogflow projectId |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const structjson = require('./structjson'); | |
const intentResponseMessage = intentResponse.queryResult.fulfillmentMessages | |
const replyMessage = intentResponseMessage.map( (messageObj) => { | |
let struct | |
if (messageObj.message === "text") { | |
return {type: "text", text: messageObj.text.text[0] } | |
} else if(messageObj.message === "payload") { | |
struct = messageObj.payload | |
return structjson.structProtoToJson(struct) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
request({ | |
method: "POST", | |
uri: `${LINE_MESSAGING_API}/reply`, | |
headers: LINE_HEADER, | |
body: JSON.stringify({ | |
replyToken: event.replyToken, | |
messages: replyMessage | |
}) | |
}) |