Guest User

Untitled

a guest
Jan 19th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. function sendMessage(recipient, payload, accessToken) {
  2.  
  3. return axios.post(baseURL + 'v2.11/me/messages/?access_token=' + accessToken,
  4. Object.assign({}, {
  5. messaging_type: "RESPONSE",
  6. recipient: {
  7. id: recipient
  8. }
  9. }, payload) );
  10. }
  11.  
  12. let async_actions;
  13. let promise_chain = Q.fcall(function(){});
  14. async_actions = flow['messages'].map(message => {
  15. return sendMessage(recipient, message['payload'], flow['page']['accessToken'])
  16. });
  17.  
  18.  
  19. async_actions.forEach(async_action => {
  20. //console.log(async_action)
  21. promise_chain = promise_chain.then(f);
  22. });
Add Comment
Please, Sign In to add comment