I'm having constant problems with your example code.
Code:
bot.on('message', async message => {
const {sender} = message;
let out, buttons;
await sender.fetch(`first_name,last_name,profile_pic`, true); // true: use cache
// ---- send text
out = new Elements();
out.add({text: `hey ${sender.first_name}! what up`});
await bot.send(sender.id, out);
// wait for 1s
await Bot.wait(1000);
});
Leads to
Unhandled rejection Error: cannot GET /v2.6/...?access_token=&fields=first_name%2Clast_name%2Cprofile_pic (400)
at Response.toError (/Users/tobias/Projects/dreamer/node_modules/facebook-messenger-bot/node_modules/superagent/lib/node/response.js:106:13)
at Response.setStatusProperties (/Users/tobias/Projects/dreamer/node_modules/facebook-messenger-bot/node_modules/superagent/lib/node/response.js:183:12)
at new Response (/Users/tobias/Projects/dreamer/node_modules/facebook-messenger-bot/node_modules/superagent/lib/node/response.js:42:8)
at Stream.<anonymous> (/Users/tobias/Projects/dreamer/node_modules/facebook-messenger-bot/node_modules/superagent/lib/node/index.js:918:22)
at emitNone (events.js:91:20)
at Stream.emit (events.js:185:7)
at Unzip.<anonymous> (/Users/tobias/Projects/dreamer/node_modules/facebook-messenger-bot/node_modules/superagent/lib/node/utils.js:108:12)
at emitNone (events.js:91:20)
at Unzip.emit (events.js:185:7)
at endReadableNT (_stream_readable.js:974:12)
at _combinedTickCallback (internal/process/next_tick.js:74:11)
at process._tickCallback (internal/process/next_tick.js:98:9)
Tracing deeper, the message coming from fb is:
Tried accessing nonexisting field (first_name) on node type (Page)
I am chatting with the bot in dev mode, but not as page.
Whenever I re-focus the chat window, it triggers the "on message" callback and repeats this,
Could this be connected to some "focus" event that is treated as "message" event or something?
Any Ideas what this could be?
including the exception.
Okay, I obviously selected to many webhooks from the list.
Would be great if the module would recognize the webhooks it does not support and not trigger a "message" callback...
Hi there,
I'm having constant problems with your example code. Code:
Leads to
Tracing deeper, the message coming from fb is:
I am chatting with the bot in dev mode, but not as page. Whenever I re-focus the chat window, it triggers the "on message" callback and repeats this, Could this be connected to some "focus" event that is treated as "message" event or something?
Any Ideas what this could be? including the exception.
Node version is 7.4.0.
Best,
Tobias