
Features
Facebook chat can custom response such as image, video, custom buttons. It can also add pay feature how ever still in demo.
I have a FB page about room rental. For my chatbot, I want it to introduct some basic room types and if customer asks a too complicated question, I’ll have a generic response.
User Story
- [ ] User should see a getting started button
- [ ] User see a welcome message
- [ ] User see options have room types, price, features
- [ ] User should see a generic phone number and message for complicated response
Code
Change default message response
12345678910111213app.post('/webhook/', function(req, res) {...if (event.postback && event.postback.payload === "getstarted") {sendText(sender, "歡迎來到高醫套房, 請問你想了解什麼?房型?價錢?特色")// welcome, what would you like to know? room types, price, features}if (event.message && event.message.text) {let text = event.message.textdecideMessage(sender, text)}}res.sendStatus(200)})Direct mapping for specific keyword
1234567891011121314function decideMessage(sender, text) {if (text.includes("房型")) { // Room TypessendText(sender, "我們這裡有一間5坪房間, 6間6坪房間, 2間7坪房間") // We have 15sq, 25 sq, 35sq room} else if ( text.includes("價錢")) { //PricesendText(sender, "長期約: 1年合約: 每月5500-6800$,2個月押金")// contract term is 1 year, monthly rent is 5500-6600, 2 months deposit} else if (text.includes("特色")) { // FeaturesendText(sender, "獨立廁所,雙人床,桌子椅子,電視,冰箱,冷氣,烘洗衣機")//bathroom, queen size bed, tv, fridge, ac....} else {sendText(sender, "如果有更多問題, 請打給 0800-123-333。 會有專人幫你服務")// if you have further question, please call...}}Setup welcome message
12345678910111213141516171819202122232425262728app.get('/setup', function(req, res){setupGetStartedButton(res);})function setupGetStartedButton(res){var messageData = {"get_started":{"payload":"getstarted"}};// Start the requestrequest({url: "https://graph.facebook.com/v2.6/me/messenger_profile?access_token="+ token,method: 'POST',headers: {'Content-Type': 'application/json'},form: messageData},function (error, response, body) {if (!error && response.statusCode == 200) {// Print out the response bodyres.send(body);} else {// TODO: Handle errorsres.send(body);}});}
More pictures


Thoughts
Facebook chatbot is still a new technology. Even more advanced chatbot such as cnn only maps user to news. I think the future is to have implement with a AI so chatbot can be more lively.