Таймер ответа не работает мессенджер бот - PullRequest
0 голосов
/ 30 июня 2018

Я работаю над ботом мессенджера в Facebook, используя node.js. Я пытаюсь получить код для отправки временного ответа пользователю, но он не работает. Вот код:

function handlePostback(sender_psid, received_postback) {
let response;
let subscribe;

// Get the payload for the postback
let payload = received_postback.payload;

// Set the response based on the postback payload
if (payload === 'yes') {
  response = { "text": "Thanks! Here's your first task : Hold the door for someone. " };
  subscribe = true;
} else if (payload === 'no') {
  response = {"text":"That's unfortunate" };
  subscribe = false;
}

// Send the message to acknowledge the postback
callSendAPI(sender_psid, response);

  if (subscribe===true) {
    response = {"text":"Today's task will be:"};
    setTimeout(sendTask(), 5000);
  }

}

1 Ответ

0 голосов
/ 05 июля 2018

Проблема была решена с использованием другой функции отправки для ответа по времени.

...