How to do a pattern check for sentence after the OOB in chatscript

178 views Asked by At

I am trying to achieve something like this, I have an OOB data and some user entered text I am able to parse the OOB data which is a JSON. But I am not able to check the pattern for user entered data Test data in the below example input. Is there any suggestion how can I do this?

u: (< \[ * input _*  \] _*) ^keep() ^repeat() 
$inputData=_0 

$secondInput=%originalinput

getNameFromJson($inputData $secondInput)

$_tmp = ^jsonparse( $inputData ) 

\n name: $_tmp.user, phone: $_tmp.speed 

if(^match(TEST)) {
^reuse(TEST) 
} else if(match(THANKS)){
^reuse(THANKS) 
}

u: TEST (test)  ^keep() ^repeat()
    Some test impl

u: THANKS (~thankConcept)  ^keep() ^repeat()
    Glad to be of help.

My input is like [ input {user:"test", speed:10} ] Test data

1

There are 1 answers

0
rajan goswami On

In simplecontrol.top you can put following rule before MAIN

u: ( \[ _* \] )

$requestData = ^jsonparse(^original(_0))
^fail(SENTENCE)

$requestData will capture your JSON input (provided in OOB). ^fail() function is important here, as it will allow further processing of your input sentence. After above rule If you keep u: MAIN () as it is provided in simplecontrol.top of harry bot, you can match "Test Data" with following rule in any matching topic.

u: (Test Data) ^keep() ^repeat() Some test impl