AIML:思考/设置按钮单击

问题描述 投票:0回答:1

仅当单击按钮时我如何思考/设置变量。我的模板中有多个按钮,我想根据用户单击的按钮设置变量的值。我不知道如何在不使用 Think/Set 标签对变量进行多次赋值的情况下执行此操作,并且该变量最终会使用最后一个值赋值。

<category>
        <pattern>quiz</pattern>
        <template>
         Which of these topics are most interesting to you?
            <button>
                <text>topic1</text>
                <postback>question 2</postback>
                <think><set name = "question1">1</set></think>
            </button>
            <button>
                <text>topic2</text>
                <postback>question 2</postback>
                <think><set name = "question1">2</set></think>
            </button>
            <button>
                <text>topic3</text>
                <postback>question 2</postback>
                <think><set name = "question1">3</set></think>
            </button>
            <button>
                <text>topic4</text>
                <postback>question 2</postback>
                <think><set name = "question1">4</set></think>
            </button>
            <button>
                <text>topic5</text>
                <postback>question 2</postback>
                <think><set name = "question1">5</set></think>
            </button>
        </template>
    </category>
artificial-intelligence chatbot aiml pandorabots
1个回答
0
投票

正如您已经看到的,您无法在按钮或回复标签内设置变量。相反,您应该通过回发将任何值传递给类别本身,如下所示:

<category>
    <pattern>quiz</pattern>
    <template>
     Which of these topics are most interesting to you?
        <button>
            <text>topic1</text>
            <postback>question 2 1</postback>
        </button>
        <button>
            <text>topic2</text>
            <postback>question 2 2</postback>
        </button>
        <button>
            <text>topic3</text>
            <postback>question 2 3</postback>
        </button>
        <button>
            <text>topic4</text>
            <postback>question 2 4</postback>
        </button>
        <button>
            <text>topic5</text>
            <postback>question 2 5</postback>
        </button>
    </template>
</category>

<category>
    <pattern>question 2 *</pattern>
    <template>
        <think><set name="question1"><star/></set></think>
        You clicked on topic <get name="question1"/>.
    </template>
</category>
© www.soinside.com 2019 - 2024. All rights reserved.