问题
Is there a way to implement a custom endpoint for my bot in node.js?. I saw the same for C# but it seems to to be implemented in node.js.
Here is the link to the C# implementation: Configure Custom Endpoint for Botframework Bot
A part from this, in the portal there was an option to connect the bot to an azure function, but I don't see it now. Here is the post where is saw it, on the step 3: https://blogs.msdn.microsoft.com/waws/2018/04/22/azure-bot-function/
Here is the C# code to implement and get a custom endpoint, the one it would be great to have in Node.js:
httpConfiguration.MapBotFramework(botConfig =>
{
botConfig.BotFrameworkOptions.Paths = new BotFrameworkPaths()
{
BasePath = "/bot",
MessagesPath = "/john"
};
});
回答1:
Remember that a chat bot is just a web app. You can customize the endpoint that your bot uses the same way you would customize the endpoint for any web app. The Bot Builder Node.js samples do this with Restify:
// Listen for incoming requests.
server.post('/api/messages', (req, res) => {
adapter.processActivity(req, res, async (context) => {
// Route to main dialog.
await bot.run(context);
});
});
If you want your bot to listen on a different endpoint, all you have to do is change /api/messages
to something else:
// Listen for incoming requests.
server.post('/bot/john', (req, res) => {
adapter.processActivity(req, res, async (context) => {
// Route to main dialog.
await bot.run(context);
});
});
To address your other concern, it appears to be no longer possible to create new functions bots, and support for them will soon expire: Is Functions Bot no longer a recommended Bot Service in Azure?
来源:https://stackoverflow.com/questions/57321571/how-to-configure-a-custom-endpoint-for-the-microsoft-bot