Comments (8)
hey @fbessez could you provide an example of your code?
from botkit-mock.
Of course, just for a basic help message that returns a Rich Card / Adaptive Card
controller.hears('help', 'message_received', MiscUtls.help
MiscUtils.help = (bot, message) => { const reply = { attachments: [ { contentType: "application/vnd.microsoft.card.adaptive", content: { type: "AdaptiveCard", body: [ { type: 'TextBlock', text: 'Log Work', size: 'large', weight: 'bolder' }, { type: 'TextBlock', text: 'You can log work!', size: 'normal', weight: 'normal', separation: 'none', wrap: true }, { type: 'TextBlock', text: 'Get your time', size: 'large', weight: 'bolder' }, { type: 'TextBlock', text: 'Time.', size: 'normal', weight: 'normal', separation: 'none', wrap: true } ] } }] } bot.reply(message, reply); };
Does that help? Thank you!
from botkit-mock.
from botkit-mock.
Sweet, thank you!
from botkit-mock.
Your main entry point app.js
var Botkit = require('botkit');
var controller = Botkit.botframeworkbot({
debug: true
});
// Create the Botkit controller, which controls all instances of the bot.
var bot = controller.spawn({
appId: process.env.app_id,
appPassword: process.env.app_password
});
require('./indexController')(controller);
Logic of actions (indexController.js):
var MiscUtls = {};
MiscUtls.help = (bot, message) => {
const reply = {
attachments: [{
contentType: "application/vnd.microsoft.card.adaptive",
content: {
type: "AdaptiveCard",
body: [{type: 'TextBlock', text: 'Log Work', size: 'large', weight: 'bolder'}, {
type: 'TextBlock',
text: 'You can log work!',
size: 'normal',
weight: 'normal',
separation: 'none',
wrap: true
}, {type: 'TextBlock', text: 'Get your time', size: 'large', weight: 'bolder'}, {
type: 'TextBlock',
text: 'Time.',
size: 'normal',
weight: 'normal',
separation: 'none',
wrap: true
}]
}
}]
};
bot.reply(message, reply);
};
module.exports = function (controller) {
controller.hears('help', 'message_received', MiscUtls.help)
};
tests:
'use strict';
const assert = require('assert');
const Botmock = require('botkit-mock');
const fileBeingTested = require("./indexController");
describe("controller tests", () => {
afterEach(() => {
//clean up botkit tick interval
this.controller.shutdown()
});
beforeEach(() => {
this.userInfo = {
slackId: 'user123',
channel: 'channel123',
};
this.controller = Botmock({
debug: false,
});
this.bot = this.controller.spawn({});
fileBeingTested(this.controller);
});
it('should return correct attachments object in message', () => {
let sequence = [
{
//type: null, //if type null, default to direct_message
user: this.userInfo.slackId, //user required for each direct message
channel: this.userInfo.channel, // user channel required for direct message
messages: [
{
text: 'help',
isAssertion: true,
}
]
}
];
return this.bot.usersInput(sequence).then((message) => {
let testValue = {
attachments: [{
contentType: "application/vnd.microsoft.card.adaptive",
content: {
type: "AdaptiveCard",
body: [{type: 'TextBlock', text: 'Log Work', size: 'large', weight: 'bolder'}, {
type: 'TextBlock',
text: 'You can log work!',
size: 'normal',
weight: 'normal',
separation: 'none',
wrap: true
}, {type: 'TextBlock', text: 'Get your time', size: 'large', weight: 'bolder'}, {
type: 'TextBlock',
text: 'Time.',
size: 'normal',
weight: 'normal',
separation: 'none',
wrap: true
}]
}
}]
};
return assert.deepEqual(message.attachments, testValue.attachments);
})
});
});
from botkit-mock.
@ihorrusinko @amplicity Beautiful! I really appreciate all of the work you have put in! I will double check to see if this works upon returning to work :)
from botkit-mock.
Great! It works wonderfully! Do you mind also mapping out for me how I'd go about testing a conversation? So if user says 'What is my name?' then bot should respond 'fbessez, right?' and then I would say 'yes' or 'no'. How do I test that out? Do I add those messages to the sequence? and then add responses?
from botkit-mock.
@fbessez checkout this example please
https://github.com/gratifyguy/botkit-mock/tree/master/examples/convo-bot
it should be what you need
from botkit-mock.
Related Issues (20)
- 100ms is not enough for some responses HOT 11
- Indentation Issue in Test Example HOT 1
- Support replyAndUpdate HOT 4
- Test controller.api.* (eg. Facebook's messenger_profile) functions HOT 6
- can't set afterProcessingUserMessageTimeout on each bot.usersInput. HOT 3
- AssertionError HOT 22
- bot.whisper is not a function HOT 4
- Does it work with SocketBot? HOT 2
- Where is "this" coming from in the examples HOT 3
- middleware interface HOT 9
- Relax deps permit use of 4.x HOT 2
- v4 is a breaking change. HOT 6
- Having trouble testing predefined botkit dialogs HOT 6
- bot.identity throws on Slack HOT 12
- Configurable baseUrl for use with yakbak HOT 2
- Audit issues with Handlebars HOT 1
- @slack/web-api dependency causes `invalid_auth` throws on every instantiation of adapter HOT 5
- Events not registering for testing `controller.trigger()` HOT 3
- Multi-step Testing? HOT 1
- Twilio SMS adapter? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from botkit-mock.