bottender
Advanced tools
Changelog
0.15.1 / 2018-07-20
Changelog
0.15.0 / 2018-07-18
v0.15
is the second major version after we open sourced Bottender. In this version, we introduce a lot of helpful, community requested features based on Messaging APIs v0.7.
context.requestContext
:Express, Micro, Restify:
context.requestContext; // { req, res }
Koa:
context.requestContext; // ctx in koa
DEBUG
env:DEBUG=bottender:*
DEBUG=bottender:request
DEBUG=bottender:session:read
DEBUG=bottender:session:write
MemoryCacheStore
(#235)MessengerContext
method - sendQuickReplies
appsecret_proof
by default.context.getThreadOwner
const threadOwner = await context.getThreadOwner();
// {
// app_id: '12345678910'
// }
pageId
, gamePlay
, brandedCamera
, isRequestThreadControlFromPageInbox
getters to MessengerEvent
context.event.pageId; // "<PAGE_ID>"
context.event.isRequestThreadControlFromPageInbox; // true
context.event.isGamePlay; //
context.event.gamePlay; //
context.event.isBrandedCamera; //
context.event.brandedCamera; //
const { isError613 } = require('messenger-batch');
new MessengerBot({
// ...
batchConfig: {
delay: 1000,
shouldRetry: isError613, // (#613) Calls to this api have exceeded the rate limit.
retryTimes: 2,
},
});
It will enable message batching functionality via messaging-api-messenger under the hood.
sendAirlineFlightUpdateTemplate
has been renamed to sendAirlineUpdateTemplate
.replyFlex
, pushFlex
, sendFlex
:context.sendFlex('this is a flex', {
type: 'bubble',
header: {
type: 'box',
layout: 'vertical',
contents: [
{
type: 'text',
text: 'Header text',
},
],
},
hero: {
type: 'image',
url: 'https://example.com/flex/images/image.jpg',
},
body: {
type: 'box',
layout: 'vertical',
contents: [
{
type: 'text',
text: 'Body text',
},
],
},
footer: {
type: 'box',
layout: 'vertical',
contents: [
{
type: 'text',
text: 'Footer text',
},
],
},
styles: {
comment: 'See the example of a bubble style object',
},
});
issueLinkToken
to LineContext
(#245):const result = await context.issueLinkToken();
// {
// linkToken: 'NMZTNuVrPTqlr2IF8Bnymkb7rXfYv5EY',
// }
linkAccount
events support (#243):context.event.isAccountLink; // true
context.event.linkAccount;
// {
// result: 'ok',
// nonce: 'xxxxxxxxxxxxxxx',
// }
shouldBatch
option:new LineBot({
// ...
shouldBatch: true, // Default: false
});
When batching is enabled,
context.replyText('Hi');
context.replyText('Hi');
context.replyText('Hi');
context.replyText('Hi');
context.replyText('Hi');
Those 5 messages will be sent in one API call, just like the below one.
const { Line } = require('messaging-api-line');
context.reply([
Line.createText('Hi'),
Line.createText('Hi'),
Line.createText('Hi'),
Line.createText('Hi'),
Line.createText('Hi'),
]);
sendMethod
option:new LineBot({
// ...
sendMethod: 'reply', // Default: 'push'
});
ok
is false
in Telegram:{
ok: false,
result: { /* ... */ }
}
{
...query,
...body,
}
It's useful in custom connectors.
const { Context } = require('bottender');
class MyContext extends Context {
//...
}