怎么安装ubuntu物理机装ubuntu

How to Build a Facebook Messenger Chatbot in 10 Minutes - 推酷
How to Build a Facebook Messenger Chatbot in 10 Minutes
The new Facebook Messenger platform,
, lets developers write bots, or&automated chat programs, that&drive user engagement&and provide value in an intelligent and interactive way.
In this series of articles, we’re going to take a look at what it takes to build out a Facebook Messenger chat bot, withBackand serving as the back-end. This article will cover creating the Facebook app, tying it to a Backand, then testing the pairing. Future articles will cover what is happening on the back-end in greater depth, as well as&integrating with third-party providers to create even more&interesting content for your users.
Tools for Building the Chatbot
One of the great things about choosing a Backend-as-a-Service provider likeBackand is that the tool chain necessary to create interactive and exciting programs is very short. Between Facebook’s informative app interface, and Backand’s in-browser JavaScript editor, most of your tools are already provided. In, fact, the entire exercise will be conducted in a web browser! While you can always use text editors or IDEs for formatting and organizing the JavaScript portions of this effort, these tools are more of a convenience than a necessity.
This also allows you to iterate more quickly once the app has been wired up. As your server-side action code changes, those changes will be immediately reflected in your Messenger chat bot. With Backand, you don’t have any need to deploy changes to your code – simply make the appropriate changes, save the action, and you are ready to go.
Configuring the App on Facebook
Every Facebook app begins the same way – at the
. If you haven’t registered with Facebook as a developer, you will first be prompted to do so. Once you’ve registered, you’re brought to the app creation page flow. Start by entering the name of your new Facebook Messenger bot:
You’ll be prompted for more info before the ID is finalized – fill out the specified fields, and click “Create App ID”:
At this point you can go through the provided quick-start wizard if you want, but for our purposes we will skip this to end up at the App Dashboard. From here you can manage all aspects of your app, and see relevant stats such as the number of users, API calls, and other statistics. To create an app that our backend can communicate with, we need to add a product using the provided “Add Product” link in the navigation bar. This takes up to the Product Setup page. Choose the “Get Started” button for a Messenger app:
Now&we’re almost ready to create our application’s backend. But first, there is one more step to take on Facebook. Facebook requires that all Messenger applications be associated with a Facebook Page. The page doesn’t need to be complex, it just needs to be associated with your Facebook account – simply create a blank page, and you can flesh it out later if you desire.
Adding Backend Functionality
Facebook messenger bots communicate using Webhooks. Webhooks are a notification of an action taken in your app – in this case, you receive a webhook notification whenever someone sends a message to your bot via Facebook Messenger. The response of your webhook will be converted into a Facebook Messenger message sent back to the user.
To integrate with Facebook’s webhooks, you need to have a backend application that is publicly-accessible. Using a traditional approach (without Backand), this would have required five steps: securing a domain, standing up a web server, standing up a database, writing an application to receive the messages, then writing the code to handle the messages and send a response. But we’re going to leverage Backand as our app’s backend, which eliminates&four of the above five steps. So the only thing we need to do&is the most important one: write the code to handle the webhooks!
. Accounts are free to start, and the Prototype tier gives you more than enough data storage and transfer to get your app up and running. Once you register, you are brought to the Backand dashboard. Use the provided box to create a new Backand app:
Once this is done, you’re brought to your app’s dashboard:
By default, you are given a basic set of objects to work with: items and users. All items in a Backand application are RESTful resources, and are publicly accessible for authenticated apps from the moment your Backand application is created. We’re going to use a Custom Action on the “Items” object to control our bot’s integration with Facebook Messenger. To get this set up, first navigate to the Items object by selecting it from the navigation bar:
Once there, select the “Actions” tab:
The Actions tab offers us the capability to create automated actions based on each potential database operation that could be performed on this object, driven by the Amazon RDS instance that was automatically provisioned for you when you created your app. Additionally, you can create Custom Actions on an object. These actions respond to messages sent to a specific URL, and are ideal for driving our Facebook Messenger bot integration.
Custom actions can consist of sending an email, executing a Transactional SQL script, or running custom server-side JavaScript code. We’re going to use the latter, but via a handy template provided in the Backand interface. To get started with our bot’s custom action, select the “Facebook Messenger Bot” template from the provided examples:
This step automatically configures the action to be performed on demand, and provides you with sample JavaScript code to integrate with the Facebook messages you will shortly receive. Save the action for now, without any modifications. At this point the backend is ready – all that is left is to tie the Facebook app we created to the Backand app we will be using to power it!
Tying it Together
Navigate back to the Facebook app page. The first thing we need to do is generate a key that the app can use to authenticate with outside communicators. This is done in the “Token Generation” section – simply select the page you created while configuring the Facebook app, and the token will be automatically generated:
Once you have the token, you need to paste it into your application’s JavaScript code. There is a variable named PAGE_ACCESS_TOKEN defined in the template code – simply change this variable’s value to the key you copied from Facebook:
After this is finished, you need to configure Facebook to send the correct webhooks to your application. This is managed in the “Webhooks” section. Click the button marked “Setup Webhooks” to get started:
This brings up the New Page Subscription dialog. In this dialog, you need to provide the URL for your Backand application’s custom action, a Verify Token, and select the webhooks you wish to receive. First, let’s retrieve the action URL. Navigate back to your app’s Backand dashboard, and pull up the action. To find the URL, we simply need to send a test object to our action. Click the “Test Action” button:
This brings up the testing sidebar. Within this sidebar, select “Test On Demand Action”:
The test results are revealed below, along with the URL used to make the request:
As you can see, this URL is of the form /1/objects/action/&OBJECT_NAME&/?name=&ACTION_NAME&. You can use this format as a reference for future Backand actions. To ensure the action is&properly authenticated, we also need to configure the URL to use your application’s master token. To find this, navigate to the “Security & Auth” section in the Backand dashboard, and load the “Social & Keys” section:
You will also need a user token – this is generated in the “Team” section of the “Security & Auth” configurations. Simply click the key icon next to any admin user to get a user token dialog:
Copy the key provided – we’ll use it to construct the final action URL. Action URLs are of the following format:
/1/objects/action/items?name=&authorization=basic+:
Replace &ACTION_NAME& with the name of your action, &MASTER_TOKEN& with the master token, and &USER_KEY& with the user key. Paste the final URL into the New Page Subscription dialog on the Facebook configuration page, then select “message_deliveries,” “messages,” “messaging_optins,” and “messaging_postbacks” from the Subscription Fields. Next, set the value of field “Verify Token” to “my_test_token”. Finally, click “Verify and Save”. When you are done, the dialog will look as follows (all identification information has been removed from the URL for security reasons):
Once saved, you need to select the page to subscribe to your webhooks – set this to your Facebook page, and your app should be successfully configured! Navigate to the page you created, and start a messenger chat:
And with that, our Facebook chat bot is completed! Facebook took the message “Test” that we sent to the page, and forwarded it to our back-end application. The back-end application parsed the message, appended its own data (“Back& bot says:”), and returned data to the user. With this base, the entire power of a web application is available to you.
Conclusion
The above tutorial walked you through creating a Facebook Messenger bot from the very beginning. We built a simple web application withBackand as the backend, hooked it up to a Facebook page, authorized it, and then tested it – all without having to write or deploy significant code! In our next article, we’ll look at expanding the bot’s functionality, as well as what exactly is going on with our custom action – stay tuned!
Additional resources:
已发表评论数()
请填写推刊名
描述不能大于100个字符!
权限设置: 公开
仅自己可见
正文不准确
标题不准确
排版有问题
主题不准确
没有分页内容
图片无法显示
视频无法显示
与原文不一致  又到了谈论Facebook的时候,看上去这家社交巨头的一切都很美好:
  第二季度营收为64.36亿美元,同比增长59%;
  净利润为20.55亿美元,同比增长186%;
  广告收入继续突飞猛进,大涨63%,达到了62.39亿美元,均超过分析师的预期;
  为地球上40亿没有网络的人们送去无线网的无人机成功试飞;
  以Oculus为代表的VR平台让Facebook在虚拟现实的世界中也有了先发优势。
  但是,一个更加迫切和现实的问题是:Facebook手握的两大用户数均分别超过10亿的即时通讯应用Facebook 和
Whatsapp应该如何变现,以及如何规划它们的未来。
  自2012年上市以来,Facebook在业绩上所取得的巨大成功,让投资者给予了其更多的宽容和耐心,但随着Facebook平台上的用户量已经到达了十数亿量级,继续强调其用户量的增长,或许并不是一种明智的态度。Facebook或许应该从上述两款明星级应用做文章。
  目前,Facebook公司的营收主要来自于其拥有16亿活跃用户的Facebook社交网络平台。从PC时代到移动时代,Facebook的广告业务成功实现了转型,是移动互联网转型红利的一大受益者。同时,Facebook或许是在这一轮互联网过渡时期,在广告业务方面积累成功经验最多的一家大型互联网公司。
  但Facebook营业收入结构单一实际上也是潜在的财务风险,因为一旦目前成功的广告商业模式陷入停滞,其业绩也将随之陷入停滞。
  另外,来自投资者方的压力也是巨大的,过去投资者能够给Facebook足够的时间和空间去培育Messenger和Whatsapp的用户量,是因为相信扎克伯格的策略是对的,那就是先积累用户,到了一定阶段再考虑变现的事,并且广告业务还在继续快速增长,也为Messenger和Whatsapp最终要担负的变现任务赢得了喘息。
  但最终,Messenger和Whatsapp的变现还是会进行,这来源于Facebook自身业绩多元化的要求以及投资者方面带来的压力。
  尽管Facebook方面从来没有就Messenger和Whatsapp如何变现做过系统性的详细公开阐述,但从过往的公开信息中,仍然能够寻找到Facebook关于即时通讯产品如何变现的战略考量的一些蛛丝马迹。
  Facebook对于Messenger和Whatsapp变现的考量实际上是随着自身业务以及行业的发展变化不断演进的。
  首先,扎克伯格最早关于Messenger
和Whatsapp如何变现的表态发生在2015年第二季度财报公布后的投资者电话会上,当时扎克伯格在回答分析师提出的相关问题时称,这两款产品的变现手段将会“与最初Facebook和News
Feed变现的方法类似。”
  扎克伯格所提到的最初的Facebook广告变现手段,绝对是一段Facebook引以为傲的历史。早在2006年,Facebook的一些早期投资人和分析师在看到Facebook不断快速积累的用户群体后,纷纷敦促它进行广告变现,方式就是在页面中简单粗暴地插入横幅展示广告,这是最立竿见影的互联网广告变现方式。
  然而,扎克伯格却决定不这么干,当时年仅22岁的扎克伯格想的比其他人更长远。他认为,直接在页面上插入广告的方式,容易令用户感到反感,虽然短期广告收入效果显著,但长期来看,会影响用户体验,反而损害平台对用户的吸引力。于是扎克伯格和其团队决定采用一种他们称为“用户与商家内生互动的方式”。
  所谓“内生互动”,即Facebook鼓励商家也在Facebook平台上建立自己的专属页面,成为自己品牌和产品展示的窗口,商家通过用户的点赞和评论获得反馈,取得广告效果。
  随着这种更为自然和具备社交属性的模式获得初步的成功,Facebook开始向商家收取在页面上推广产品信息的费用,并进一步沿用至移动端并同样取得成功。由于这种形式的广告效果比传统的展示广告好得多,Facebook对
这种形式的广告实际上收取的费用也要更高。
  从这一模式中尝到了甜头的Facebook,打算将这样的思路延续到Messenger和Whatsapp这样的即时通讯产品的变现中,换言之,就是在初期也鼓励商家在Messenger或Whatsapp上设立专门的账号,通过推荐功能让用户初期与其形成连接和互动,随后再从商家处收取效果广告费。
  另一种则是随着近年行业趋势的变化,尤其是人工智能技术的快速发展和广泛应用,以及Facebook自身对即时通讯产品理解的不断加深而在其内部变得愈加清晰和明确的变现方式,这种方式是通过Chatbot(聊天机器人)。
  Chatbot这一概念最早由Facebook在今年的F8开发者大会上公开提出,同时Facebook还在期间向开发者开放了基于Messenger的开发平台。所谓Chatbot,即存在于Messenger平台上的利用人工智能等技术,能够满足用户各种不同使用和应用场景需求的自动聊天工具。例如凯悦酒店开发的Messenger上的Chatbot,能够让用户实现订酒店房间,荷兰航空公司开发的Chatbot能够实现飞机票订购服务等。
  Chatbot的提出,尤其是开放平台的发布,让Messenger上的应用具备了更多的想象空间,将更多的第三方开发者纳入进来,Facebook
Messenger的平台属性更为明确,而不仅仅局限于过去的即时通讯工具,发布Messenger开发者平台时,Messenger上的用户数是9亿,很快接近10亿,这个用户数的时点也被外界看作是为下一轮变现做铺垫。
  一旦Facebook所期望的用户在Messenger平台上与Chatbot互动的场景活跃起来,变现也就成了顺理成章的事。无论是在此过程中发生支付行为,还是广告展示,Facebook都能轻而易举地将其变成真实收入。
  但就目前而言,Facebook如果想将Messenger和Whatsapp变现,还存在一些需要克服的障碍。
  首先是用户习惯和体验的问题,这一直是扎克伯格从创立Facebook之初一直最在意的方面,尽管这两款产品各自有超过10亿的用户,但其中有多少是愿意或习惯于在被大多数人当成聊天工具的平台上进行与商家的互动,另外在Messenger上与商家的互动和发生交易活动,就一定比使用独立的应用实现同样的功能对于用户来说更加有效率吗?在F8上Facebook展示的用Messenger叫Uber车的流程逻辑就让人有些费解,用户需要通过对话的形式,设置接客地点,显得较为繁琐,反而不如直接使用Uber
App来的方便。
  另外Chatbot的实际应用,也对蕴含其中的人工智能特别是自然语言识别技术提出了更高的要求,如何让Chatbot“读懂”用户输入的文本的意思,并且反馈给用户最适合有效的信息,其实是一个不小的技术上的挑战,或许Chatbot这一概念对于热衷技术的工程师更有吸引力,而非真正的终端用户。
  还有一个问题是,同样拥有10亿以上用户的Whatsapp,或许依然不会那么快变现,从2014年以近200亿美元被Facebook收购时,扎克伯格便对外承诺称,Whatsapp将依然保持独立运营,并不会对其业务进行干涉,如今快2年过去了,Whatsapp确实没有发生太多变化,Facebook的Messenger和Whatsapp双产品策略,目前看来是以从Messenger端进行更多业务拓展,而Whatsapp保持简单易用和用户增长这样的逻辑来进行。

我要回帖

更多关于 物理机装ubuntu 的文章

 

随机推荐