title: How do I convert this chained promises code with callback to async/await
body: <p>How do I convert this chained promises code with callback to async/await</p>
  <p>I have no idea on how to go about converting this code to async/await so that its more readable</p>
  <pre><code>var responseCallbacks = {};
  
  bot.onText(/\/something/, async (msg) =&gt; {
    var callback = responseCallbacks[msg.chat.id];
    if (callback) {
      delete responseCallbacks[msg.chat.id];
      return callback(msg);
    }
    bot.sendMessage(msg.chat.id, &quot;something&quot;).then(() =&gt; {
      responseCallbacks[msg.chat.id] = (answer) =&gt; {
        var something = answer.text;
  
        bot.sendMessage(msg.chat.id, &quot;something else&quot;).then(() =&gt; {
          responseCallbacks[msg.chat.id] = (answer) =&gt; {
            var somethingElse = answer.text;
            console.log(something, somethingElse);
          };
        });
      };
    });
  });
  </code></pre>