How to use the botbuilder-ai.LocaleConverter function in botbuilder-ai

To help you get started, we’ve selected a few botbuilder-ai examples, based on popular ways it is used in public projects.

github microsoft / botbuilder-js / samples / luis-translator-ts / src / app.ts View on Github external
} else {
        return Promise.resolve(false);
    }
}

// Add language translator middleware
const languageTranslator = new LanguageTranslator({
    translatorKey: "xxxxxx",
    nativeLanguages: ['en'],
    setUserLanguage: setUserLanguage,
    getUserLanguage: getUserLanguage 
});
adapter.use(languageTranslator);

// Add locale converter middleware
const localeConverter = new LocaleConverter({
    toLocale: 'en-us',
    setUserLocale: setUserLocale,
    getUserLocale: getUserLocale
});
adapter.use(localeConverter);

// Add Luis recognizer middleware
const luisRecognizer = new LuisRecognizer({
    appId: "xxxxxx",
    subscriptionKey: "xxxxxx"
});
adapter.use(luisRecognizer);

// Listen for incoming requests 
server.post('/api/messages', (req, res) => {
    // Route received request to adapter for processing
github microsoft / botbuilder-js / samples / qna-translator-es6 / app.js View on Github external
return Promise.resolve(false);
    }
}

// Add language translator middleware
const languageTranslator = new LanguageTranslator({
    translatorKey: "xxxxxx",
    nativeLanguages: ['en'],
    setUserLanguage: setUserLanguage,
    getUserLanguage: getUserLanguage,
    translateBackToUserLanguage: true
});
adapter.use(languageTranslator);

// Add locale converter middleware
const localeConverter = new LocaleConverter({
    toLocale: 'en-us',
    setUserLocale: setUserLocale,
    getUserLocale: getUserLocale,
});
adapter.use(localeConverter);

// Add Qna Maker middleware
const qnaMaker = new QnAMaker({
    knowledgeBaseId: "xxxxxx",
    subscriptionKey: "xxxxxx",
    answerBeforeNext: true,
});
adapter.use(qnaMaker);

// Listen for incoming requests 
server.post('/api/messages', (req, res) => {
github microsoft / botbuilder-js / samples / qna-translator-ts / src / app.ts View on Github external
} else {
        return Promise.resolve(false);
    }
}

// Add language translator middleware
const languageTranslator = new LanguageTranslator({
    translatorKey: "xxxxxx",
    nativeLanguages: ['en'],
    setUserLanguage: setUserLanguage,
    getUserLanguage: getUserLanguage 
});
adapter.use(languageTranslator);

// Add locale converter middleware
const localeConverter = new LocaleConverter({
    toLocale: 'en-us',
    setUserLocale: setUserLocale,
    getUserLocale: getUserLocale
});
adapter.use(localeConverter);

// Add Qna Maker middleware
const qnaMaker = new QnAMaker({
    knowledgeBaseId: "xxxxxx",
    subscriptionKey: "xxxxxx"
});
adapter.use(qnaMaker);

// Listen for incoming requests 
server.post('/api/messages', (req, res) => {
    // Route received request to adapter for processing
github microsoft / botbuilder-js / samples / qna-translator-ts / lib / app.js View on Github external
else {
            return Promise.resolve(false);
        }
    });
}
// Add language translator middleware
const languageTranslator = new botbuilder_ai_1.LanguageTranslator({
    translatorKey: "xxxxxx",
    noTranslatePatterns: new Set(),
    nativeLanguages: ['en'],
    setUserLanguage: setUserLanguage,
    getUserLanguage: getUserLanguage
});
adapter.use(languageTranslator);
// Add locale converter middleware
const localeConverter = new botbuilder_ai_1.LocaleConverter({
    toLocale: 'en-us',
    setUserLocale: setUserLocale,
    getUserLocale: getUserLocale
});
adapter.use(localeConverter);
// Add Qna Maker middleware
const qnaMaker = new botbuilder_ai_1.QnAMaker({
    knowledgeBaseId: "xxxxxx",
    subscriptionKey: "xxxxxx"
});
adapter.use(qnaMaker);
// Listen for incoming requests 
server.post('/api/messages', (req, res) => {
    // Route received request to adapter for processing
    adapter.processActivity(req, res, (context) => __awaiter(this, void 0, void 0, function* () {
        if (context.activity.type != 'message') {
github microsoft / botbuilder-js / samples / translator-ts / lib / app.js View on Github external
const adapter = new botbuilder_1.BotFrameworkAdapter({
    appId: process.env.MICROSOFT_APP_ID,
    appPassword: process.env.MICROSOFT_APP_PASSWORD
});
// Add conversation state middleware
const conversationState = new botbuilder_1.ConversationState(new botbuilder_1.MemoryStorage());
adapter.use(conversationState);
// Add language translator middleware
const languageTranslator = new botbuilder_ai_1.LanguageTranslator({
    translatorKey: "xxxxxx",
    noTranslatePatterns: new Set(),
    nativeLanguages: ['fr', 'de']
});
adapter.use(languageTranslator);
// Add locale converter middleware
const localeConverter = new botbuilder_ai_1.LocaleConverter({
    toLocale: 'fr-fr',
    fromLocale: 'en-us'
});
adapter.use(localeConverter);
// Listen for incoming requests 
server.post('/api/messages', (req, res) => {
    // Route received request to adapter for processing
    adapter.processActivity(req, res, (context) => __awaiter(this, void 0, void 0, function* () {
        if (context.activity.type === 'message') {
            const state = conversationState.get(context);
            const count = state.count === undefined ? state.count = 0 : ++state.count;
            yield context.sendActivity(`${count}: You said "${context.activity.text}"`);
        }
        else {
            yield context.sendActivity(`[${context.activity.type} event detected]`);
        }
github microsoft / botbuilder-js / samples / translator-ts / src / app.ts View on Github external
count: number;
}

// Add conversation state middleware
const conversationState = new ConversationState<EchoState>(new MemoryStorage());
adapter.use(conversationState);

// Add language translator middleware
const languageTranslator = new LanguageTranslator({
    translatorKey: "xxxxxx",
    nativeLanguages: ['fr', 'de'] 
});
adapter.use(languageTranslator);

// Add locale converter middleware
const localeConverter = new LocaleConverter({
    toLocale: 'fr-fr',
    fromLocale: 'en-us'
})
adapter.use(localeConverter);

// Listen for incoming requests 
server.post('/api/messages', (req, res) => {
    // Route received request to adapter for processing
    adapter.processActivity(req, res, async (context) => {
        if (context.activity.type === 'message') {
            const state = conversationState.get(context);
            const count = state.count === undefined ? state.count = 0 : ++state.count;
            await context.sendActivity(`${count}: You said "${context.activity.text}"`);
        } else {
            await context.sendActivity(`[${context.activity.type} event detected]`);
        }
github microsoft / botbuilder-js / samples / translator-es6 / app.js View on Github external
appPassword: process.env.MICROSOFT_APP_PASSWORD 
});

// Add conversation state middleware
const conversationState = new ConversationState(new MemoryStorage());
adapter.use(conversationState);

// Add language translator middleware
const languageTranslator = new LanguageTranslator({
    translatorKey: "xxxxxx",
    nativeLanguages: ['fr', 'de'] 
});
adapter.use(languageTranslator);

// Add locale converter middleware
const localeConverter = new LocaleConverter({
    toLocale: 'fr-fr',
    fromLocale: 'en-us'
})
adapter.use(localeConverter);

// Listen for incoming requests 
server.post('/api/messages', (req, res) => {
    // Route received request to adapter for processing
    adapter.processActivity(req, res, (context) => {
        if (context.activity.type === 'message') {
            const state = conversationState.get(context);
            const count = state.count === undefined ? state.count = 0 : ++state.count;
            return context.sendActivity(`${count}: You said "${context.activity.text}"`);
        } else {
            return context.sendActivity(`[${context.activity.type} event detected]`);
        }
github microsoft / botbuilder-js / samples / luis-translator-ts / lib / app.js View on Github external
else {
            return Promise.resolve(false);
        }
    });
}
// Add language translator middleware
const languageTranslator = new botbuilder_ai_1.LanguageTranslator({
    translatorKey: "xxxxxx",
    noTranslatePatterns: new Set(),
    nativeLanguages: ['en'],
    setUserLanguage: setUserLanguage,
    getUserLanguage: getUserLanguage
});
adapter.use(languageTranslator);
// Add locale converter middleware
const localeConverter = new botbuilder_ai_1.LocaleConverter({
    toLocale: 'en-us',
    setUserLocale: setUserLocale,
    getUserLocale: getUserLocale
});
adapter.use(localeConverter);
// Add Luis recognizer middleware
const luisRecognizer = new botbuilder_ai_1.LuisRecognizer({
    appId: "xxxxxx",
    subscriptionKey: "xxxxxx"
});
adapter.use(luisRecognizer);
// Listen for incoming requests 
server.post('/api/messages', (req, res) => {
    // Route received request to adapter for processing
    adapter.processActivity(req, res, (context) => __awaiter(this, void 0, void 0, function* () {
        if (context.activity.type != 'message') {

botbuilder-ai

Cognitive services extensions for Microsoft BotBuilder.

MIT
Latest version published 6 days ago

Package Health Score

90 / 100
Full package analysis

Similar packages