0
나는 node.js의 페이스 북 메신저 봇에서 일하고 있는데 봇이 나중에 보내도록 보내는 메시지에서 사용자 응답을 저장해야합니다. 변수.변수에 사용자 응답 저장하기 - 페이스 북의 메신저 봇 js
// defines that 'text' is any message sent by the user
let text = event.message.text
// if the user's text contains 'Savings', 'saving', 'calculator', or 'Calculator, the following conditions will occur:
if (text.search("Saving") >= 0 || text.search("saving") >= 0 || text.search("Calculator") >= 0 || text.search("calculator") >= 0) {
sendTextMessage(sender, "How much would you like to save?");
// here is where I want to store the response to how much money the user wants to save
}
모든 도움을 주시면 감사하겠습니다.
받는 사람이 보낸 다음 텍스트를 저장하는 방법을 알 수 없습니다. – sickguy125
그래서 예를 들어 돈을 얼마나 많이 저축해야하는지 물어 보면 '125'라고 대답하면받는 사람이 보낸 다음 텍스트가 '125'라고 판단 할 수 있어야합니다. – sickguy125
저장하는 경우 객체이면, 이전 값을 덮어 씁니다 : let messages = {}; 메시지 [user_psid] = 125 console.log (message [user_psid]) // 125 메시지 [user_psid] = "새 값" console.log (message [user_psid]) // "새 값 – amuramoto