AI Zone Admin Forum Add your forum

NEWS: survey on 3000 US and UK consumers shows it is time for chatbot integration in customer service!read more..

RiveScript Question: Change Topic

Hi . I am using rivescript python. I am trying to change topic after reading from mongodb using macros.
I tried

+ *
- {topic=<call>findtopic <star></call>}

This is not working and getting output <call>findtopic xxxx</call>}
Function findtopic is returning right topic; but how can i redirect?
Inside findtopic, we were finding intent and reading right topic from mongodb. Is it possible to redirect from macro itself? We prefer redirection from replies.


  [ # 1 ]

Hello, Babu.

I’ve split your post into it’s own thread. Whenever you have a question about something, unless it’s specifically tied to a current thread, it’s best to just create a new thread. Posting something that’s not relevant to a given thread is considered “hijacking”, and is not encouraged. Also, posting to a thread that is more than a few months old (AKA “necroing”) is also not encouraged, even if the post is relevant. Just some friendly advice here. smile


  [ # 2 ]

Necroing? I never knew that term for it. I guess you live and learn…


  [ # 3 ]

Yes, to “necro” a thread is to bring it “back from the dead”. The term is related to necromancy, the magic of death. Thus, “necro”. wink


  [ # 4 ]

The tags in RiveScript are processed in a particular order, and that combination of tags (a `<call>` inside a `{topic}`) don’t work. Generally speaking, the `<call>` tag is always the very last one processed, so you can’t use the output from that tag as the input for any other tags.

See the tag processing order on the RiveScript spec:

What you can do, however, is use the RiveScript API from within your object macro to set the user’s topic. You can use the `set_uservar()` function to set the “topic” variable, and use the `current_user()` function to get the current user’s ID.

object findtopic python
# The arguments to a Python macro are (rs, args)
    # where `rs` is the reference to the RiveScript instance,
    # so you can use it to call any of its API functions.
star args[0]
"I've set your topic to {}".format(star)

(For brevity, you could do `rs.set_uservar(rs.current_user(), “topic”, star)` too)


  login or register to react