AI Zone Admin Forum Add your forum

CHATBOT MEETUP CHATBOT MEETUP CHATBOT MEETUP CHATBOT CHATBOT MEETUP CHATBOT MEETUP CHATBOT MEETUP CHATBOT MEETUP

On June 28th, 2017 we're organizing our next Chatbot Meetup in Amsterdam, The Netherlands. Feel free to join!'

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: https://github.com/aichaos/rivescript-wd/blob/349f3f577380fe3a647951f9406be35a8e127b25/WD.rst#tag-priority

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]
    username 
rs.current_user()
    
rs.set_uservar(username"topic"star)
    return 
"I've set your topic to {}".format(star)
object 

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

 

 
  login or register to react