- Output field: Returns the given expression for the current robot message and set it as context for the next user message.
By default system sets the last sentence of the robot message. With set-context element, you can set any part of the robot message as the next context. When using along with think, you can even set text that are not included with the robot message as next context.
A valid BrainXML expression consists of text and/or elements. Note no custom XML element is allowed for the expression.
Example: Set part of message as context
- How old are you
I'm <bot>age</bot> years old. How about you?<think><set-context>How old are you</set-context></think>
- Context: How old are you
Glad to meet someone of <s/> years old.
- How old are you?
- I'm 4 years old. How about you?
- Glad to meet someone of 7 years old.
Using with API
This element can be used with "get" API for setting the context on the fly. To do so, just include
<set-context>new context</set-context> with the "msg" parameter. To clear the context, use
- Be sure to use set-context along with think, so it won't be displayed to your users.
- The set-context element doesn't get into effect before the robot message is sent out. It has no way to change the current context.
- If there are multiple set-context elements, the last one will override the previous ones.
- If the parameter for set-context is null, it means the normal context, the last sentence of output, will be applied.