简体   繁体   中英

Does Azure Bot Service SDK require restify? (node)

I am attempting to transfer my v3 Azure Bot Service ( npm botbuilder ) to v4, however all tutorials or documentation seem to include restify , whereas v3 did not.

Is this a strict requirement? Or does have anyone have any examples without restify ?

If so, does anyone know why it is required?

I am currently attempting to work on proactive messages from an azure function app.

V3: https://docs.microsoft.com/en-us/azure/bot-service/nodejs/bot-builder-nodejs-proactive-messages?view=azure-bot-service-3.0

V4: https://docs.microsoft.com/en-gb/azure/bot-service/bot-builder-howto-proactive-message?view=azure-bot-service-4.0&tabs=javascript

Thanks in advance.

As per the documentation for v3, it is stated as below:

The conversational logic for your bot is hosted as a web service. The Bot Framework SDK uses restify , a popular framework for building web services, to create the bot's web server. The SDK is also compatible with Express and the use of other web app frameworks is possible with some adaption.

Also, for the proactive messages from an azure functions app, refer to this Stack Overflow question which has the binding information for the azure function which will be triggered after every x minute.

Hope this helps.

It is not required to use restify or express in Bot Framework SDK v4. Any webserver framework that uses a similar WebRequest and WebResponse object is compatible with the Bot Framework.

Azure Functions could be used without any modifications. You create a httpTrigger listening to POST requests. Within the httpTrigger, you call the adapter.processActivity just like you would do in a 'normal' bot.

const httpTrigger: AzureFunction = async function (context: Context, req: HttpRequest): Promise<void> {

    adapter.processActivity(req as any, context.res as any, async (context) => {
        // Route to main dialog.
        await myBot.run(context);
    });

};

Currently you have to cast the WebRequest object as any while using Typescript and Azure Functions (or create a shim layer), but this will be solved in 4.9 according to this open pull request .

In order to send proactive notifications, you don't even need this approach. I created an example for a proactive function for Bot Framework SDK v4 in your similar question .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM