owin 怎么部署在云中
by Rajat Saxena
通过拉贾特·萨克森纳(Rajat Saxena)
我如何完全在云中设计,开发和部署聊天机器人 (How I designed, developed, and deployed a chatbot entirely in the cloud)
It all started with a YouTube video I recorded few months back. In it, I talked about the importance of deliberate revision. This helps you retain things in your mind for a longer period of time, and gives you techniques to revise important projects. If you haven’t, please watch it here.
一切始于几个月前我录制的YouTube视频。 在其中,我谈到了故意修订的重要性。 这可以帮助您将事情长时间保留在您的脑海中,并为您提供修改重要项目的技巧。 如果还没有,请在这里观看 。
In the video, I talked about how frequently you should revise, what the heck is the forgetting curve, and why you should care.
在视频中,我谈到了您应该多久进行一次修改, 遗忘曲线到底是什么,以及您为什么要关心它。
I wanted to give you guys a proper tool, in addition to the video, so that you can revise better. Being a developer, my natural response was “Let’s write an app!”
除了视频之外,我还想给你们一个合适的工具,以便您更好地进行修改。 作为开发人员,我的自然React是“让我们编写一个应用程序!”
But if you’ve read my other article about why native apps are doomed, you know I was a bit reluctant to write a standalone app for this. I took a step back and analyzed the situation. I needed a back-end to store users’ data and a front-end to collect and show that data.
但是,如果您已经阅读了另一篇关于本机应用程序注定失败的原因的文章,那么您会知道我有点不愿意为此编写一个独立的应用程序。 我退后一步,分析了情况。 我需要一个后端来存储用户的数据,并需要一个前端来收集和显示该数据。
I wanted the user on-boarding to be as frictionless as possible. Forcing users to download a new app is hard. If I built a chatbot, it would serve that purpose and I wouldn’t have to convince anyone to download anything. I would also save some time since I wouldn’t have to build a standalone client app and go through app stores’ processes.
我希望入职的用户尽可能地保持无摩擦。 强制用户下载新应用程序很困难。 如果我构建了一个聊天机器人,它将达到这个目的,并且我不必说服任何人下载任何内容。 我还可以节省一些时间,因为我不必构建独立的客户端应用程序并经历应用程序商店的流程。
You can try the bot I built here.
您可以尝试我在这里构建的机器人。
Let’s cut to the chase and talk about the process. Read on to see how my chatbot went from an idea to a fully working product — entirely using cloud-based tools.
让我们开始追逐并讨论一下过程。 继续阅读以了解我的聊天机器人如何从一个想法变成一个完全可用的产品-完全使用基于云的工具。
任务1:AI和NLP (Quest 1: AI and NLP)
Natural Language Processing (NLP) and AI are integral parts of any smart chatbot. So, I knew from the start that I’d require AI and NLP to make my bot “smart” and something you could talk to. It should also understand what you are asking it to do. I come from a full stack development background and I have zero experience with Machine Learning, AI or NLP. But for this bot, all of these things were necessities.
自然语言处理(NLP)和AI是任何智能聊天机器人的组成部分。 因此,我从一开始就知道我需要AI和NLP来使我的机器人“智能”,并且可以与之对话。 它还应该了解您要执行的操作。 我来自全栈开发背景,并且对机器学习,AI或NLP的经验为零。 但是对于这个机器人来说,所有这些都是必需的。
Being a tech enthusiast, I always keep tabs on what tools and libraries the Biggies are launching. I was aware of Wit.ai, an online API, released by Facebook for enabling NLP in your apps and bots. I played around with it for a while but found it particularly hard.
作为技术爱好者,我始终密切关注Biggies正在推出哪些工具和库。 我知道Facebook发行的在线API Wit.ai ,用于在您的应用程序和机器人中启用NLP。 我玩了一段时间,但发现它特别难。
I quickly searched for other alternatives and found Api.ai. I played around with it and found it more developer-friendly, so I went with it.
我Swift搜索了其他替代方法并找到了Api.ai。 我试用了它,发现它对开发人员更友好,因此我选择了它。
Here’s what exactly you do with these ai APIs:
您正是使用这些AI API的方法如下:
- First, you write down a probable conversation which can happen between your bot and a person. 首先,您写下一个可能在您的机器人与人之间发生的对话。
- Based on that conversation, you create an exclusive flow-diagram (or something like that) which handles all the outcomes of the conversation. 根据该对话,您可以创建一个专用的流程图(或类似的流程图)来处理对话的所有结果。
- You program the Api.ai agent to handle all the pre-defined outcomes using its dashboard. It’s simple enough — once you learn it. 您可以对Api.ai代理进行编程,以使用其仪表板处理所有预定义的结果。 这很简单-一旦您学会了它。
Note: You can call on custom logic, which resides in your secure back-end, if API.ai’s built-in handlers can’t handle your use case. In the case of Revisebot, I was storing each user’s learning history and calculating what topics the user should revise next. This required custom calculations and persistence mechanisms.
注意:如果API.ai的内置处理程序无法处理您的用例,则可以调用位于安全后端中的自定义逻辑。 就Revisebot而言,我存储了每个用户的学习历史并计算了用户接下来应修改哪些主题。 这需要自定义计算和持久性机制。
Api.ai also offers some pre-built agents, such as small talk and weather agents, which can answer users’ queries about weather and other topics. These are plug-n-play things which you can readily use in your chatbots.
Api.ai还提供了一些预制的代理,例如闲聊和天气代理,它们可以回答用户对天气和其他主题的查询。 这些是即插即用的东西,您可以在聊天机器人中轻松使用。
Since Revisebot needed to handle custom use cases, I had to write some code. Time to churn out some JavaScript/Node.js code. Yay!
由于Revisebot需要处理自定义用例,因此我不得不编写一些代码。 是时候推出一些JavaScript / Node.js代码了。 好极了!
任务2:云托管 (Quest 2: Cloud Hosting)
I am a long time user of Digital Ocean, but it costs around $6/month at a minimum. Since I wasn’t hoping to make money off of Revisebot, hosting it on Digital Ocean didn’t make sense. I’d be losing money on a monthly basis.
我是Digital Ocean的长期用户,但每月最低费用约为$ 6。 由于我不希望通过Revisebot赚钱,因此将其托管在Digital Ocean上没有任何意义。 我每月都会亏钱。
I needed a free cloud host for this project. I knew Firebase offered free hosting (as I’ve used it in the past). I have also used Open Shift as well, for other projects (mostly Laravel). But I thought it would be a great idea to Google some other alternatives, at least for the sake of Node.js.
我需要一个免费的云主机来进行该项目 。 我知道Firebase提供了免费托管(因为我过去曾经使用过)。 我也将Open Shift用于其他项目(主要是Laravel )。 但我认为,至少对于Node.js而言,这对Google来说是一个不错的选择。
That’s when I came across Heroku and its free plan.
那是我遇到Heroku及其免费计划的时候。
In no time, I learned that Heroku’s Node.js integration is awesome. So I read their docs and quickly spun up a Node.js app on their free dynamo. It was enough for my needs. Its only limitation was that it sleeps after a while, so the first API call might fail while the dynamo is waking up from sleep. But I adapted my chatbot to respond to such scenarios.
我很快就知道Heroku的Node.js集成很棒。 因此,我阅读了他们的文档,并在他们的免费发电机上快速启动了Node.js应用程序。 足以满足我的需求。 唯一的限制是它会在一段时间后进入睡眠状态,因此在发电机从睡眠状态唤醒时,第一个API调用可能会失败。 但是我修改了聊天机器人来应对这种情况。
任务3:云中的MongoDB (Quest 3: MongoDB in the cloud)
I had been contemplating learning some MongoDB. So I decided to use MongoDB as the database for my chatbot. A chat app is a good use case for MongoDB’s document-based storage system.
我一直在考虑学习一些MongoDB。 因此,我决定将MongoDB用作聊天机器人的数据库。 聊天应用程序是MongoDB基于文档的存储系统的一个很好的用例。
My plan ran into a little roadblock when I discovered that Heroku does not offer MongoDB integration for free. No worries — I went back to my friend Google and searched for a “Free MongoDB cloud.”
当我发现Heroku不免费提供MongoDB集成时,我的计划遇到了一些障碍。 不用担心-我回到朋友Google那里,搜索了“免费的MongoDB云”。
That’s how I came to know about mLabs, which offers free MongoDB instances in the cloud.
这就是我了解mLabs的方式 , mLabs在云中提供免费的MongoDB实例。
Their free plan is not recommended for production ready apps, but that’s OK. I’m gonna run my chatbot on the free plan anyway.
不建议将其免费计划用于生产准备就绪的应用程序,但这没关系。 无论如何,我将以免费计划运行我的聊天机器人。
任务4:Cloud IDE (Quest 4: Cloud IDE)
My plan was to code the entire thing up in whatever free time I had after my full time job. Because of this, I needed the flexibility of coding from anywhere. So my developer workspace needed to reside in the cloud, which I could load up from anywhere I had internet.
我的计划是在完成全职工作后的空闲时间里将整个事情编码。 因此,我需要从任何地方进行编码的灵活性。 因此,我的开发人员工作区需要驻留在云中,可以从任何有互联网的地方加载它。
I’ve been using cloud-based IDEs for quite a while and the experience is mixed. Nitrous.io was awesome but they shut it down. :( After trying some online IDEs like cloud9 and codeanywhere, the one that I found most stable and developer-friendly was Codenvy. It offers workspaces which you can create or destroy at your own will.
我使用基于云的IDE已经有一段时间了,经验是好坏参半。 Nitrous.io很棒,但是他们关闭了它 。 :(在尝试了一些在线IDE(例如cloud9和codeanywhere)之后 ,我发现最稳定且对开发人员最友好的一个是Codenvy 。它提供了可以随意创建或销毁的工作区。
So I created a new Ubuntu-based workspace in Codenvy and installed node, npm, git and curl right away. Codenvy offers a terminal as well, so Linux users feel right at home. My developer workspace in the cloud was all set.
因此,我在Codenvy中创建了一个新的基于Ubuntu的工作区,并立即安装了节点npm,git和curl。 Codenvy还提供了一个终端,因此Linux用户感到宾至如归。 我在云中的开发人员工作区已全部设置好。
Next, I git-cloned my project’s repository from Heroku, and set up the DB integration with mLab’s MongoDB instance using .env files. As you can see in the screenshot below, blooming-escarpment-58368 was my Heroku Node.js project.
接下来,我从Heroku 克隆了我的项目的存储库,并使用设置了与mLab的MongoDB实例的数据库集成。 环境文件。 正如您在下面的屏幕快照中看到的那样, blooming-scarpment-58368是我的Heroku Node.js项目。
任务5:将聊天机器人与社交媒体API集成 (Quest 5: Integrating the chatbot with Social Media APIs)
The chatbot was supposed to work with Facebook Messenger and Slack. I would have to learn the developer APIs for both platforms and set up my development machine for testing the API calls. Luckily, Api.ai also offers easy one-click integration with most of the social media platforms. You just have to follow their documentation to bring your chatbot to the specified platform.
该聊天机器人应该与Facebook Messenger和Slack一起使用。 我将必须学习两种平台的开发人员API,并设置我的开发机器以测试API调用。 幸运的是, Api.ai还提供与大多数社交媒体平台的轻松一键式集成。 您只需要遵循他们的文档,即可将您的聊天机器人带到指定的平台。
As you can see in the screenshot above, I’ve integrated Revisebot with Facebook Messenger and Slack, as of now. This step won’t take long, believe me.
如您在上面的屏幕截图中所见,到目前为止,我已经将Revisebot与Facebook Messenger和Slack集成在一起。 相信我,这一步不会花很长时间。
Using these tools, I was able to write, test and deploy the entire ecosystem of my chatbot (the DB, the application layer, the front-end and the AI agent) to react to users’ queries.
使用这些工具,我能够编写,测试和部署我的聊天机器人的整个生态系统(数据库,应用程序层,前端和AI代理)以响应用户的查询。
But there were still some pieces left in order to make Revisebot a complete, finished product.
但是,为了使Revisebot成为完整的成品,还有一些工作要做。
任务6:源代码管理 (Quest 6: Source Code Management)
Although I was the only developer working on this chatbot, I needed to store the code somewhere safe. Git was an obvious choice for source code and version control management, but GitHub does not offer a free, private repository. Revisebot was not supposed to be an open-source venture, so I could not host the source code there. Additionally, as I was not using a local development machine, I couldn’t use any local git repo to store my code on.
尽管我是唯一使用此聊天机器人的开发人员,但我需要将代码存储在安全的地方。 对于源代码和版本控制管理,Git是一个显而易见的选择,但是GitHub没有提供免费的私有存储库。 Revisebot不应被视为开源企业,因此我无法在此处托管源代码。 另外,由于我没有使用本地开发机器,因此无法使用任何本地git repo来存储我的代码。
Back in the day, I played around with bitbucket.org. I had some idea that they offered a free private repository, but wasn’t sure if they still offered any such plans. I went to their site and found that they did. The rest is pretty self-explanatory.
回想过去,我在bitbucket.org上玩耍。 我有一个想法,他们提供了一个免费的私人存储库,但是不确定他们是否仍然提供任何这样的计划。 我去他们的网站,发现他们做到了。 其余的很不言自明。
任务7:图形资产 (Quest 7: Graphic Assets)
Design and graphics sit at the core of any digital product. I needed a logo, background images, and cover images for my chatbot’s Facebook page, Slack app store listing, and homepage.
设计和图形是任何数字产品的核心。 我需要聊天机器人的Facebook页面,Slack应用商店列表和主页的徽标,背景图像和封面图像。
I am not a designer by any means, so I needed some help. I had to choose the color palette and icons, mix shapes together to create a logo, and more.
我无论如何都不是设计师,所以我需要一些帮助。 我必须选择调色板和图标,将形状混合在一起以创建徽标,等等。
Luckily, there is a helpful tool for this called Canva.
幸运的是,有一个有用的工具叫做Canva 。
It offers ready-made design templates for social media, YouTube, and logos which you can customize according to your needs. I created Revisebot’s logo, entirely in Canva, using free shapes and some creativity. I think I did fine.
它为社交媒体,YouTube和徽标提供了现成的设计模板,您可以根据需要自定义这些模板。 我使用自由形状和一些创造力,完全在Canva上创建了Revisebot的徽标。 我想我做的很好。
I also used some of their free templates to create other visual assets for Revisebot like a Facebook cover image.
我还使用了一些免费模板来为Revisebot创建其他视觉资产,例如Facebook封面图像。
So that’s how I coded and deployed a fully working chatbot, which can help you schedule your revision, entirely in the cloud.
因此,这就是我编写并部署了一个完全正常工作的聊天机器人的方式,它可以帮助您完全在云中计划修订时间。
It costs me exactly $0 to run this service.
运行该服务,我要花0美元。
Let me know if you have any questions regarding my project.
如果您对我的项目有任何疑问,请告诉我。
*No local machines were engaged in the making of this chatbot.
*没有本地机器参与此聊天机器人的制作。
If you liked this post, kindly give me some claps and follow me for more posts like this one. You should also subscribe to my YouTube channel, if you like developing digital things.
如果您喜欢这篇文章,请给我一些鼓掌,并关注我以获取更多类似文章。 如果您喜欢开发数字事物,还应该订阅我的YouTube频道。
推特 | YouTube | 雷恩工作室 (Twitter|YouTube|Rayn Studios)
Till next time…
直到下一次…
owin 怎么部署在云中