Skip to content

Commit 7a5215c

Browse files
committed
Fixes
1 parent 98bf1cd commit 7a5215c

File tree

5 files changed

+28
-27
lines changed

5 files changed

+28
-27
lines changed

labs/04-hello-world-bot/bot.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33

44
const { ActivityTypes } = require('botbuilder');
55

6+
/**
7+
* We will use compromise NLP library for text-matching.
8+
* http://compromise.cool
9+
*/
10+
const nlp = require('compromise');
11+
612
class MyBot {
713
/**
814
*
@@ -13,8 +19,15 @@ class MyBot {
1319
// Message activities may contain text, speech, interactive cards, and binary or unknown attachments.
1420
// see https://aka.ms/about-bot-activity-message to learn more about the message and other activity types
1521
if (turnContext.activity.type === ActivityTypes.Message) {
16-
let userMessage = turnContext.activity.text;
17-
await turnContext.sendActivity(`You said "${userMessage}"`);
22+
var rawtext = turnContext.activity.text
23+
24+
// interpret usermessage with compromise for further use
25+
var userMessage = nlp(rawtext);
26+
27+
if(userMessage.match("welcome")) {
28+
await turnContext.sendActivity(`Hello you!`);
29+
}
30+
await turnContext.sendActivity(`You said "${rawtext}"`);
1831
} else {
1932
// Generic handler for all other activity types.
2033
await turnContext.sendActivity(`[${ turnContext.activity.type } event detected]`);

labs/04-hello-world-bot/deploymentScripts/msbotClone/bot.recipe

Lines changed: 0 additions & 22 deletions
This file was deleted.

labs/04-hello-world-bot/hello-world-bot.bot

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
{
22
"name": "hello-world-bot",
33
"description": "",
4-
"services": [],
4+
"services": [
5+
{
6+
"type": "endpoint",
7+
"name": "development",
8+
"endpoint": "http://localhost:3978/api/messages",
9+
"appId": "",
10+
"appPassword": "",
11+
"id": "1"
12+
}
13+
],
514
"padlock": "",
615
"version": "2.0",
716
"path": "/Users/steffen/Projects/hfg gmuend/ai for designers/dev/lecture-nlp/labs/04-hello-world-bot/hello-world-bot.bot",

labs/04-hello-world-bot/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "nlp-bot",
2+
"name": "hello-world-bot",
33
"version": "1.0.0",
44
"description": "Demonstration bot for educational purposes",
55
"author": "Generated using Microsoft Bot Builder Yeoman generator v4.2.6",
@@ -14,6 +14,7 @@
1414
"dependencies": {
1515
"botbuilder": "^4.2.0",
1616
"botframework-config": "^4.2.0",
17+
"compromise": "^11.13.2",
1718
"dotenv": "^6.1.0",
1819
"restify": "^7.2.3"
1920
},

labs/05-nlp-bot/nlp-bot.bot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "steffen-chat-bot",
2+
"name": "nlp-chat-bot",
33
"services": [
44
{
55
"type": "endpoint",

0 commit comments

Comments
 (0)