@orisign/bot-sdk
v0.1.0
Published
Typed SDK for building bots on top of bot-service
Downloads
7
Maintainers
Readme
@orisign/bot-sdk
Typed Node.js SDK for building bots on top of bot-service.
Install
npm install @orisign/bot-sdkbun add @orisign/bot-sdkIncluded
BotServiceClientfor HTTP access tobot-serviceMarkupbuilders for inline/reply/remove/force-reply keyboardsBotModuleruntime with commands, callbacks, middleware, scenes and wizardsBotContextwith typed access to chat, user, message and session- callback payload signing helpers
Quick start
import { BotModule, BotServiceClient, Markup } from '@orisign/bot-sdk';
type Actions = {
'order:confirm': { orderId: string };
};
const client = new BotServiceClient({
baseUrl: 'http://localhost:4011',
apiKey: process.env.BOT_ADMIN_API_KEY,
});
const bot = new BotModule<Actions>({
botId: 'bot_123',
client,
});
bot.command('start', async (ctx) => {
await ctx.reply('Welcome', {
replyMarkup: Markup.inlineKeyboard([
[
Markup.button.callback('Confirm', 'order:confirm', { orderId: 'ord_1' }, {
secret: process.env.BOT_CALLBACK_SIGNING_SECRET,
}),
],
]),
});
});Publish
npm login
npm publish --access public