Patterns

When writing commands, you need to provide phrases that the user can say to invoke these commands. In Alan AI, these phrases are known as patterns.

For example, in the intent below, How do I begin? is a pattern:

Dialog script
intent('How do I begin?', p => {
    p.play('Ask me a question or give a task');
});

Multiple patterns

You can add multiple patterns to commands. Multiple patterns can be helpful if you want to let users invoke the same command with completely different phrases.

To define multiple patterns, pass them to the intent() function as comma separated strings:

Dialog script
intent('How do I begin?', 'What should I do here?', p => {
    p.play('Ask me a question or give a task');
});

Multiple patterns can also be passed to the intent() function as an array:

Dialog script
let requests = [
    'How do I begin?',
    'What should I do here?'
];

intent(requests, p => {
    p.play('Ask me a question or give a task');
});