Thursday 8 June 2017

How to use direct line API to receive the message from Line@ on Azure Bot Service

I am trying to use Azure Bot Service to create a LINE@ chat bot. The following is the template index.js generated by Azure Bot Service. As I know, I need to use Direct Line API to receive the message from LINE APP. However, I do not know how to do.


`"use strict";

var builder = require("botbuilder");

var botbuilder_azure = require("botbuilder-azure");

var path = require('path');

var useEmulator = (process.env.NODE_ENV == 'development');

var connector = useEmulator ? new builder.ChatConnector() : new botbuilder_azure.BotServiceConnector({

appId: process.env['MicrosoftAppId'],
appPassword: process.env['MicrosoftAppPassword'],
stateEndpoint: process.env['BotStateEndpoint'],
openIdMetadata: process.env['BotOpenIdMetadata']

});

var bot = new builder.UniversalBot(connector);

bot.localePath(path.join(__dirname, './locale'));

bot.dialog('/', function (session) {

session.send('You said ' + session.message.text);

});

if (useEmulator) {

var restify = require('restify');
var server = restify.createServer();
server.listen(3978, function() {
    console.log('test bot endpont at http://localhost:3978/api/messages');
});
server.post('/api/messages', connector.listen());    

} else { module.exports = { default: connector.listen() } }`



via Chih-Shu Shih

No comments:

Post a Comment