ETC/기타

[Aog] Dialogflow 와 java와 연동하기 (2)

지과쌤 2020. 7. 9.

목차

반응형

 

[Aog] Dialogflow 와 java와 연동하기 (2)

https://earthteacher.tistory.com/18

 

[Aog] Dialogflow 와 java와 연동하기 (1)

developers.google.com/assistant/conversational/df-asdk/overview Conversational Actions  | Dialogflow and legacy Actions SDK Conversational Actions extend the functionality of the Google Assistant b.....

earthteacher.tistory.com

 

이어서 조금 더 응용하여 Dialogflow 에서 인자를 받아와 다시 출력해보도록 하겠습니다.

 


[Aog] Dialogflow 와 java와 연동하기 (2)

날짜에 대해서 처리해볼 예정이기때문에 간단하게 whatDay 라는 entity를 만들어주고 reference value와 synonym을 간단하게 입력해주도록 하겠습니다.

 


[Aog] Dialogflow 와 java와 연동하기 (2)

이제 위의 entity를 처리할 intent를 생성해줍니다.

 

intent의 이름은 day 로 하였고, training pharases에 발화를 추가하였습니다.

 

whatDay라는 entity가 synonym를 감지하여 어제, 오늘 문구에 표시가 생긴것을 확인할 수 있습니다.

 

위의 synonym 부분에 있는 단어들을 능동적으로 감지하여 하나의 reference value로 처리하게되므로, 

 

intent - training pharases 에 어저께, 지금 과 같은 단어를 넣어도 감지하게 됩니다.

 

이후 reference value가 whatday(소문자 parameter name 이다) 값이 되게 됩니다.

 

Intent - day

	@ForIntent("day")
	public ActionResponse dayView(ActionRequest request) throws ExecutionException, InterruptedException {
		ResponseBuilder rb = getResponseBuilder(request);
		String date = CommonUtil.makeSafeString(request.getParameter("whatday"));

		SimpleResponse simpleResponse = new SimpleResponse();

		simpleResponse.setTextToSpeech(date + " 의 일정을 보여드릴게요.")
				.setDisplayText(date + " 의 일정을 보여드릴게요.")
		;

		rb.add(simpleResponse);

		return rb.build();
	}

request.getParameter("whatday"); -> 이 부분에서 whatday에 해당하는 값을 받아오고, 해당하는 값이 string 타입이 아니기때문에 CommonUtil을 활용하여 강제 형변환을 해준 후 string 타입의 변수 date에 저장해줍니다.

 

이후 TTS 또는 text view 에 변수를 함께 넣어 빌드!

 


[Aog] Dialogflow 와 java와 연동하기 (2)

 

오늘 경기 해? 라고 물어봤을때, "오늘" 을 함께 출력해주게 된다.

 

좀더 자세한 부분들은 추가적으로 공부 후 기술해보도록 하겠습니다.

 

 

반응형

댓글