2

I am trying to build a bot using Microsoft Bot Framework. I am planning to use a Azure Function with Http Trigger as the endpoint. NodeJS is the language of my choice. I am seeing botframework examples with restify and nodejs but none on using azure functions. Can anyone point me to an example where botframework is developed using azure functions and nodejs or give me an example on how to do it.

2 Answers 2

2

You can see here https://github.com/vjrantal/bot-sample/commit/e80faefded1c9da9a8b0d69e36497bb221b54709 a changeset that brings Azure Functions compatibility to a bot built with restify.

The approach is borrowed from Chris Anderson's project at https://github.com/christopheranderson/functions-bot-example but includes updates to work with the latest botbuilder.

UPDATE: On latest Functions runtime, you don't need the wrapping anymore. See https://github.com/vjrantal/bot-sample/commit/fe56a16f6f0286bfe66095eefc417388c1bc1e1c for details.

Sign up to request clarification or add additional context in comments.

Comments

1

From Chris Anderson...

https://github.com/christopheranderson/functions-bot-example

You'll need to connect it to an HTTP trigger and the following code does the integration.

var listen = bot.listen();

var response = function (context) {
    return {
        send: function (status, message) {
            var _msg = message ? message : (typeof status !== 'number' ? status : null)
            var _status = typeof status === 'number' ? status : 200
            var res = {
                status: _status,
                body: _msg
            };

            context.res = res;
            context.done();
        }
    }
}



module.exports = function (context, req) {
    listen(req, response(context))
}

2 Comments

When I try with the above method I am getting the following error
2016-10-15T21:57:30.527 Exception while executing function: Functions.spellcheck. mscorlib: TypeError: res.status is not a function at ChatConnector.dispatch (D:\home\site\wwwroot\spellcheck\node_modules\botbuilder\lib\bots\ChatConnector.js:354:13) at ChatConnector.verifyBotFramework (D:\home\site\wwwroot\spellcheck\node_modules\botbuilder\lib\bots\ChatConnector.js:106:18) at D:\home\site\wwwroot\spellcheck\node_modules\botbuilder\lib\bots\ChatConnector.js:36:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.