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

Fancy control script
 
 

I need some help writing an advanced control script. I’ll post it here once I’m done.

So I want to process each sentence in the user response but output only the response that’s in the most relevant topic.

For instance:

Example #1
bot: > I want to buy something.
user: > OK.
bot: > So can you help me? ## this is taken from ~quibble

Example #2
bot: > I want to buy something.
user: > OK, what are you looking for?
bot: > I need a (some product). ## this is taken from ~introduction

Example #3, problematic
bot: > I want to buy something.
user: > OK. What are you looking for?
bot: > So can you help me? I need a (some product). ## this is taken from ~quibble + ~introduction

Example #4, problematic
user: > I suggest you buy this one. Is it OK?
bot: > Looks perfect, thanks. I don’t remember. ## this is taken from ~suggestion + ~quibble

I would like to augment the per-sentence processing so that instead of output it generates a fact table of the format (<response> ‘is_in_topic’ <topic>). Then I could have an outputmacro that loops over the fact objects three times for three if-statements: 1)is there a topic that’s the same as the current topic; 2) is there a topic that’s not ~keywordless and not ~quibble; 3) else. Then output the first response that matches any of the if statements.

Is it even possible to write the output from ^rejoinder(), ^gambit() and ^respond() into a variable as a string instead of sending it to the user immediately?

 

 
  [ # 1 ]

Output is not immediately sent to the user - it is all subject to post processing. It is just that the default control script exits out of the main loop as soon as something generates a response, i.e. when %response > 0.

So you can change your control script to not do that, and you can access those responses via ^response() and where it was generated from via ^responseruleid().

Output can be changed via ^reviseOutput()

 

 
  [ # 2 ]

Actually, I’ve found another way to do this.

I split the original if-statements into several outputmacros. Then I have a counter for failed sentences for each macro. If the first macro fails for all the sentences, I move on to the next macro. This is faster than memorizing anything in a fact table.

However, I can’t seem to get this to work completely and I’ve run out of ideas as to what could be the problem. Could anyone help me troubleshoot this one? It works only for the first macro.

Thank you!

File Attachments
simplecontrol.top  (File Size: 3KB - Downloads: 0)
 

 
  [ # 3 ]

Sweet mother of jesus I think I figured it out. It works but not every time, still needs some refining. I get the error message “The file could not be written to disk.” when I try to attach the new version, so I uploaded the file to dropbox:

https://www.dropbox.com/s/4hkts44tynh2x1m/simplecontrol_v2.top?dl=0

Please do take a look and tell me what you think.

 

 
  [ # 4 ]

In your outputmacros use ^end(CALL) and not ^end(RULE).
You want control to return back to the output script of the current rule so that you can take the decision of ending all input or trying the next sentence.


BTW, there is an extra { in the last line.

 

 
  login or register to react