Facebook Messenger bot not sending messages in order

后端 未结 11 2091
遥遥无期
遥遥无期 2021-01-01 21:00

I\'m playing around with building a simple Facebook Messenger chatbot and I\'m having trouble sending messages in sequence.

In the example above, it should

11条回答
  •  我在风中等你
    2021-01-01 21:25

    I had exactly same problem, that solution worked for me:

    function sendMessage(recipient, messages, accessToken, i) {
    
    
        axios.post(baseURL + 'v2.11/me/messages/?access_token=' + accessToken,
            Object.assign({}, {
                messaging_type: "RESPONSE",
                recipient: {
                    id: recipient
                }
            }, messages[i]['payload']) )
            .then(response => {
    
                if(i < messages.length) sendMessage( recipient, messages, accessToken, i+1 );
    
                },
                error => {})
            .catch(error => {});
    
    }
    sendMessage(recipient, flow['messages'], flow['page']['accessToken'], 0);
    

    That's my question: Sequential Message Sending Using Facebook Send-API

提交回复
热议问题