没有 Azure 的 Bot Framework 可能吗?
Bot Framework without Azure possible?
如果我使用 Microsoft Bot Framework 构建机器人,我是否需要将我的机器人部署到 Azure 以注册我的机器人 HERE 以便为机器人配置通道?
或者我可以简单地将我的机器人部署到普通的(例如)IIS 服务器吗?
我找不到关于此主题的任何信息,我不想使用 Azure。
是的,应该可以在 IIS 或任何其他托管服务(包括除 Azure 之外的云托管)中 运行 您的机器人,如 here 所述。您必须确保您的机器人具有可通过互联网访问的端点和有效的 HTTPS 证书。
关于HTTPS证书的要求,我复制了这个thread的信息供大家参考:
The Bot Framework requires that the x.509v3 certificate exposed by
your endpoint be current and valid. Most of the checks for "current
and valid" are standard checks for server certs: the CN must match the
hostname, it must not be expired, it must not be listed in a CRL, it
must have the correct set of EKUs, etc.
Most importantly, your cert must chain to a root certificate authority
trusted by Microsoft. The latest list of these CAs is available here.
此外,您可以注册您的机器人,甚至无需部署到 Azure 或任何其他主机即可启用频道。可以暂时使用ngrok to create a secure tunnel to your localhost environment and test the bot in your email channel before exposing it to other users. BTW, you don't need to Publish your bot in the BotFramework portal, just register it. Publishing is just for those bots that would like to appear in the Bot Directory.
是的,您的机器人就像一个 API,由 Facebook Messenger、Skype 等聊天前端使用。查看此媒体博客,了解如何在 Heroku 上托管 https://medium.com/@chinnatiptaemkaeo/create-fb-bot-with-heroku-nodejs-microsoft-bot-framework-687bd2893238
是的,完全可以在不使用 Azure 云门户的情况下开发机器人。
- 您只需要 node.js 或 C# 的机器人生成器 SDK。
- 像VSCode
这样的代码编辑器
在微软提供的机器人模拟器上测试
但要在频道或 Web 应用程序上发布机器人,您必须向 Azure 机器人服务注册机器人。
在此处查看更多信息:https://thewebspark.com/2018/04/15/is-microsoft-bot-framework-without-azure-possible/
你需要一个 Azure 帐户,但不需要直接在 Azure 上托管你的机器人。登录 Azure 仪表板时有三个选项:Web App Bot、Functions Bot 和 Bot Channels Registration。选择 Bot Channels Registration 并在设置中输入你的 bot 的 https URL(你部署它的地方)。
或者,如果您想直接从 Messenger(而非模拟器)调试您的机器人,您可以下载 ngrok,然后在命令行中输入
ngrok.exe http <your port> -host-header="localhost:<your port>
然后输入 ngrok 代理 URL(无端口)到 Bot Channels Registration 设置。
在几个小时内,该临时地址将转发到您的本地主机。
完全有可能。
我运行有两种方式。
1st - 在 docker 容器中重新定义服务 - 运行 在本地使用和 ngrok 以及在 AWS
// Create HTTP server.
const server = restify.createServer();
server.listen(process.env.port || process.env.PORT || 3978, () => {
console.log(`\n${server.name} listening to ${server.url}`);
});
async function main(req: WebRequest, context: TurnContext) {
logger.json("Request ->", req.body);
try {
for (const bot of allBots) {
await bot.run(context);
}
} catch (error) {
logger.error("Error processing request[server.ts]");
logger.error(error);
}
}
// Listen for incoming requests.
server.post("/api/messages", (req: WebRequest, res: WebResponse) => {
adapter.processActivity(req, res, async (context: TurnContext) => {
await main(req, context);
});
});
2nd - 运行 在 AWS Lambda 上使用无服务器框架。这是适配器。
export function lambda(bots: ActivityHandler[]) {
const handler: Handler = async (event: any, _: Context, callback: Callback) => {
logger.json("Event to bot framework: ", event);
const reqWrapper: WebRequest = {
body: event.body,
headers: event.headers,
method: event.method,
query: event.query,
on: (_1: string, ..._2: any[]): any => {
// it needs to be empty
},
};
let statusCode: number;
const resWrapper: WebResponse = {
status: (code: number) => {
statusCode = code;
},
send: (body) => {
callback(null, {statusCode, body});
},
end: () => {
callback(null, { statusCode });
},
};
const adapter = await getAdapter();
adapter.processActivity(reqWrapper, resWrapper, async (context: TurnContext) => {
await main(context, bots);
});
};
return handler;
}
如果我使用 Microsoft Bot Framework 构建机器人,我是否需要将我的机器人部署到 Azure 以注册我的机器人 HERE 以便为机器人配置通道? 或者我可以简单地将我的机器人部署到普通的(例如)IIS 服务器吗?
我找不到关于此主题的任何信息,我不想使用 Azure。
是的,应该可以在 IIS 或任何其他托管服务(包括除 Azure 之外的云托管)中 运行 您的机器人,如 here 所述。您必须确保您的机器人具有可通过互联网访问的端点和有效的 HTTPS 证书。
关于HTTPS证书的要求,我复制了这个thread的信息供大家参考:
The Bot Framework requires that the x.509v3 certificate exposed by your endpoint be current and valid. Most of the checks for "current and valid" are standard checks for server certs: the CN must match the hostname, it must not be expired, it must not be listed in a CRL, it must have the correct set of EKUs, etc.
Most importantly, your cert must chain to a root certificate authority trusted by Microsoft. The latest list of these CAs is available here.
此外,您可以注册您的机器人,甚至无需部署到 Azure 或任何其他主机即可启用频道。可以暂时使用ngrok to create a secure tunnel to your localhost environment and test the bot in your email channel before exposing it to other users. BTW, you don't need to Publish your bot in the BotFramework portal, just register it. Publishing is just for those bots that would like to appear in the Bot Directory.
是的,您的机器人就像一个 API,由 Facebook Messenger、Skype 等聊天前端使用。查看此媒体博客,了解如何在 Heroku 上托管 https://medium.com/@chinnatiptaemkaeo/create-fb-bot-with-heroku-nodejs-microsoft-bot-framework-687bd2893238
是的,完全可以在不使用 Azure 云门户的情况下开发机器人。
- 您只需要 node.js 或 C# 的机器人生成器 SDK。
- 像VSCode 这样的代码编辑器
在微软提供的机器人模拟器上测试
但要在频道或 Web 应用程序上发布机器人,您必须向 Azure 机器人服务注册机器人。 在此处查看更多信息:https://thewebspark.com/2018/04/15/is-microsoft-bot-framework-without-azure-possible/
你需要一个 Azure 帐户,但不需要直接在 Azure 上托管你的机器人。登录 Azure 仪表板时有三个选项:Web App Bot、Functions Bot 和 Bot Channels Registration。选择 Bot Channels Registration 并在设置中输入你的 bot 的 https URL(你部署它的地方)。
或者,如果您想直接从 Messenger(而非模拟器)调试您的机器人,您可以下载 ngrok,然后在命令行中输入
ngrok.exe http <your port> -host-header="localhost:<your port>
然后输入 ngrok 代理 URL(无端口)到 Bot Channels Registration 设置。 在几个小时内,该临时地址将转发到您的本地主机。
完全有可能。
我运行有两种方式。 1st - 在 docker 容器中重新定义服务 - 运行 在本地使用和 ngrok 以及在 AWS
// Create HTTP server.
const server = restify.createServer();
server.listen(process.env.port || process.env.PORT || 3978, () => {
console.log(`\n${server.name} listening to ${server.url}`);
});
async function main(req: WebRequest, context: TurnContext) {
logger.json("Request ->", req.body);
try {
for (const bot of allBots) {
await bot.run(context);
}
} catch (error) {
logger.error("Error processing request[server.ts]");
logger.error(error);
}
}
// Listen for incoming requests.
server.post("/api/messages", (req: WebRequest, res: WebResponse) => {
adapter.processActivity(req, res, async (context: TurnContext) => {
await main(req, context);
});
});
2nd - 运行 在 AWS Lambda 上使用无服务器框架。这是适配器。
export function lambda(bots: ActivityHandler[]) {
const handler: Handler = async (event: any, _: Context, callback: Callback) => {
logger.json("Event to bot framework: ", event);
const reqWrapper: WebRequest = {
body: event.body,
headers: event.headers,
method: event.method,
query: event.query,
on: (_1: string, ..._2: any[]): any => {
// it needs to be empty
},
};
let statusCode: number;
const resWrapper: WebResponse = {
status: (code: number) => {
statusCode = code;
},
send: (body) => {
callback(null, {statusCode, body});
},
end: () => {
callback(null, { statusCode });
},
};
const adapter = await getAdapter();
adapter.processActivity(reqWrapper, resWrapper, async (context: TurnContext) => {
await main(context, bots);
});
};
return handler;
}