1

Is it possible to access the object macros internally in RiveScript? I'm bit confused with that. I have defined the following script:

> object small python
  return "4"
< object

+ small
- <call>small</call>

Which gives me an error when I enter small:

error: [ERR: Object Not Found]
agold
  • 6,140
  • 9
  • 38
  • 54

2 Answers2

1

The definition of the object seems to be ok, but you are probably running it from https://play.rivescript.com/ or https://www.rivescript.com/try, which only allow JavaScript or CoffeeScript (see the about page).

You can use rivescript-python to run the code, which you can install by:

pip install rivescript

Then put your rivescript in a file (.rive), for example, in helloworld.rive.

Then in python:

from rivescript import RiveScript
bot = RiveScript()
bot.load_directory('.') # set your directory where the .rive file(s) is/are
bot.sort_replies()

Now you can use bot.reply to get the answer for a certain input:

>>> bot.reply('localuser','small')
'4'

Edit: I have tested this code on Ubuntu 14.04 with Python 3.4.3 and Python 2.7.12 and rivescript 1.14.4.

Trenton McKinney
  • 56,955
  • 33
  • 144
  • 158
agold
  • 6,140
  • 9
  • 38
  • 54
1

make a space after the object name just like that

- <call>small  </call>
  • Here are some guidelines for [How do I write a good answer?](https://stackoverflow.com/help/how-to-answer). This provided answer may be correct, but it could benefit from an explanation. Code only answers are not considered "good" answers. From [review](https://stackoverflow.com/review). – Trenton McKinney Sep 22 '19 at 18:59