chatbot framwork
故事是這樣子開始的.......
所以決定來寫寫看 chatbot
...要做啥呢
希望有的功能
做一個幫忙統計訂餐的聊天機器人
盡量減少規範達成判定
.......然後第一個挫折就是發現 FB
不讓 chatBot 加入多人對話
feature
核心構成
State - 麻將 -1 QAQ
Event - 問 Kevin Hu 要不要大膽 ++
State + Event => 不要,我要去跟__泡湯呢ლ(・ ิω・ิლ)
Kevin Hu
(ChatBot)
State + Event => Action(Response)
ChuChuJay
(User)
State + Event => Action(Response)
(State, Props) => UI
484 跟 react 很像呢
// state={ 大膽的人: 3, __約泡湯: true }
module.exports = async context => {
const { text } = context.event.message;
if (/要不要(大膽|打麻將|下棋|吃飯|)/.test(text) {
if (__約泡湯) {
context.sendText('不要,我要去跟__泡湯呢ლ(・ ิω・ิლ)')
} else {
context.sendText('來咩!不敢膩!')
}
}
};
紀錄一個對話開始到結束的關係
(ex: user )
Session
SessionStore
儲存 session 的地方
Context 代表一個 Event 發生時,我們當下要處理它的整個情境
// initialState={ ordering: false}
module.exports = async function App(context) {
//判斷是否開團
if (context.state.ordering) {
return isOrdering; // 開團中
}
return notOrdering; // 尚未開團
};
context
(from user)
紀錄 session
session Store
(to user)
change state
chatbot
歡迎幫忙優化或開發新功能 ><
client
server
提供 api
client
platform
提供 api
1. 必須要有一個 domain(不能只有 IP)
2. 要是 https
差異: 明/密文傳輸訊息
如何轉職
1. 了解對稱式加密
2. 再了解非對稱式加密
3. 只剩下證明我就是發出訊息的那個人
跟公正的第三方申請數位憑證,
好證明這個公鑰就是我的
=>
管理 cache 的一個方式
Least Recently Used cache
當有新朋友進來時又剛好沒位子時,
邊緣人會被踢出去
Read and write operations has to be in O(1) time complexity.
Read O(1)
insert O(1)
delete O(1)