diff --git a/icshttp/handler.go b/icshttp/handler.go index da992b7..a035062 100644 --- a/icshttp/handler.go +++ b/icshttp/handler.go @@ -68,8 +68,9 @@ type ResData struct { } type ResStatus struct { - Count int - Status string + Count int + Status string + NotUnderstand int } type ScenarioSession struct { @@ -180,11 +181,24 @@ func (s *ScenarioSession) BOTPFunc(w http.ResponseWriter, r *http.Request) { // 현재 들어온 method로 분기 // next 시나리오로 넘겨주기 fmt.Printf("response %+v", request) - if request.Method != "INIT" && request.TalkText == "" { + 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 response.Action = "END" - response.AnounceMents = "잘 이해하지 못했습니다. 다시 말씀해주세요." + if s.session[request.Token].NotUnderstand == 3 { + response.AnounceMents = "잘 이해하지 못했습니다. 정확한 상담을 위해 매장으로 연결해드릴게요." + } else { + response.AnounceMents = "잘 이해하지 못했습니다. 다시 말씀해주세요." + 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 @@ -204,7 +218,7 @@ func (s *ScenarioSession) BOTPFunc(w http.ResponseWriter, r *http.Request) { response.Data.SttMaxTime = scnarioConf.SttMaxTime[0] s.m.Lock() - s.session[token] = ResStatus{Count: 1, Status: scnarioConf.Order[0]} + s.session[token] = ResStatus{Count: 1, Status: scnarioConf.Order[0], NotUnderstand: 0} s.m.Unlock() case "STT": response.ResultCode = 200