Begin Block은 이전에 저희가 살펴봤던 RiveScript brain의 선택적 기능입니다.
brain에 관한 자세한 내용은 [Tutorial] The Begin File 에서 설명하고 있습니다.
Begin Block또한 begin.rive에 포함되고 토픽과 비슷한 형태로 동작합니다. 예를 들어 보겠습니다.
> begin
+ request
- {ok}
< beginBegin Block 응답을 가져오기 위한 전처리와 후처리로 사용됩니다.
Begin Block이 있으면 사용자가 말하는 각 메시지에 대해 요청 트리거가 작동됩니다.
응답에 {ok}태그가 있으면 사용자 메시지에 대한 응답을 가져오게 됩니다.
> begin
// If we don't know their name, set the new_user topic and continue.
+ request
* <get met> == undefined => <set met=true>{topic=new_user}{ok}
- {ok}
< begin
> topic new_user
+ *
- Hi! I'm <bot name>! I'm a chatbot written in RiveScript.\s
^ What is your name?{topic=asked_name}
< topic
> topic asked_name
+ #
- Your name is a number?
+ *
- I only want your first name.
+ _
- <set name=<formal>>Nice to meet you, <get name>!{topic=random}
< topicrequest는 어떤 메시지는 들어 왔을 때 {topic=new_user}로 넘어가게 됩니다. 그리고 이름을 받도록 토픽을 설정해 놨는데 숫자나 특수문자가 아닌 <formal>문자가 들어 왔을 때 이름을 저장하고 토픽 {topic=random}으로 넘어오게 됩니다.
'프로그래밍 > RiveScript' 카테고리의 다른 글
| [Tutorial] TAGS (0) | 2017.03.09 |
|---|---|
| [Tutorial] MORE DEFINITIONS (0) | 2017.03.09 |
| [Tutorial] Topics (0) | 2017.03.09 |
| [Tutorial] Conditionals (0) | 2017.03.09 |
| [Tutorial] Short Discussions (2) | 2017.03.09 |