Commit 80dbaed2 authored by Yorrd's avatar Yorrd
Browse files

feat: new intent field

parent ff6dfa42
Pipeline #1396 passed with stages
in 11 minutes and 27 seconds
......@@ -101,6 +101,7 @@ export class CCBContentsAdmin extends AdornisDBView<Content> {
${this.fieldDisplays(this.getField('Frage')!, entity, index)}
${this.fieldDisplays(this.getField('Antwort')!, entity, index)}
${this.fieldDisplays(this.getField('Quelle')!, entity, index)}
${this.fieldDisplays(this.getField('intent')!, entity, index)}
<a-stack horizontal centeraligned size="md">
<div class="${this.css({ flex: '1' })}">
${this.fieldDisplays(this.getField('Ansprechpartner')!, entity, index)}
......@@ -225,6 +226,7 @@ export class CCBContentsAdmin extends AdornisDBView<Content> {
case 'Frage':
case 'Quelle':
case 'Ansprechpartner':
case 'intent':
return html`
<mwc-textfield
style="width: 100%"
......
......@@ -66,6 +66,8 @@ export class Content extends AdornisFile {
public ratings!: Rating[];
@Field(String)
public country?: Country;
@Field(String)
public intent?: string;
public rate(positive: boolean) {
this.ratings.push(new Rating({ rating: positive }));
......
Subproject commit e4dd76a597dfad5e59f3ce6ce70962eb701c6753
Subproject commit c739c2c9235276b61ec04046f161c7b88373ea8d
Subproject commit bb577d7f8028320028eacfca60d1acdb856f6a1a
Subproject commit 880b11d5faf023bd2c89a8f87f33d0ba676a6fb9
......@@ -6,6 +6,7 @@ import { files } from '@adornis/file-utils/db';
import { AdornisUser } from 'imports/git_modules/users/db';
import { CCBUser } from 'imports/db/ccbuser';
import { timeout } from 'rxjs/operators';
import { Content } from 'imports/db';
process.env.DEBUG = 'dialogflow:debug'; // enables lib debugging statements
......@@ -108,7 +109,7 @@ expressApp.post('/api/dialogflow-webhook', (request, response, next) => {
switch (agent.intent) {
case 'welcome disclaimer': {
agent.add('Hallo');
agent.add('Hallo ' + agent.originalRequest.payload.data.from.first_name);
agent.add(
'Ich bin erst wenige Stunden alt, also noch eine Beta-Version. Es kann sein, dass mich die ein oder andere Frage noch verwirrt. Wenn Du mir Feedback gibst lerne ich und werde jeden Tag besser! \nKennst du schon den Disclaimer zur Haftung und zum Datenschutz schon?',
);
......@@ -118,17 +119,22 @@ expressApp.post('/api/dialogflow-webhook', (request, response, next) => {
break;
}
default: {
if (!agent.query) {
agent.add('Oops... Hier gibts wohl noch einen Bug');
let content: Content | null = null;
if (agent.intent && (await Content.findOne({ intent: agent.intent }).result)) {
const foundContent = (await Content.findOne({ intent: agent.intent }).result) as Content | null;
content = foundContent;
} else {
const foundContents = await (files.rawCollection() as Collection)
.find({ $text: { $search: agent.query } })
.project({ score: { $meta: 'textScore' } })
// .filter({ score: { $gte: 0.7 } })
.sort({ score: { $meta: 'textScore' } })
.toArray();
console.log(foundContents.map(x => x.score));
content = foundContents[0];
}
const foundContents = await (files.rawCollection() as Collection)
.find({ $text: { $search: agent.query } })
.project({ score: { $meta: 'textScore' } })
// .filter({ score: { $gte: 0.7 } })
.sort({ score: { $meta: 'textScore' } })
.toArray();
console.log(foundContents.map(x => x.score));
const content = foundContents[0];
if (!content) {
agent.add('Da kann ich dir leider nicht weiterhelfen.');
agent.add(new Suggestion('jetzt mit Menschen schreiben'));
......
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