Skip to content

Conversation

@chentsulin
Copy link
Collaborator

@chentsulin chentsulin commented Feb 5, 2018

With fallbackMethods: true, we can test all of methods using ConsoleBot:

const bot = new ConsoleBot({ fallbackMethods: true });

bot.onEvent(async context => {
  await context.sendText('Hello World');
  await context.sendImage('https://example.com/vr.jpg');
  await context.sendButtonTemplate('What do you want to do next?', [
    {
      type: 'web_url',
      url: 'https://petersapparel.parseapp.com',
      title: 'Show Website',
    },
    {
      type: 'postback',
      title: 'Start Chatting',
      payload: 'USER_DEFINED_PAYLOAD',
    },
  ]);
});

Result:

Bot > Hello World
Bot > sendImage: ["https://example.com/vr.jpg"]
Bot > sendButtonTemplate: ["What do you want to do next?",[{"type":"web_url","url":"https://petersapparel.parseapp.com","title":"Show Website"},{"type":"postback","title":"Start Chatting","payload":"USER_DEFINED_PAYLOAD"}]]

@chentsulin chentsulin force-pushed the console-fallback-methods branch from f2627bb to d72e8e9 Compare February 5, 2018 04:39
// should return undefined when check if it is a promise
if (key === 'then') return;
return async (...args) => {
await target._methodMissing.call(target, key, args);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we just await target._methodMissing(key, args);?

@chentsulin chentsulin force-pushed the console-fallback-methods branch from d72e8e9 to 6e0952b Compare February 5, 2018 09:56
@chentsulin chentsulin merged commit 88d0e6c into master Feb 5, 2018
@chentsulin chentsulin deleted the console-fallback-methods branch February 5, 2018 15:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants