티스토리 뷰

REF: https://actions-on-google.github.io/actions-on-google-nodejs/classes/dialogflow.dialogflowconversation.html


지역정보를 얻을려면 권한이 필요하다.

 아래의 코드를 쓴다.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
app.intent(ALLROUND_INTENT, (conv, confirmationGranted) => {
  conv.data.fallbackCount = 0;
  console.log("confirmationGranted: ", confirmationGranted)
  if (Object.keys(confirmationGranted).length === 0) { //권한 없으면
 
    //https://developers.google.com/actions/assistant/helpers
    //위치 퍼미션 받는 intent
 
    // Choose one or more supported permissions to request:
    // NAME, DEVICE_PRECISE_LOCATION, DEVICE_COARSE_LOCATION
    const options = {
      context: '이름과 지역정보가 필요합니다.',
      // Ask for more than one permission. User can authorize all or none.
      permissions: ['NAME''DEVICE_PRECISE_LOCATION'],
    };
    conv.ask(new Permission(options));
 
  } else { // 권한을 얻었다면 작업 시작
    
  }
 
});
Colored by Color Scripter
cs

권한이 필요한 곳에 이렇게 쓴다

권한이 없으면 Permission 작업을 한다. 여기선 이름과 위치정보를 받아온다.

confirmationGranted로 현재권이 있는지없는지 구분을 해준다.




dialogflow에 Yes or No 작업을 넣어주고 또하나의 각 Intent 별로 만들어준다.


1
2
3
4
5
6
7
8
9
10
11
12
//actions_intent_PERMISSION
app.intent(ALLROUND_INTENT_YES, (conv, confirmationGranted) => {
  conv.data.fallbackCount = 0;
  console.log("confirmationGranted: ", confirmationGranted)
  conv.followup("aroundAll");
});

app.intent(ALLROUND_INTENT_NO, (conv, confirmationGranted) => {
  conv.data.fallbackCount = 0;
  console.log("confirmationGranted: ", confirmationGranted)
  conv.followup("start");
});

cs




Yes Intent 에는 Dialogflow에 actions_intent_PERMISSION 을 이벤트에 넣어준다.


 conv.followup("start"); 이게 궁금할 수 있는데


followup은 바로 넘겨주는 conv 이다. event이름으로 지정된 intent로 돌려버린다.






공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2024/04   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
글 보관함