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

How to take a reply in rivescript (containing multiple lines) to next line when implemented on the chatbot ?
 
 

I am using python3.5 and the complete reply from rivescript code to the chatbot comes in a single line on the chatbot interface. This is unclean and I want to change it to multiple lines of short width.
How is that done ?
I am using Tkinter for chatbot interface.

 

 
  [ # 1 ]

Hi

Do you mean like when you do this?

tell me a poem
There once was a man named Tim,\n
who never quite learned how to swim.\n
He fell off a dock, and sank like a rock,\n
^ and that was the end of him

When you get the reply from that, those “\n” sequences would come back as actual “\n” ASCII newline characters—so if you printed them to your terminal, for example, it would come in with line breaks.

If that’s all working, then your question may be Tkinter specific. What kind of widget are you writing the reply into? For example I’m not sure if a Label widget supports line breaks, but a Text widget does.

Also, in RiveScript, if you don’t want to have to remember to type “\n” everywhere you can set a local parser flag in each RiveScript source file. The flag is file-scoped so each file would need it near the top, or whenever you want it to change how the ^Continue command joins lines together.

local concat newline

// equivalent to the above example. each ^Continue
// implicitly joins with a \n
tell me a poem
There once was a man named Tim,
who never quite learned how to swim.
He fell off a dock, and sank like a rock,
^ and 
that was the end of him.

// other options
local concat none  // the default, just joins the lines with no separator
local concat space  // joins with a space character

// RiveScript code that follows `! local concat` uses the last
// rule set, so you can toggle the option around in the same
// source file.
what is my name
Your name is
^ <get name>, right?
// "Your name is kirsle, right?" -- joins with spaces 

I haven’t worked with Tk in Python much, but I found some neat things and wrote my own scrollbar widget if any of this is helpful: https://www.kirsle.net/python-tk-experiments

 

 
  login or register to react