input tag

Summary

Being a part of context, input tag must contain a set (at least one) of input patterns.
They describe those user's phrases which are valid in the current dialog context.

Thus an input tag is a main “executive” point of Botscript.
User's text request matches by Zenbot through all inputs inside the current context and then the best matched input takes a control.

Nested tags

Input tag also may contain a set of variables, get/post actions, outputs and nested contexts.

Zenbot will look inside selected input tag and will perform some action for each of them.
Thus output tag inside input will generate some text output.
Variable tag will generate and store some variable's value.
Get and post actions will request some external HTTP resources and store the result in some variable.

At the end of request processing Zenbot looks through the set of nested contexts to extend root context.
If there is no nested contexts or no one satisfies conditions, the current context remains unchanged.

If such context was found, Zenbot performs it's own nested variables, get/post and outputs tags, and adds the results to the response.
This context extends the root context and the next user's text request will be matched through extended context.

<context><inputid="greeting"pattern="(hi|hello) *"><outputvalue="Hello $UserName!"if="full($UserName)"/><contextid="name_is_empty"if="empty($UserName)"><outputvalue="Hi! What is your name?"/><inputpattern="$Text"><varname="UserName"value="$Text"scope="user"/><outputvalue="Nice to meet you $UserName!"/><context/></input></context></input></context>

In the example above input with id “greeting” takes control when user says something like “Hello!”
Zenbot then goes through nested tags and sees the first one - output tag.
It has a condition inside if attribute, so Zenbot evaluates it and generates a text greeting output if our bot already knows the user's name.

We defined an empty context inside this input because we want to switch to the root context manually, so that a next request will not be interpreted as a user's name again.

Multiple patterns

In the example above you can see an input tag with single pattern defined through a pattern attribute.
It is a one-liner syntax which saves some piece of code if there is only one simple pattern involved.

Of course you can define as many patterns as you need in each input tag: