fix(btfmw): new dialog pattern fixing.

This commit is contained in:
Rodrigo Rodriguez (pragmatismo.io) 2018-11-12 13:00:30 -02:00
parent 54b816b3ca
commit bf48d12f76
4 changed files with 14 additions and 14 deletions

View file

@ -55,7 +55,7 @@ export class GBImporter {
localPath: string) { localPath: string) {
const packageJson = JSON.parse( const packageJson = JSON.parse(
Fs.readFileSync(UrlJoin(localPath, 'package.json'), 'utf8') fs.readFileSync(UrlJoin(localPath, 'package.json'), 'utf8')
); );
const botId = packageJson.botId; const botId = packageJson.botId;
@ -74,10 +74,10 @@ export class GBImporter {
packageJson: any packageJson: any
) { ) {
const settings = JSON.parse( const settings = JSON.parse(
Fs.readFileSync(UrlJoin(localPath, 'settings.json'), 'utf8') fs.readFileSync(UrlJoin(localPath, 'settings.json'), 'utf8')
); );
const servicesJson = JSON.parse( const servicesJson = JSON.parse(
Fs.readFileSync(UrlJoin(localPath, 'services.json'), 'utf8') fs.readFileSync(UrlJoin(localPath, 'services.json'), 'utf8')
); );
packageJson = {...packageJson, ...settings, ...servicesJson}; packageJson = {...packageJson, ...settings, ...servicesJson};

View file

@ -59,10 +59,10 @@ export class AskDialog extends IGBDialog {
min.dialogs.add( min.dialogs.add(
new WaterfallDialog('/answerEvent', [ new WaterfallDialog('/answerEvent', [
async step => { async step => {
if (step.options && step.options.questionId) { if (step.options && step.options['questionId']) {
const question = await service.getQuestionById( const question = await service.getQuestionById(
min.instance.instanceId, min.instance.instanceId,
step.options.questionId step.options['questionId']
); );
const answer = await service.getAnswerById( const answer = await service.getAnswerById(
min.instance.instanceId, min.instance.instanceId,
@ -84,9 +84,9 @@ export class AskDialog extends IGBDialog {
new WaterfallDialog('/answer', [ new WaterfallDialog('/answer', [
async step => { async step => {
const user = await min.userProfile.get(step.context, {}); const user = await min.userProfile.get(step.context, {});
let text = step.options.query; let text = step.options['query'];
if (!text) { if (!text) {
throw new Error(`/answer being called with no args.query text.`); throw new Error(`/answer being called with no args query text.`);
} }
const locale = step.context.activity.locale; const locale = step.context.activity.locale;
@ -97,9 +97,9 @@ export class AskDialog extends IGBDialog {
// Handle extra text from FAQ. // Handle extra text from FAQ.
if (step.options && step.options.query) { if (step.options && step.options['query']) {
text = step.options.query; text = step.options['query'];
} else if (step.options && step.options.fromFaq) { } else if (step.options && step.options['fromFaq']) {
await step.context.sendActivity(Messages[locale].going_answer); await step.context.sendActivity(Messages[locale].going_answer);
} }
@ -212,9 +212,9 @@ export class AskDialog extends IGBDialog {
// Three forms of asking. // Three forms of asking.
if (step.options && step.options.firstTime) { if (step.options && step.options['firstTime'] ) {
text = Messages[locale].ask_first_time; text = Messages[locale].ask_first_time;
} else if (step.options && step.options.isReturning) { } else if (step.options && step.options['isReturning'] ) {
text = Messages[locale].anything_else; text = Messages[locale].anything_else;
} else if (user.subjects.length > 0) { } else if (user.subjects.length > 0) {
text = Messages[locale].which_question; text = Messages[locale].which_question;

View file

@ -63,7 +63,7 @@ export class MenuDialog extends IGBDialog {
const locale = step.context.activity.locale; const locale = step.context.activity.locale;
let rootSubjectId = null; let rootSubjectId = null;
if (step.options && step.options.data) { if (step.options && step.options['data']) {
const subject = step.result.data; const subject = step.result.data;
// If there is a shortcut specified as subject destination, go there. // If there is a shortcut specified as subject destination, go there.

View file

@ -210,7 +210,7 @@ export class KBService {
public async getFaqBySubjectArray(from: string, subjects: any): Promise<GuaribasQuestion[]> { public async getFaqBySubjectArray(from: string, subjects: any): Promise<GuaribasQuestion[]> {
const where = { const where = {
from: from from: from, subject1: null, subject2: null, subject3: null, subject4:null
}; };
if (subjects) { if (subjects) {