Facebook bot.identity is undefined
ouadie-lahdioui opened this issue · comments
Hello,
Facebook messenger doesn't support direct mention, so when i want to test some facebook conversations with this awesome botkit-mock, i got this error :
// BotmockWorker.js:66 -> var direct_mention = new RegExp('^\<\@' + bot.identity.id + '\>', 'i');
TypeError: Cannot read property 'id' of undefined
In BotmockWorker.js you try to prune off the bot's name and trim whitespaces, in my case bot.identity is undefined so bot.identity.id throw an error.
// Example of code
beforeEach(() => {
let controller = Botmock({});
bot = controller.spawn({type: 'facebook'});
controller.hears(['hi'], 'direct_message', function(bot, message){
bot.startConversation(message, function(response, convo){
convo.ask('hello there', function(response, convo){
convo.say('..user typed any text after `hi`');
convo.ask('here a question', function(response, convo){
convo.say('here an answer');
convo.next();
});
convo.next();
});
})
});
});
it('should return `help message` if user types `help`', (done) => {
let sequence = [
{
type: null, // direct_message, message_received, interactive_message_callback, defaults to direct_message
user: 'someUserId', // this.userInfo.slackId
channel: 'someChannel', //his.userInfo.channel
messages:[
{
text: 'hi',
},
{
text: 'its true',
deep: 1,
isAssertion:true,
}
]
}
];
bot.usersInput(sequence).then((message) => {
console.log(message);
expect(message.text).toBe('help message');
done();
});
});
Oups ! this fixed in the latest version 👍
:)
…On Sat, Jun 17, 2017 at 1:35 PM Ouadie Lahdioui ***@***.***> wrote:
Oups ! this fixed in the latest version 👍
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#28 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ACKLHv1NrmOlTmp0HqcC-G2_e_MzBRgGks5sFA58gaJpZM4N9SKm>
.