Preview:
/* create a smart voice assistant in spanish that can accept questions and answers from wikipedia */
var assistant = new Annyang();
var commands = {
  'hola': function() {
    alert('Hola, ¿en qué puedo ayudarte?');
  },
  '*question': function(question) {
    var url = 'https://es.wikipedia.org/w/api.php?action=opensearch&search=' + question + '&format=json&callback=?';
    $.ajax({
      type: 'GET',
      url: url,
      async: false,
      dataType: 'json',
      success: function(data) {
        alert(data[2][0]);
      },
      error: function(errorMessage) {
        alert('Error');
      }
    });
  }
};
assistant.addCommands(commands);
assistant.start();
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter