This tag describes a piece of valid input phrases and contains a set of actions and nested contexts.

It may contain:


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.

Read more about context extending in the context tag chapter

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.

  <input id="greeting" pattern="(hi|hello) *">
    <output value="Hello $UserName!" if="full($UserName)"/>

    <context id="name_is_empty" if="empty($UserName)">
      <output value="Hi! What is your name?"/>

      <input pattern="$Text">
        <var name="UserName" value="$Text" scope="user"/>
        <output value="Nice to meet you $UserName!"/>


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.

Then nested context tag goes and Zenbot evaluates it's condition. This context extends the root one if our bot doesn't know the user's name yet. If so, Zenbot performs it's nested actions and extend the root context with pattern “$Text”. Thus the nested output generates response text “Hi! What is your name?”

The next user's request will be matched through extended context which understands what a simple text means. In this particular example each text will be interpreted as a user's name.

  If user will greet our bot again, it will understand her correctly.

Zenbot goes inside the matched input and performs all it's actions: saves variable “UserName” and generates a greeting text output.

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:

<input id="color">
  <pattern value="(green|blue|red)"/>
  <pattern value="(yellow|grey|white)"/>

In this case Zenbot will compose all nested pattern tags to build a single one behind the scene. But your Botscript will look much more readable.


pattern attribute

Use this attribute to define pattern if your input contains only one simple pattern and you would like to save XML file's space. Use inner pattern tags otherwise.

id attribute

You can define some non unique identifier for any input to have knowledge about what particular input was matched.

  This attribute is useful only if you connect your bot with Telegram Botan analytics service or if you work with Zenbot's REST API.