I need an embedded component within AIML scenario that sets a variable of the user to specific value in runtime. Then my template supposed to reuse the variable.
I've implemented a service which sets a property:
class DayTimeClfService(Service):
"""
AIML Service that classifies time into 4 classes:
- evening,
- night,
- morning,
- day
and puts it into user_variable `time_of_day`
"""
def __init__(self, config=None, api=None):
Service.__init__(self, config)
def ask_question(self, client_context, question: str):
time_of_day = classify_current_time()
# service adds a property with part of date for usage by greeting templates:
client_context.brain.properties.add_property('time_of_day', time_of_day)
And I have an AIML category:
<category>
<pattern>HELLODAY</pattern>
<template>
<sraix service="daytimeclf"></sraix>
<get name="time_of_day" />
<get name="name" />
<condition name="time_of_day">
<li value="night">Good Night, friend! Why don't you sleep so late?</li>
<li value="morning">Good Morning!</li>
<li value="day">Hello!</li>
<li value="evening">Good Evening!</li>
<li>Hi. What timezone do you use?</li>
</condition>
</template>
</category>
Unfortunately when we get out of sraix the property is missed. Although within service context I can command:
client_context.brain.properties.property("time_of_day")
and it returns correct result.
By the way I tried to set dynamic_variable, but it even does not set it:
I need an embedded component within AIML scenario that sets a variable of the user to specific value in runtime. Then my template supposed to reuse the variable.
I've implemented a service which sets a property:
And I have an AIML category:
Unfortunately when we get out of
sraix
the property is missed. Although within service context I can command:client_context.brain.properties.property("time_of_day")
and it returns correct result.By the way I tried to set dynamic_variable, but it even does not set it:
Is it possible to set properties and variables from custom services?