How to use the @nlpjs/core.uuid function in @nlpjs/core

To help you get started, we’ve selected a few @nlpjs/core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github axa-group / nlp.js / packages / directline-connector / src / directline-controller.js View on Github external
createActivity(incoming, conversationId) {
    return {
      ...incoming,
      channelId: 'emulator',
      serviceUrl: this.serviceUrl,
      conversation: {
        id: conversationId,
      },
      address: {
        conversation: {
          id: conversationId,
        },
      },
      id: uuid(),
    };
  }
github axa-group / nlp.js / packages / directline-connector / src / directline-controller.js View on Github external
getConversation(id, autocreate = false) {
    const conversationId = id || uuid();
    if (!this.conversations[conversationId] && autocreate) {
      this.conversations[conversationId] = {
        conversationId,
        history: [],
      };
    }
    return this.conversations[conversationId];
  }
github axa-group / nlp.js / packages / directline-connector / src / directline-controller.js View on Github external
return new Promise(resolve => {
      const activity = srcActivity;
      activity.id = uuid();
      activity.from = {
        id: process.env.BACKEND_ID || 'directline',
        name: process.env.BACKEND_NAME || 'Directline',
      };
      const conversation = this.getConversation(conversationId, true);
      conversation.history.push(activity);
      resolve({
        status: 200,
      });
    });
  }
github axa-group / nlp.js / packages / directline-connector / src / directline-controller.js View on Github external
},
            });
          });
        } else {
          const result = {
            type: 'message',
            serviceUrl: activity.serviceUrl,
            channelId: activity.channelId,
            conversation: {
              id: activity.conversation.id,
            },
            text: activity.text,
            recipient: activity.from,
            inputHint: 'acceptingInput',
            replyToId: activity.id,
            id: uuid(),
            from: {
              id: process.env.BACKEND_ID || 'directline',
              name: process.env.BACKEND_NAME || 'Directline',
            },
          };
          const nlp = this.settings.container.get('nlp');
          if (nlp) {
            nlp
              .process({
                message: activity.text,
                channel: 'directline',
                app: this.settings.container.name,
              })
              .then(nlpresult => {
                result.text =
                  nlpresult.answer || "Sorry, I didn't understand you";

@nlpjs/core

Core

MIT
Latest version published 1 year ago

Package Health Score

75 / 100
Full package analysis

Similar packages