AI Zone Admin Forum Add your forum

NEWS: Chatbots.org survey on 3000 US and UK consumers shows it is time for chatbot integration in customer service!read more..

if/else in rules
 
 

if/else in rules is error?

this code

topic: ~MONGOCOUNSELOR keep repeat [WSMSG:OPEN]

t: (WSMSG:OPEN _*1) ^keep()
$cust=‘_0

$$jsonobject=^jsoncreate(object)

if (^mongoinit(mongodb://localhost:27017 test articles)) {}
else {init failed - $$mongo_error}

if (^mongofinddocument($cust)) {

$mongodata=^mongofinddocument($cust)
$$jsonstring = ^jsonparse($mongodata)
$$custname = ^jsonpath(.name $$jsonstring)
$$custphone = ^jsonpath(.phone $$jsonstring)
$$custaddr = ^jsonpath(.addr $$jsonstring )
^mongoclose()

^jsonobjectinsert($$jsonobject name $custname)
^jsonobjectinsert($$jsonobject phone $custphone)
^jsonobjectinsert($$jsonobject addr $custaddr)

^mongoinit(mongodb://localhost:27017 test buy)

$mongodata=^mongofinddocument($cust)
$$jsonstring = ^jsonparse($mongodata)
$$product1 = ^jsonpath(.product1 $$jsonstring )
$$product2 = ^jsonpath(.product2 $$jsonstring )
^mongoclose()

# name: $$custname /phone: $$custphone /addr: $$custaddr /product1: $$product1 /product2: $$product2 ////

^jsonobjectinsert($$jsonobject product1 $product1)
^jsonobjectinsert($$jsonobject product2 $product2)

}
else
{^mongoclose()}

if ($$custname) {

$$custname hello. your product is ^join($$product1 ?)
name: $$custname /phone: $$custphone /addr: $$custaddr /product1: $$product1 /product2: $$product2 ////

a:(~no)your product is ^join($$product2 ?)
name: $$custname /phone: $$custphone /addr: $$custaddr /product1: $$product1 /product2: $$product2 ////
}
else{

hello. what is your name?
name: $$custname /phone: $$custphone /addr: $$custaddr /product1: $$product1 /product2: $$product2 ////
}

Image Attachments
ifelseerror.jpg
 

 
  login or register to react
‹‹ if/else value reset      if/else in rules ››