예외 분기 추가

main
JungJun 2 years ago
parent 810fde58aa
commit bcc608a580

@ -201,110 +201,110 @@ func (s *ScenarioSession) BOTPFunc(w http.ResponseWriter, r *http.Request) {
// case "space": // case "space":
// case "null": // case "null":
// } // }
}
////////////////////////////////////
//////// SCENARIO MAPPING///////////
////////////////////////////////////
// 현재 들어온 method로 분기
// next 시나리오로 넘겨주기
fmt.Printf("response %+v", request)
if request.Method == "HANGUP" {
response.ResultCode = 200
response.Token = request.Token
response.Action = ""
response.AnounceMents = ""
response.Data.BargeIn = ""
response.Data.RecodingFile = ""
response.Data.SttMaxTime = 10
} else if request.Method != "INIT" && request.TalkText == "" {
response.ResultCode = 200
response.Token = request.Token
if s.session[request.Token].NotUnderstand == 3 {
response.AnounceMents = "잘 이해하지 못했습니다. 정확한 상담을 위해 매장으로 연결해드릴게요."
response.Action = "END"
} else {
response.AnounceMents = "잘 이해하지 못했습니다. 다시 말씀해주세요."
response.Action = "STT"
s.session[request.Token] = ResStatus{Count: 1, Status: scnarioConf.Order[0], NotUnderstand: s.session[request.Token].NotUnderstand + 1}
}
response.Data.BargeIn = ""
response.Data.RecodingFile = ""
response.Data.SttMaxTime = 10
} else { } else {
////////////////////////////////////
//////// SCENARIO MAPPING///////////
////////////////////////////////////
// 현재 들어온 method로 분기
// next 시나리오로 넘겨주기
fmt.Printf("response %+v", request)
if request.Method == "HANGUP" { if request.Method == "HANGUP" {
s.ByeCheck(request.Method, request.Token) response.ResultCode = 200
} else { response.Token = request.Token
switch request.Method { response.Action = ""
case "INIT": response.AnounceMents = ""
token := createToken(request.CallId) response.Data.BargeIn = ""
response.ResultCode = 200 response.Data.RecodingFile = ""
response.Token = token response.Data.SttMaxTime = 10
response.Action = scnarioConf.Order[1] } else if request.Method != "INIT" && request.TalkText == "" {
response.AnounceMents = scnarioConf.Value[0] response.ResultCode = 200
response.Data.BargeIn = scnarioConf.BargeIn[0] response.Token = request.Token
response.Data.RecodingFile = "Y" if s.session[request.Token].NotUnderstand == 3 {
response.Data.SttMaxTime = scnarioConf.SttMaxTime[0] response.AnounceMents = "잘 이해하지 못했습니다. 정확한 상담을 위해 매장으로 연결해드릴게요."
s.m.Lock()
s.session[token] = ResStatus{Count: 1, Status: scnarioConf.Order[0], NotUnderstand: 0}
s.m.Unlock()
case "STT":
response.ResultCode = 200
response.Token = request.Token
response.Action = scnarioConf.Order[s.session[request.Token].Count+1]
response.AnounceMents = scnarioConf.Value[s.session[request.Token].Count]
response.Data.BargeIn = scnarioConf.BargeIn[s.session[request.Token].Count]
response.Data.RecodingFile = "Y"
response.Data.SttMaxTime = scnarioConf.SttMaxTime[s.session[request.Token].Count]
s.m.Lock()
s.session[request.Token] = ResStatus{Count: s.session[request.Token].Count + 1, Status: scnarioConf.Order[s.session[request.Token].Count+1]}
s.m.Unlock()
case "DTMF":
response.ResultCode = 200
response.Token = request.Token
response.Action = scnarioConf.Order[s.session[request.Token].Count+1]
response.AnounceMents = scnarioConf.Value[s.session[request.Token].Count]
response.Data.BargeIn = "N"
response.Data.RecodingFile = "Y"
response.Data.SttMaxTime = 3
s.m.Lock()
s.session[request.Token] = ResStatus{Count: s.session[request.Token].Count + 1, Status: scnarioConf.Order[s.session[request.Token].Count+1]}
s.m.Unlock()
case "REFER":
response.ResultCode = 200
response.Token = request.Token
response.Action = "END" response.Action = "END"
response.AnounceMents = "네. 매장으로 연결해드릴게요." } else {
response.Data.BargeIn = "" response.AnounceMents = "잘 이해하지 못했습니다. 다시 말씀해주세요."
response.Data.RecodingFile = "" response.Action = "STT"
response.Data.SttMaxTime = 0 s.session[request.Token] = ResStatus{Count: 1, Status: scnarioConf.Order[0], NotUnderstand: s.session[request.Token].NotUnderstand + 1}
response.Data.TelNo = request.TelNo }
response.Data.BargeIn = ""
s.m.Lock() response.Data.RecodingFile = ""
s.session[request.Token] = ResStatus{Count: s.session[request.Token].Count + 1, Status: scnarioConf.Order[s.session[request.Token].Count+1]} response.Data.SttMaxTime = 10
s.m.Unlock() } else {
case "BYE": // 전화 종료 요청 if request.Method == "HANGUP" {
response.ResultCode = 200 s.ByeCheck(request.Method, request.Token)
response.Token = request.Token } else {
response.Action = "END" switch request.Method {
response.AnounceMents = "접수가 완료되었습니다." case "INIT":
response.Data.BargeIn = "Y" token := createToken(request.CallId)
response.Data.RecodingFile = "Y" response.ResultCode = 200
response.Data.SttMaxTime = 0 response.Token = token
// case "HANGUP": response.Action = scnarioConf.Order[1]
// response.ResultCode = 200 response.AnounceMents = scnarioConf.Value[0]
// response.Token = request.Token response.Data.BargeIn = scnarioConf.BargeIn[0]
// response.Action = "" response.Data.RecodingFile = "Y"
// response.AnounceMents = "" response.Data.SttMaxTime = scnarioConf.SttMaxTime[0]
// response.Data.BargeIn = ""
// response.Data.RecodingFile = "" s.m.Lock()
// response.Data.SttMaxTime = 0 s.session[token] = ResStatus{Count: 1, Status: scnarioConf.Order[0], NotUnderstand: 0}
// if ByeCheck(request.Method, request.Token) { s.m.Unlock()
// } case "STT":
response.ResultCode = 200
response.Token = request.Token
response.Action = scnarioConf.Order[s.session[request.Token].Count+1]
response.AnounceMents = scnarioConf.Value[s.session[request.Token].Count]
response.Data.BargeIn = scnarioConf.BargeIn[s.session[request.Token].Count]
response.Data.RecodingFile = "Y"
response.Data.SttMaxTime = scnarioConf.SttMaxTime[s.session[request.Token].Count]
s.m.Lock()
s.session[request.Token] = ResStatus{Count: s.session[request.Token].Count + 1, Status: scnarioConf.Order[s.session[request.Token].Count+1]}
s.m.Unlock()
case "DTMF":
response.ResultCode = 200
response.Token = request.Token
response.Action = scnarioConf.Order[s.session[request.Token].Count+1]
response.AnounceMents = scnarioConf.Value[s.session[request.Token].Count]
response.Data.BargeIn = "N"
response.Data.RecodingFile = "Y"
response.Data.SttMaxTime = 3
s.m.Lock()
s.session[request.Token] = ResStatus{Count: s.session[request.Token].Count + 1, Status: scnarioConf.Order[s.session[request.Token].Count+1]}
s.m.Unlock()
case "REFER":
response.ResultCode = 200
response.Token = request.Token
response.Action = "END"
response.AnounceMents = "네. 매장으로 연결해드릴게요."
response.Data.BargeIn = ""
response.Data.RecodingFile = ""
response.Data.SttMaxTime = 0
response.Data.TelNo = request.TelNo
s.m.Lock()
s.session[request.Token] = ResStatus{Count: s.session[request.Token].Count + 1, Status: scnarioConf.Order[s.session[request.Token].Count+1]}
s.m.Unlock()
case "BYE": // 전화 종료 요청
response.ResultCode = 200
response.Token = request.Token
response.Action = "END"
response.AnounceMents = "접수가 완료되었습니다."
response.Data.BargeIn = "Y"
response.Data.RecodingFile = "Y"
response.Data.SttMaxTime = 0
// case "HANGUP":
// response.ResultCode = 200
// response.Token = request.Token
// response.Action = ""
// response.AnounceMents = ""
// response.Data.BargeIn = ""
// response.Data.RecodingFile = ""
// response.Data.SttMaxTime = 0
// if ByeCheck(request.Method, request.Token) {
// }
}
} }
} }
} }

Loading…
Cancel
Save