title: Problem With decoding an Incoming WhatsApp message using Twilio
body: <p>I use this lambda as WebHook for Twilio WhatsApp. but when I receive the message in event. it is a base64 encoded. after decoding to a string with utf-8, it's still not in proper string form.
  here is the code:</p>
  <pre><code>exports.handler = async (event) =&gt; {
      // TODO implement
  
     // event = JSON.stringify(event);
      console.log(&quot;Event: &quot;, event);
      console.log(&quot;BODY&quot;, event.body);
      
      let buff = Buffer.from(event.body, 'base64');
      let text = buff.toString('utf-8');
  
      console.log(&quot;Text Before &quot;, text);
  
      // 
  
      let array = text.split('&amp;');
      
      console.log({array});
      
      let text2 = unescape(array[6]);
      let replaced = text2.split('+').join(' ');
  
      console.log(&quot;New Text &quot;, replaced);
      console.log(&quot;New Text2 &quot;, text2);
      //console.log(JSON.stringify(text) );
      // console.log({array});
  
      //console.log(&quot;Message Body&quot;, );
      const response = {
          statusCode: 200,
          body: JSON.stringify(),
      };
      return response;
  };
  </code></pre>
  <p>the Original Message</p>
  <pre><code>Hello, From the Other Side
  </code></pre>
  <p>the text I got in the lambda event base64 encoded
  <code>U21zTWVzc2FnZVNpZD1TTWM2MGU4YWYxMzJiN2IzMTU3OTAwMTdjYTMyM2M5Zjg3Jk51bU1lZGlhPTAmUHJvZmlsZU5hbWU9QW1qYWQrU2F5eWFtJlNtc1NpZD1TTWM2MGU4YWYxMzJiN2IzMTU3OTAwMTdjYTMyM2M5Zjg3JldhSWQ9OTIzMDg1NjUxNDE0JlNtc1N0YXR1cz1yZWNlaXZlZCZCb2R5PUhlbGxvJTJDK0Zvcm0rdGhlK090aGVyK3NpZGUuJlRvPXdoYXRzYXBwJTNBJTJCMTQxNTUyMzg4ODYmTnVtU2VnbWVudHM9MSZSZWZlcnJhbE51bU1lZGlhPTAmTWVzc2FnZVNpZD1TTWM2MGU4YWYxMzJiN2IzMTU3OTAwMTdjYTMyM2M5Zjg3JkFjY291bnRTaWQ9QUNhYjk5NWJlMTgxYzIwODc0OGFiYTkzZmQxMGJhYjIxMCZGcm9tPXdoYXRzYXBwJTNBJTJCOTIzMDg1NjUxNDE0JkFwaVZlcnNpb249MjAxMC0wNC0wMQ==</code></p>
  <p>After Decoding to string i get this.</p>
  <pre><code>Hello%2C+Form+the+Other+side.
  </code></pre>
  <p>Thanks in Advance.</p>