vue.js 构建项目

Over the last few years, chatbots have exploded in popularity. It makes sense that businesses and customers alike would want the easiest way to perform tasks without human intervention. But, building your own chatbot can be a daunting task without a third party service.

在过去的几年中,聊天机器人Swift普及。 企业和客户都希望有最简单的方法来执行任务而无需人工干预,这是有道理的。 但是,没有第三方服务,构建自己的聊天机器人可能是一项艰巨的任务。

This is where AWS Amplify’s interactions API shines. It leverages the same deep learning power that Amazon Alexa uses. With it, you can build out chatbots quickly and efficiently. So, let's jump right into setting one up.

这是AWS Amplify的交互API的亮点。 它利用了与Amazon Alexa相同的深度学习能力。 有了它,您可以快速有效地构建聊天机器人。 因此,让我们直接进行设置。

影片教学 (Video Tutorial)

Video Tutorial
影片教学

AWS Amplify CLI设置 (AWS Amplify CLI Setup)

If you don’t already have an account, head over to AWS, and create one. Then open your terminal and run this command:

如果您还没有账户,请转到AWS ,然后创建一个。 然后打开您的终端并运行以下命令:

npm i -g @aws-amplify/cli

Vue应用程式建立 (Vue App Creation)

To create the Vue app, open your terminal, cd into the directory of your choosing and run this command:

要创建Vue应用程序,请打开您的终端,将cd插入您选择的目录并运行以下命令:

npx vue create aws-amplify-chatbot

Then just choose the default settings for the app:1. Please pick a preset: default (babel, eslint)

然后只需为应用选择默认设置:1.。 请选择一个预设: 默认(babel,eslint)

放大设置 (Amplify Setup)

扩大帐户 (Amplify Account)

Now open the newly created Vue Project in the code editor of your choice (I’m using VS Code). Then, open a new terminal in the root of your project (In VS code, Terminal -> New Terminal). If you’ve never used Amplify, run the following command:

现在,在您选择的代码编辑器中打开新创建的Vue项目(我正在使用VS Code)。 然后,在项目的根目录中打开一个新的终端(在VS代码中,终端->新建终端)。 如果您从未使用过Amplify,请运行以下命令:

amplify configure

This will walk you through the steps of setting up a new IAM account in AWS. This account will programmatically generate everything we tell Amplify via the CLI.

这将引导您完成在AWS中设置新IAM帐户的步骤。 该帐户将以编程方式生成我们通过CLI告知Amplify的所有内容。

初始化Vue项目中的Amplify (Initializing Amplify In Vue Project)

Then, we’ll need to initialize Amplify in our project. To do so, run the following command in the terminal:

然后,我们需要在项目中初始化Amplify。 为此,请在终端中运行以下命令:

amplify init

Choose the following:

选择以下内容:

  1. Enter a name for the project:

    输入项目名称:

    Enter a name for the project:hit enter to choose the default

    输入项目名称:按Enter键选择默认名称

  2. Enter a name for the environment:dev

    输入环境名称: dev

  3. Choose your default editor:

    选择默认编辑器:

    Choose your default editor:Visual Studio Code

    选择默认编辑器: Visual Studio Code

  4. Choose the type of app that you’re building:

    选择您要构建的应用程序类型:

    Choose the type of app that you’re building:javascript

    选择您要构建的应用程序类型: javascript

  5. What javascript framework are you using:

    您正在使用什么javascript框架:

    What javascript framework are you using:vue

    您使用的是什么JavaScript框架: vue

  6. Source Directory Path:

    源目录路径:

    Source Directory Path:hit enter to choose the default (src)

    源目录路径:按Enter键选择默认值 (src)

  7. Distribution Directory Path:

    分发目录路径:

    Distribution Directory Path:hit enter to choose the default (dist)

    分发目录路径:按Enter键选择默认值 (dist)

  8. Build Command:

    生成命令:

    Build Command:hit enter to choose the default (npm.cmd run-script build)

    生成命令:按Enter键选择默认值 (npm.cmd运行脚本生成)

  9. Start Command:

    启动命令:

    Start Command:hit enter to choose the default (npm.cmd run-script serve)

    启动命令:按Enter键选择默认值 (npm.cmd运行脚本服务)

  10. Do you want to use an AWS profile?:

    您是否要使用AWS配置文件?:

    Do you want to use an AWS profile?:Y

    您是否要使用AWS配置文件?:

  11. Choose the account you set up in the last step选择您在最后一步中设置的帐户

添加放大互动 (Adding Amplify Interactions)

In your terminal run the following command:

在您的终端中运行以下命令:

amplify add interactions

Choose the following:

选择以下内容:

  1. Provide a friendly resource name that will be used to label this category in the project:

    提供一个友好的资源名称,该名称将用于在项目中标记此类别:

    Provide a friendly resource name that will be used to label this category in the project:hit enter to choose the default

    提供一个友好的资源名称,该名称将用于在项目中标记此类别:按Enter选择默认

  2. Would you like to start with a sample chatbot, import a chatbot, or start from scratch?Start with a sample

    您要从示例聊天机器人开始,导入聊天机器人还是从头开始? 从样本开始

  3. Choose a sample chatbot:

    选择一个示例聊天机器人:

    Choose a sample chatbot:OrderFlowers

    选择一个示例聊天机器人: OrderFlowers

  4. Please indicate if your use of this bot is subject to the Children’s Online Privacy Protection Act (COPPA).

    请指出您使用此漫游器是否受儿童在线隐私保护法(COPPA)的约束。

    Please indicate if your use of this bot is subject to the Children’s Online Privacy Protection Act (COPPA).N

    请指出您使用此漫游器是否受儿童在线隐私保护法(COPPA)的约束。 ñ

将更改推送到云 (Push Changes to Cloud)

To have Amplify push your changes to the cloud, run the following command in your terminal:

要使Amplify将更改推送到云,请在终端中运行以下命令:

amplify push

在AWS中查看 (View In AWS)

To view the resources that have been created run the following command in your terminal:

要查看已创建的资源,请在终端中运行以下命令:

amplify console

Unfortunately, the amplify console does not show our bot, but it will get you to the correct was account and region. After the console has opened, click the services dropdown in the top menu and search for “Lex”. Then click on Amazon Lex.

不幸的是,放大控制台未显示我们的漫游器,但是它将使您正确地找到帐户和区域。 打开控制台后,单击顶部菜单中的服务下拉菜单,然后搜索“ Lex”。 然后单击Amazon Lex。

Amazon Lex
亚马逊Lex

Once there, you will see a list of your chatbots. Since we picked the sample of OrderFlowers, we’ll see a chatbot named OrderFlowers_dev or something similar. Click on it to go to the bot settings.

到达那里后,您将看到您的聊天机器人列表。 既然我们选择OrderFlowers的样品我们将看到一个名为OrderFlowers_dev或类似聊天机器人。 点击它进入机器人设置。

机器人设置演练 (Bot Settings Walkthrough)

Sample UtterancesThese are the first words a user will type to initialize the bot. They don't have to be exact as Lex will use natural language processing for phrases close to the ones specified.

样本示例这些是用户键入以初始化机器人的第一个单词。 它们不必很精确,因为Lex将对与指定短语接近的短语使用自然语言处理。

Sample Utterances
话语样本

Lambda InitializationHere you can specify if you want a lambda function to fire of initialization of the bot.

Lambda初始化在这里,您可以指定是否要启动机器人初始化Lambda函数。

Lambda Initialization
Lambda初始化

SlotsThink of these as the steps that the bot will walk the user through. Each slot has the following:

插槽将这些视为机器人将引导用户执行的步骤。 每个插槽具有以下内容:

  1. Priority — When the question will be asked.优先级-何时提出问题。
  2. Required — Whether or not it is required input.必填-是否为必填项。
  3. Name — Variable name of the input. This will be used when passing the data to complete function名称-输入的变量名称。 将数据传递给完整功能时使用
  4. Slot Type— These are meta fields for the input to determine valid input data. You can choose a predefined slot or create your own in the left menu. See the flower type slot for an example of a custom slot.插槽类型-这些是用于确定有效输入数据的输入元字段。 您可以选择预定义的插槽,也可以在左侧菜单中创建自己的插槽。 有关自定义广告位的示例,请参见花型广告位。
  5. Version — The version of the slot. Used for your custom slots.版本—插槽的版本。 用于您的自定义插槽。
  6. Prompt — How the bot will prompt the user to enter data. Entered in the form of a question.提示-机器人将如何提示用户输入数据。 以问题的形式输入。

Confirmation PromptThis is the prompt that will conclude the bot operations. Typically, it will reiterate what the user has chosen and as for confirmation.

确认提示这是结束机器人操作的提示。 通常,它将重申用户选择的内容并进行确认。

FulfillmentAfter the bot has finished, you can fire a lambda function. In this case, we would add the order to our database or send out an email with the order details to the florist.

实现机器人完成后,您可以启动lambda函数。 在这种情况下,我们会将订单添加到我们的数据库中,或者将包含订单详细信息的电子邮件发送给花店。

Fulfillment
履行

ResponseAfter fulfillment has been executed, we can send another response. I’ll add a message that says “Flower order successfully placed”

响应执行完成后,我们可以发送另一个响应。 我将添加一条消息,指出“已成功下达鲜花订单”

Response
响应

将放大添加到Vue (Adding Amplify to Vue)

Now that we have our Chatbot Provisioned in AWS, we can add the Amplify npm packages to our Vue project and initialize Amplify. Open a terminal in the root of your project and run the following command:

现在我们已经在AWS中配置了Chatbot,我们可以将Amplify npm软件包添加到我们的Vue项目中并初始化Amplify。 在项目的根目录中打开一个终端,然后运行以下命令:

npm i aws-amplify aws-amplify-vue

Next head over to src/main.js and add the following:

接下来转到src / main.js并添加以下内容:

// Import Amplify Modules, Plugins, and aws exports fileimport Amplify, * as AmplifyModules from "aws-amplify";import { AmplifyPlugin } from "aws-amplify-vue";import awsconfig from "./aws-exports";// Configure Amplify in projectAmplify.configure(awsconfig); // Configure vue to use plugins and modulesVue.use(AmplifyPlugin, AmplifyModules);

聊天机器人界面 (Chatbot UI)

Luckily for us, Amplify gives us a chatbot component we can add to our page. In src/App.vue, in the main app div, we’ll remove everything to add the chatbot component:

对我们来说幸运的是,Amplify给了我们一个聊天机器人组件,我们可以将其添加到页面中。 在src / App.vue的主应用div中,我们将删除所有内容以添加chatbot组件:

<amplify-chatbot v-bind:chatbotConfig="chatbotConfig"></amplify-chatbot>

In the script tag, we’ll add a data property with our chatbotConfig. You’ll need to add the bot name and I optionally added clearComplete and set it to false.

在脚本标签中,我们将使用chatbotConfig添加数据属性。 您需要添加机器人名称,我可以选择添加clearComplete并将其设置为false。

<script> export default {  name: "App",  data: () => ({   chatbotConfig: {    bot: "OrderFlowers_dev",    clearComplete: false,   },  }), };</script>

处理确认 (Processing The Confirmation)

There are two ways you can process the confirmation of the flower order in our demo. You can either use a lambda function or pass the data back to our client (Vue). We’ll be passing it back to our project.

您可以通过两种方式处理演示中的花序确认。 您可以使用lambda函数,也可以将数据传递回我们的客户端(Vue)。 我们将把它传递回我们的项目。

To do so, we’ll need to import the Interaction class from the AWS Amplify package. Then we’ll declare a method called handleComplete. In this method, we’ll log any errors and alert a completed bot. Lastly, we’ll need to register the function on load which we’ll do in the mounted lifecycle hook.

为此,我们需要从AWS Amplify包中导入Interaction类。 然后,我们将声明一个名为handleComplete的方法。 在这种方法中,我们将记录所有错误并提醒已完成的漫游器。 最后,我们需要在加载时注册功能,这将在已安装的生命周期挂钩中进行。

When finished your App.vue file will look like this:

完成后,您的App.vue文件将如下所示:

演示版 (Demo)

That’s it! Now we can check out a demo of the bot.

而已! 现在,我们可以查看该机器人的演示。

Chatbot Demo
聊天机器人演示

结论 (Conclusion)

As you can see it is extremely easy to get a powerful chatbot up and running using AWS Amplify. I’d love to know what you plan to build with one. Let us know in the comments below.

如您所见,使用AWS Amplify启动和运行功能强大的聊天机器人非常容易。 我很想知道您打算用什么构建。 在下面的评论中让我们知道。

Bitbucket Repo: https://bitbucket.org/TheDiligentDev/aws-chatbot/src/master/

Bitbucket回购: https : //bitbucket.org/TheDiligentDev/aws-chatbot/src/master/

翻译自: https://medium.com/javascript-in-plain-english/building-a-chatbot-with-vue-js-and-aws-amplify-6e190d2e8a2e

vue.js 构建项目


http://www.taodudu.cc/news/show-4365173.html

相关文章:

  • Chatbot(五)
  • 基于OpenAI的Chatbot开发记录
  • 环境监测系统/智能监测平台---Vue/Node.js
  • oracle 表变化监控,oracle 怎么 监控数据变化
  • 水质在线监测系统方案
  • 2021年煤矿安全监测监控模拟试题及煤矿安全监测监控理论考试
  • java 内存 监控_监控JVM内存使用情况
  • 2021年煤矿安全监测监控最新解析及煤矿安全监测监控考试试卷
  • 联想启天M420-D046(C)电脑Win10改Win7
  • Win10 无法加载操作系统,关键系统驱动程序丢失或错误 蓝屏错误代码0xc000007b
  • 电脑蓝屏个人解决办法————由程序引起的
  • vscode win10笔记本 蓝屏_联想拯救者Win10蓝屏0xc000000d的解决办法
  • 【日记】20220219启动项目蓝屏
  • 小新14pro锐龙版虚拟机启动蓝屏重启
  • 索尼(SONY)笔记本装系统蓝屏问题解决方案
  • 联想Thinkpad E420 重装系统
  • 联想v360安装linux双系统,联想V360在WIN7下安装XP双系统完美运行攻略.doc
  • 联想拯救者R7000P加硬盘
  • 联想服务器怎么使用uefi启动不了系统,联想小新如何用uefi启动在win10下装win7系统...
  • 计算机正在准备从D盘中回收,电脑一直显示正在启动怎么选择重灌系统
  • 电脑系统修复之--Windows系统开机蓝屏 EFI Network 0 for IPv4(XX-XX-XX-XX-XX)boot failed.
  • Win10 无法加载操作系统,因为无法验证文件或某个xx数字签名 蓝屏错误代码0xc0000428
  • 电脑win10蓝屏,INACCESSIBLE BOOT DEVICE,处理方法
  • 联想Think Server TS540/440蓝屏故障处理
  • windbg抓一个windows蓝屏分析
  • Win10 开机突然蓝屏错误代码0xc0000001安全模式也进不了,不用重装系统怎么修复?(已解决)八个解决参考方案
  • Windows电脑开机蓝屏(2)
  • 解决联想笔记本E40 安装VM虚拟机后每次启动都会导致电脑蓝屏问题
  • 计算机蓝屏安全模式都启动不了,stop:0x00000074蓝屏无法进入安全模式无法开机 解决办法...
  • 联想小新Pro 16频繁蓝屏解决方案

vue.js 构建项目_使用Vue.js和AWS Amplify构建Chatbot相关推荐

  1. Vue整合SpringBoot项目实战之Vue+Element-Ui搭建前端项目

    Vue整合SpringBoot项目实战之Vue+Element-Ui搭建前端项目 源码(欢迎star): 前端项目代码 后端项目代码 系列文章: Vue整合SpringBoot项目实战之后端业务处理 ...

  2. vue 公用页面引用_关于vue全局引用公共的js和公共的组件的折腾

    前沿 最近在项目开发中遇到一些需要全局引用的公共js,或者公共组件,早就烦死了那种每个页面都写一遍,都引用一个js的写法,正好vue解决了这个额问题,于是乎就开始折腾,折腾的过程中也发现了一些自己之前 ...

  3. 删除vue打包大小限制_压缩Vue.js打包后的体积方法总结(Vue.js打包后体积过大问题)...

    问题 由于这次项目是在初学 Vue 之后的第一个正式项目,没有考虑到类似 路由懒加载. 按需加载的问题 ,所以呢,也算是没经验. 到了这些天,项目写得差不多了,准备放到服务器测试,才发现这个问题. 优 ...

  4. vue 引入json地图_使用vue+echarts快速进行全国地图与各省市地图联动(下钻地图), 引入省份js文件...

    项目源码附js/json地图数据(下载项目源码后请使用Npm install 来安装相关依赖) 效果 使用前请使用npm(cnpm)安装echarts,详情见官网. 本文作为笔记demo只引入5个省( ...

  5. vue 打开html流_解决Vue项目打包后打开index.html页面显示空白以及图片路径错误的问题...

    Vue项目运行npm run build后会生成一个dist文件夹,我们一般都是把这个文件夹部署到服务器上.dist文件夹里边有一个static文件和一个index.html页面,这个index就是最 ...

  6. vue脚手架搭建项目_复习之vue脚手架搭建项目的两种方法

    安装脚手架 node 版本要求: > 8.9 . 关于旧版本:如果在这之前已经全局安装了旧版本的vue-cli(1.x 或 2.x),那么需要先卸载掉. 卸载旧版本运行:``npm uninst ...

  7. 基于vue前端聊天插件_基于Vue聊天的实现

    基于vue前端聊天插件 基本视频聊天 (basic-vue-chat) Easy to use VueJS chat. 易于使用的VueJS聊天. 安装 (Installation) You can ...

  8. node.js编写网页_为Node.js编写可扩展架构

    node.js编写网页 by Zafar Saleem 通过Zafar Saleem 为Node.js编写可扩展架构 (Writing Scalable Architecture For Nodejs ...

  9. vue单选框选中_使用vue如何默认选中单选框

    使用了vue以后,发现这真的是一个灵活高效的框架,能够轻松实现页面的实时刷新. 那么,今天先聊聊单选框的使用.一般我们使用单选框,会这么写: //HTML one two three 有"c ...

最新文章

  1. ibatis查询SQL语句返回一个对象,此对象包含一个List属性
  2. Unknown column 'subject_1.pid' in 'field list') [SQL: 'SELECT anon_1.screen_id AS anon_1_screen_i
  3. ASP.NET MVC的JavaScriptResult
  4. 正月十五元宵节中国风海报PSD分层模板找灵感!
  5. django模板的使用方法
  6. Unity3D 热更新方案(集合各位专家的汇总)
  7. C# 从服务器下载文件
  8. memcached整理の基本使用
  9. js+html空间数据编码问题--以姓名为例(代码设涉及文件读取,文本数字提取,特别是文本x,y坐标的提取)
  10. 正则表达式应用(日期正则表达式)
  11. SE3可能是苹果最失败的手机,销量不达预期致上市半月降价促销
  12. python导入模块不存在_基于pycharm导入模块显示不存在的解决方法
  13. 啥是甘特图?用思维导图制作甘特图的方法
  14. 假如生活欺骗了你 (普希金诗歌)
  15. 电脑软件没运行,内存爆满可以这样解决
  16. SQLServer学习笔记 --- (20008, 'DB-Lib error message 20008, severity 9:\nUnable to open socket\nNet-Li
  17. iS-RPA 从起步到飙速(二)—— 通往新世界
  18. ARM立即寻址中有效立即数的计算
  19. 简述UIView的属性和用法
  20. C语言仿真ADC的完整代码,无信道部分,仅发送端接收端

热门文章

  1. 微信扫描下载提示以及js判断用户手机系统
  2. 编译错误/usr/bin/ld: cannot find -lz
  3. Qt官方示例-正则测试工具
  4. 3D游戏设计-智能巡逻兵
  5. 如何删除PDF水印?PDF删除水印怎么操作
  6. OpenGL--多边形偏移
  7. (二)linux下ping不通的解决方法
  8. 视频怎么剪辑成短视频?如何制作原创视频素材作品
  9. ambari_HDP之mapreduce参数调优
  10. uniapp修改字体