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..

Response of chatbot when retrieving from database
 
 

How do I change the response of the chatbot when retrieving from the database.
Below is a sample of my code.

u: (what is my grade in _id _*)
    
$subjectname '_0  
    $user_id = '
_1 
    
if (^dbexecute(^"SELECT grade FROM AccountSubject as aaa INNER JOIN Subject as bbb ON aaa.subjectname = '$subjectname' where aaa.idnumber = '$user_id' and bbb.subjectname = '$subjectname';" '^myfunc)) {is your grade in $subjectname}
    else {dbexecute failed tables - $$db_error} # to see tables: SELECT * FROM pg_catalog.pg_tables 

A sample query would be:
what is my grade in Math1 id 1

The current response is:
A is your grade in Math1

I want the response to be:
Your grade in Math1 is A.

How do i do this? Thank you so much in advance.

 

 
  [ # 1 ]

You did not include your ^myfn function, which I presume merely says out the grade. Make it put it on a variable,
then you can alter your entire output message like you want it to.

 

 
  [ # 2 ]

Hi Bruce,

Im not sure i understand. If possible can you make a quick example?

 

 
  [ # 3 ]

You use ^myfunc . I want to see your definition of it.

 

 
  [ # 4 ]

Hi bruce does chatscript support functions in a database?

Example:

if (^dbexecute(^“SELECT test(’$user_id’,’$subjectname1’);” ‘^myfunc2)) {}
else {dbexecute failed tables - $$db_error} # to see tables: SELECT * FROM pg_catalog.pg_tables

 

 
  [ # 5 ]
Bruce Wilcox - Apr 27, 2018:

You use ^myfunc . I want to see your definition of it.

if (^dbexecute(^"SELECT CONCAT('Room_assignments_for_','$subjectname1', '_and_', '$subjectname2', '_are_',array_to_string(array_agg(subjectroom), '_and_'),'_respectively.') 
       FROM SubjectSched as aaa 
       INNER JOIN AccountSubject as bbb ON aaa.subjectname = bbb.subjectname 
       where bbb.idnumber = '
$user_id' and bbb.subjectname IN ('$subjectname1', '$subjectname2')
       limit 1;" '^myfunc2)) {} 

I used concat to add sting in a database. For now it is returning right
Here is my myfunc2 function

outputmacro: ^myfunc2(^db)
 
preprint(^db 

 

 

 
  [ # 6 ]

ChatScript supports sending stuff to a db. CS doesnt care what it is.

Your myfunc2 function directly prints your value. In order to change the order of what you print, you need to store it on a variable instead.

 

 
  [ # 7 ]
Bruce Wilcox - May 11, 2018:

ChatScript supports sending stuff to a db. CS doesnt care what it is.

Your myfunc2 function directly prints your value. In order to change the order of what you print, you need to store it on a variable instead.

Thank you for your time Sir Bruce.

 

 
  [ # 8 ]

Sir Bruce!

I like it - thoroughly deserved!

Simon

 

 
  login or register to react