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

Redirect direct output to a variable
 
 

I am going to organize my Botanswers in JSON, so I don´t make use of the direct output, but collect my output and create a json struct at the end of each volley.

I don´t want to call a function each time I write an answer

u: (some input) ^addAnswer(...)
... 

So right now I have to first generate my outputstream, then analyze it, create my json structure based on it and then use ^reviseOutput() to insert my json structure instead.

So what I need is some kind of function to redirect output to a variable.

Then I would be able to do the following:

u: (some input) ^changeOutputStream($$someVariable
              
This is some text

and afterwards the content of $$someVariable would be “This is some text”.

This would make using json as the default way to communicate with an application a lot easier.

As far as I know a feature like this doesn´t excist yet.
So this thread could be understood as some kind of feature wish.

Would this feature be easy to do, Bruce? What do you think of it?

 

 

 
  [ # 1 ]

If all you want to do is map your outputs into json to then send it as OOB or other, you can just use postprocess topic to read all the messages you output, convert them, cancel them, and then insert your json message.

Not changing the outputstream.  Alternatively you do
^changeoutputstream($$somevariable
^”  This is some text ” )

 

 
  [ # 2 ]

Jeah, that is my point, I sometimes have more complex things, so i want to put parts of my answer in different json objects.

In most cases, where I would have simple answers, I want to do ^changeOutputStream($default) once in my control script, for this case you are right, the function wouldn´t be a big advantage. But if I have more complex things to do I could do multiple calls of it in one volley.

Now I have to find a way to add my own dycryption and then analyse afterwards what goes into which variable.

Totally doable, but a little but ugly. It would just be more beautiful if I wouldn´t need this workaround, because a ^changeOutputStream would excist.

 

 
  [ # 3 ]

Couldn’t this be done by some clever control script processing?

You are returned to the control script after every attempt to handle a rejoinder, responder or gambit and the default logic is typically to check %response to see if anything has been created.

If all your ^changeOutputStream function did was to save the name of a variable in another common variable, then your control script could check for that common variable being not null and then copy ^response(%response) into the desired variable via ^eval().

 

 
  [ # 4 ]

In my case this is just shifting the problem to another area. My point is that I have volleys where I want to assign many different text passages to variables. For example:

t
  
This goes to a default variable defined in control script
  
^changeOutputStream($$Variable1)
  
This goes to Variable1
  
^changeOutputStream($$Variable2)
  
This goes to Variable2
  
^changeOutputStream($$Variable3)
  
This goes to Variable3 
  
^changeOutputStream($$Variable4)
  
This goes to Variable4 

What I would have to do is add some seperator and information to which variable the following output should be pushued in ^changeOutputstream

Afterwards I have something like this, e.g. if the seperator is “|$variable|”

This goes to a default variable defined in control script |$$Variable1|This goes to Variable1 |$$Variable2This goes to Variable2 |$$Variable3|This goes to Variable3 |$$Variable4|
  
This goes to Variable4 

Now I have to parse this sentence again, look for seperators, read variable names and assign them.

As I said, doable, but a little bit ugly.

 

 

 

 
  login or register to react