code: function (i) {
      robot.adapter.send(data.context, messages_to_send[i]);
  
      if (messages_to_send.length > ++i) {
        setTimeout(function () { sendMessage(i); }, 300);
      }
    }
docs: We define a recursive closure that calls itself with the next data to send after a timeout. This approximates sending synchronous (sequential) HTTP requests.