Commit 8c8f2680 authored by Tammo Ronke's avatar Tammo Ronke

Initial commit

parents
node_modules
mochawesome-report
package-lock.json
yarn.lock
yarn-error.lock
dist
test
lib
public
\ No newline at end of file
{
"name": "first-bot",
"version": "1.0.0",
"description": "Test",
"main": "server.js",
"author": "grievouz",
"license": "MIT",
"scripts": {
"serve": "tsc -p ./tsconfig.json --watch",
"build": "tsc -p ./tsconfig.json",
"bot": "node ./dist/app.js",
"clean":
"rm -rf ./dist && rm -rf ./test && rm -rf ./node_modules && rm -f ./yarn.lock && rm -f ./package-lock.json && rm -rf ./yarn-error.log && clear && echo -e \"\\e[1;31mFinished cleaning!\\e[0m\""
},
"dependencies": {
"botbuilder": "^3.14.1",
"restify": "^7.1.1"
},
"devDependencies": {
"@types/node": "^9.6.6",
"@types/restify": "^5.0.7",
"typescript": "^2.8.3"
}
}
import builder = require("botbuilder");
import restify = require("restify");
//=========================================================
// Bot Setup
//=========================================================
// Setup Restify Server
var server = restify.createServer();
server.listen(process.env.port || process.env.PORT || 3978, function() {
console.log("%s listening to %s", server.name, server.url);
});
// Create chat bot
var connector = new builder.ChatConnector({
appId: process.env.MY_APP_ID,
appPassword: process.env.MY_APP_PASSWORD
});
var bot = new builder.UniversalBot(connector);
server.post("/api/messages", connector.listen());
//=========================================================
// Bots Dialogs
//=========================================================
bot.dialog("/", (session: any) => {
var card = createHeroCard(session);
// attach the card to the reply message
var msg = new builder.Message(session).addAttachment(card);
session.send();
});
const createHeroCard = function(session: any) {
return new builder.ReceiptCard(session)
.title("John Doe")
.facts([
builder.Fact.create(session, "1234", "Order Number"),
builder.Fact.create(session, "VISA 5555-****", "Payment Method")
])
.items([
builder.ReceiptItem.create(session, "$ 38.45", "Data Transfer")
.quantity("368")
.image(
builder.CardImage.create(
session,
"https://github.com/amido/azure-vector-icons/raw/master/renders/traffic-manager.png"
)
),
builder.ReceiptItem.create(session, "$ 45.00", "App Service")
.quantity("720")
.image(
builder.CardImage.create(
session,
"https://github.com/amido/azure-vector-icons/raw/master/renders/cloud-service.png"
)
)
])
.tax("$ 7.50")
.total("$ 90.95")
.buttons([
builder.CardAction.openUrl(
session,
"https://azure.microsoft.com/en-us/pricing/",
"More Information"
).image(
"https://raw.githubusercontent.com/amido/azure-vector-icons/master/renders/microsoft-azure.png"
)
]);
};
{
"compilerOptions": {
"target": "es6",
"baseUrl": "./",
"rootDir": "./src",
"outDir": "./dist",
"module": "commonjs",
"pretty": true,
"removeComments": true,
"strict": true,
"noImplicitAny": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"strictPropertyInitialization": true,
"noImplicitThis": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": false,
"lib": ["es2016"],
"paths": {
"~src/*": ["./src/*"]
}
},
"exclude": ["node_modules"],
"include": ["./src/**/*.ts"]
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment