title: facebook messenger bot encoding error
body: <p>I have written sample echo message bot using facebook messenger api and wit.ai actions.</p>
  
  <p>My message from facebook page is received and the proper action function defined using wit api's is also getting called. However 
  while returning the response, i am getting followin error as  - </p>
  
  <p>Oops! An error occurred while forwarding the response to  : Error: (#100) Param message[text] must be a UTF-8 encoded string
      at fetch.then.then.json (/app/index.js:106:13)
      at process._tickCallback (internal/process/next_tick.js:103:7)</p>
  
  <p>Here is the function which is used to return the response - </p>
  
  <pre><code>const fbMessage = (id, text) =&gt; {  
    const body = JSON.stringify({
      recipient: { id },
      message: { text },
    });
    const qs = 'access_token=' + encodeURIComponent(FB_PAGE_ACCESS_TOKEN);
    return fetch('https://graph.facebook.com/v2.6/me/messages?' + qs, {
      method: 'POST',
      headers: {'Content-Type': 'application/json; charset=UTF-8'},
      body
    })
    .then(rsp =&gt; rsp.json())
    .then(json =&gt; {
      if (json.error &amp;&amp; json.error.message) {
        throw new Error(json.error.message);`enter code here`
      }   
      return json;
    });
  };
  </code></pre>
  
  <p>I have copied this function from the messenger.js file from the documentation since i am just trying the POC. 
  I checked the values for text and id in this function and verified using console.log statements and those are coming properly. </p>
  
  <p>Can some experts help me to solve this error?</p>
  
  <p>Note - I tried encoding the text using text.toString("utf8"); but it returns the encoding string as [object object] and thats the 
  response i get from bot. so it doesnt work.</p>