2017-11-06 6 views
0

gupshup.io를 사용하여 스크립팅 방법을 사용하여 봇을 만들지 만 문서에서 언급 한 default.js 파일의 일부를 처리합니다. 처리기에서 처리 중입니다. 함수를 사용하여 event.message가 스크립트의 다른 섹션으로 이동하기위한 특정 문자열과 같은지 확인하십시오. 아무도 도와 줄 수 있습니까? 고마워요스크립트의 다른 섹션으로 이동하는 방법

답변

1

그래서 여러분은 자식 상태를 만들어 다른 섹션으로 이동하여 options.next_state를 그 상태로 설정할 수 있습니다. 이 스크립트가 있다고 가정 해 봅시다.

[main] 
    inputParser:Welcome to New Bot. 
      thisFlow: 
       This is a output of this flow. 
      callAnotherFlow: 
       :call default.anotherFlow 
[anotherFlow] 
    This is another flow.[[Wow, No]] 
     Wow 
      Thanks 
     No 
      Oh! 

메시지가 '다른 플로우'인 경우 두 번째 플로우를 시작하려는 경우에 대비하십시오. 따라서 입력 파서에서는 다음과 같은 것을 만들 수 있습니다.

module.exports.main = { 
    inputParser: (options, event, context, callback)=>{ 
     if(event.message.toLowerCase() === "another flow"){ 
      options.next_state = 'callAnotherFlow'; 
     }else{ 
      options.next_state = 'thisFlow'; 
     } 
     callback(options, event, context); 
    } 
} 

나는 이것이 당신이 찾고있는 것이라고 생각합니다.

+0

감사합니다. dozen @agnibha –