Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- func (df *DFClient) DetectIntents() {
- for req := range df.RequestChannel {
- go func() {
- // TODO implement intent requests
- temp := df.getIntent(
- viper.GetString(agent),
- strconv.Itoa(int(req.ID)), // TODO CHECK THIS CONVERSION
- viper.GetString(lang),
- req.Request,
- )
- req.Response = temp.QueryResult.FulfillmentText
- req.Intent = temp.QueryResult.Intent.Name
- req.Confidence = temp.QueryResult.IntentDetectionConfidence
- df.ResponseChannel <- req
- }()
- }
- }
- //Utility wrapper to get response from DialogFlowClient when parsing text messages.
- func (df *DFClient) getIntent(BotId string, DFSessionID string, LangCode string, msg string) *dfproto.DetectIntentResponse {
- req := &dfproto.DetectIntentRequest{
- Session: "projects/" + BotId + "/agent/sessions/" + DFSessionID,
- QueryParams: &dfproto.QueryParameters{},
- QueryInput: &dfproto.QueryInput{
- Input: &dfproto.QueryInput_Text{
- Text: &dfproto.TextInput{
- Text: msg,
- LanguageCode: LangCode,
- },
- },
- },
- }
- fmt.Println(req)
- res, err := df.SessionClient.DetectIntent(context.Background(), req)
- if err != nil {
- log.Fatal(err)
- }
- return res
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement