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

Changing user input and providing alternative answers
 
 

Hi,

i use Chatscript as an embedded component in my system.

What I want to achieve

I have a component which will display the messages like a messenger, e.g. whatsapp, and saves all sent and received messages.

- At some point, I want to replace parts of the history with alternative message contents.
- One answer of chatscript can contain more messages belonging to both sides (user and chatbot) in order to simply add parts of the chat.

How I thought of doing this

Chatscript will provide each answer in a defined format, providing different versions of this part of the chat and using || to achieve that i can generate more that one chat message for each call of the PerformChat function:

DEFAULT || USERINPUT  || BOTOUTPUT 
FLAGX
=|| USERINPUT || BOTOUTPUT || USERINPUT || BOTOUTPUT ....
...
FLAGX=|| USERINPUT || BOTOUTPUT || USERINPUT || BOTOUTPUT .... 

e.g.

DEFAULT || ORIGINAL|| default answer
FLAGA
=1 This would be a replacement for the user input || This is the bot answer || This is another user input || This is the next bot answer
FLAGA
=2 ORIGINAL || Here only the bot answer is changed 

The key word ORIGINAL would mean that the user input isn´t replaced in that variant.

At a later time i could do

[SET FLAGA=2] 

in the oob communication to tell my component that it should display a different version of the communication.


In Chatscript i would use the post controlscript to generate this formats.
The default case would be to generate the sequel from “botoutput” to “DEFAULT || botoutput”

Via macros i would provide functions like ^addBotOutput or ^changeUserInput or addNewVariant(FLAGASSIGNMENT) and stuff like that.

My Questions

- Do you have some feedback to my solution?
- Is there any way chatscript can provide me further support with this?
e.g. is there a way to add a check that the flagassignments are correct and that if I later change a flag that this flag is set somewhere else (to avoid spellerrors etc)
- Maybe you have some idea to achieve my goal using a completely different way?

 

 
  [ # 1 ]

I don’t really understand your goal.  I can understand how CS might generate multiple outputs, but I

What does it mean that flagassignments are correct? That if you change a flag it is set somewhere else?

 

 
  [ # 2 ]
Bruce Wilcox - Mar 23, 2016:

What does it mean that flagassignments are correct? That if you change a flag it is set somewhere else?

Yes, that I dont set a flag that i havent used as an option before. But that is not my main point, I generally just wanted some feedback, maybe I am overseeing possibilitys to do this in a more beautiful way.

Bruce Wilcox - Mar 23, 2016:

I don’t really understand your goal.

I will try to explain again what my goal is a little more. Here are some examples of what the result should look like:

1:
User: Hi, this is my first message.
Bot: Hi, this is my first answer.
User: Could you correct my last sentence?

Then my gui should change this conversation to:

User: Hi, this is my corrected message
Bot: Hi, this is my corrected answer.
User: Could you correct my last sentence?
Bot: I did.

2:

User: This is the first real user input.
Bot: That is correct.
User: Please add some simulated conversation before this message.

Then the gui should change this conversation to:

User: This is the first real user input.
Bot: That is correct.
User: This is some simulated output the user has never actually typed in.
Bot: This is simulated output, too
User: Please add some simulated conversation before this message.
Bot: ok.

In both cases it is perfectly fine if I am not able to do this completely when the user tells me to, but prepare it before that and just somehow activate it depending on the user input.


I hope it gets clearer now, thank you very much for your support smile
Tobi

 

 
  [ # 3 ]

I’m sorry. I don’t think I have any advice.

 

 
  [ # 4 ]

Sets of variables are only possible by using Indirection Variables, am I right? Or is there any other way of building something like a vector in c++, so I dont have to care about indexes or the size myself?

 

 
  [ # 5 ]

set of facts

 

 
  [ # 6 ]

Is there an equivalent of the $$temporary variable? Otherwise I have to delete the fact set manually after each volley :/

 

 
  [ # 7 ]

createfact(I eat squirrels FACTTRANSIENT)

 

 
  [ # 8 ]

Ok, thank you so much Bruce! smile

Is there a way how I can save my output into a variable at the end of a volley?
So I can use it again in the next volley?

 

 
  [ # 9 ]

sure… look up ^response

 

 
  [ # 10 ]

Another approach wich would be much better:

Do you think it would be possible for me to implement another function next to “InitSystem” and “PerformChat” which provides the History?

So that i could manipulate this history at runtime in Chatscript and make it accesible to my program where chatscript is embedded.

 

 
  [ # 11 ]

You can do anything you want OUTSIDE of chatscript in your app.  just tap before and after PerformChat.

But you can get history from CS itself using script.

 

 
  [ # 12 ]
Bruce Wilcox - Mar 27, 2016:

You can do anything you want OUTSIDE of chatscript in your app.  just tap before and after PerformChat.

I was aware of the first solution, but my idea have been to e.g. store the the history at runtime in chatscript in factsets or something similiar (in order to replace some parts of the history afterwards).Then i would need to access parts of chatscript via c++ code. So I would need access to factsets or outputmacros or anything to access the things ive done in chatscript from outside of chatscript.

Bruce Wilcox - Mar 27, 2016:

But you can get history from CS itself using script.

What do you mean by that?

 

 
  [ # 13 ]

Your control script can save the user input sentences as facts…
u: (_*) createfact(hisinput hisinput ‘_0)

You can query to get them.
You can query from your app by doing it as an out of bounds message.
You can either get back a small amount of data back as output, or the script could write all the facts to a local file and your app could retrieve them there.

Sort of depends what you want to do.

 

 
  [ # 14 ]

Thank you again Bruce.

Two new ideas / questions:

1. I sometimes want to process a lot of outputdata with an outputmacro. But when I split my String arguments in more lines, the compiler isn´t able to recognize it anymore:

topic: ~introductions []
t
MakroTest:
 ^
test1(^"This is a macro text
          I have so many output here,
          That I want the output to be split in multiple lines"

It would look beautiful if I could use the {} brackets to provide an argument to a macro, just like the ^loop(){} brackets. I could then write it as:

topic: ~introductions []
t
MakroTest:
 ^
test1
         {
          This is a macro text
          I have so many output here
,
          
That I want the output to be split in multiple lines
          } 

Which looks a lot more readable in my opinion.

2. Is there a possibility to store code as strings in facts, which is executed later on when I ask for it?

createfact(test test "If ( test1 ) { script1 } else { script2}"

Then when I query for this fact I want to be able to get script1 or script2, depending on test1.

If I could combine those two, I would have a good solution for at least a part of my problem.

 

 
  [ # 15 ]

You can store compiled CS as a fact from a table.
You can use the data from the fact with ^eval to evaluate your code.

You should be able to do: u: (test) $$tmp = ^“this is my
  form of code
that lives for now”
  $$tmp

 

 
  login or register to react