sap把系统内部直接写入到自建表_如何提供语音启用 AI 聊天机器人 SAP ME 系统

Artificial intelligence-based voice enabled chat bot for MES system would be great asset for any manufacturing company. Through voice/chat commands shop floor operators can interact with the system while doing their operational activity and Supervisor or business personal can easily look into any report.

基于人工智能的 MES 系统语音聊天机器人将成为任何制造企业的宝贵财富。通过语音/聊天命令,车间操作人员可以在进行操作活动时与系统进行交互,主管或业务人员可以轻松查看任何报告。

Today in this blog I will show how to develop a voice based chat bot application for your SAP ME system step by step.

今天在这个博客中,我将展示如何为您的 SAP ME 系统逐步开发一个基于语音的聊天机器人应用程序。

Prerequisites:You need to have access to below mentioned systems .

先决条件: 您需要访问以下提到的系统。

  1. SAP MII and SAP ME 和 SAP ME
  2. SAP Cloud Platform 云平台
  3. SAP Conversational AI 会话式人工智能
  4. SAP Cloud Connector 云连接器

Step 1: Configure cloud connector for SAP MII system:

步骤1: 为 SAP MII 系统配置云连接器:

The cloud connector serves as the connection between applications in SAP Cloud Platform and existing on-premise systems. To configure cloud connector with SAP MII system you can refer this blog .

云连接器充当 SAP 云平台中的应用程序与现有的本地系统之间的连接。要使用 SAP MII 系统配置云连接器,您可以参考本博客。

https://blogs.sap.com/2016/08/01/cloud-connector-configurations-for-sap-mii/

Step 2: Create Transactions in SAP MII:

第二步: 在 SAP MII 中创建事务:

Write transactions(BLS) in SAP MII which will interact with SAP ME system. For example if you want to execute SFC(Shop floor control) write transactions to start an SFC, Do data collection for that SFC , Complete and SFC.

在与 SAP ME 系统交互的 SAP MII 中编写事务(BLS)。例如,如果您想执行 SFC (车间控制)写入交易启动 SFC,请为该 SFC、 Complete 和 SFC 进行数据收集。

Step 3: Develop Rest APIs in SAP Cloud Platform:

第三步: 在 SAP 云平台中开发 Rest api:

Once you performed Step 1, your MII system is connected with SAP Cloud Platform using Cloud Connector, Now you can develop Rest APIs in SAP Cloud Platform which will call your MII transactions .

一旦你执行了第一步,你的 MII 系统就可以使用云连接器连接到 SAP 云平台,现在你可以在 SAP 云平台中开发 Rest api 来调用你的 MII 事务。

You can’t directly call your SAP MII transactions from SAP CAI as most of the time MII/ME system is not exposed to public network and other reason is SAP CAI supports https type of service only ,for this reason you can develop services in SAP Cloud Platform which will create a secure public Rest API for your SAP MII transactions.

你不能直接从 SAP CAI 调用你的 SAP MII 事务,因为大多数时候 MII/me 系统并不公开到公共网络,其他原因是 SAP CAI 只支持 https 类型的服务,因此你可以在 SAP 云平台上开发服务,这将为你的 SAP MII 事务创建一个安全的公共 Rest API。

I have used Node.js as a programing language for developing APIs. Steps to develop Rest APIs in SAP Cloud Platform for SAP MII/ME Transactions.

我使用 Node.js 作为开发 api 的编程语言。在 SAP 云平台中为 SAP MII/ME 事务开发 Rest api 的步骤。

Step 3.1 : Create a destination in SAP Cloud Platform and configure it with proper URL that you have used while configuring Cloud Connector as part of Step 1.

步骤3.1: 在 SAP 云平台中创建一个目标,并使用您在配置云连接器时使用的适当 URL 对其进行配置,这是步骤1的一部分。

768cf068a2bbc5edc50eedb3c8dd9d7d.png

Step 3.2: You can now use ‘sap-cf-axios’ Node JS module to develop your API in SAP Cloud Platform which will call your MII transaction though SAP Cloud Platform Destination service.

步骤3.2: 您现在可以使用“ SAP-cf-axios” Node JS 模块在 SAP 云平台中开发您的 API,该 API 将通过 SAP 云平台目的地服务调用您的 MII 事务。

Sample source code :

源代码示例

var SapCfAxios = require('sap-cf-axios').default;var axios = SapCfAxios('put your SCP Desinatination name');
var config = {    method: 'GET',    url: '/XMII/Illuminator?QueryTemplate=' + query,    headers: {        "content-type": "application/json"    },}try {    let resp = await axios(config);    return res.type("application/json").status(200).send(resp.data);} catch (error) {    console.error('MII Destination Calling error===>>>' + error);    return res.type("text/plain").status(500).send(JSON.stringify(error));}

Step 3.3: You can create also create XSUAA service instance for your application and bind it to provision oAuth authentication to your developed APIs.

步骤3.3: 您还可以为应用程序创建 XSUAA 服务实例,并将其绑定到提供 oAuth 身份验证到您开发的 api。

Once you application is deployed, open your application instance in SAP Cloud Platform Cockpit and go to Environment variable section and look for “xsuaa” node, there you will find clientid, clientsecret and url . Please take a note of that.

一旦你的应用被部署,打开你的应用程序实例在 SAP 云平台驾驶舱,并进入环境变量节并寻找“ xsuaa”节点,在那里你会找到 clientid,clientsecret 和 url。请记下来。

You can create and bind all mentioned service instance either though SAP Cloud Platform Cockpit or though mta.yml file

您可以通过 SAP Cloud Platform Cockpit 或者 mta.yml 文件创建和绑定所有提到的服务实例

Step 4 : Develop and build SAP Conversational AI Conversational flow:

第四步: 开发和建立 SAP 人工智能对话流:

Now you are done with all service creation, only part pending is building conversational flow using SAP Conversational AI.

现在您已经完成了所有服务的创建,只有部分挂起是使用 SAP 对话式 AI 构建会话流。

Step 4.1: First you need to define Intents and Entities and train your Bot with those data, It will help the bot to understand the phrases or sentences from your command. For example if you want to start one SFC , you can create Intent @StartSFC and train it with phrases like “I want to start SFC 1234 at Operation ABC and Site XYZ”,”Please start SFC 1234 at Operation ABC and Site XYZ” etc and identify SFC number as #NUMBER(Golden Entity in CAI) Entity, Operation number as #OPERATION Entity and Site as #SITE Entity.

步骤4.1: 首先你需要定义意图和实体,并用这些数据训练你的机器人,它将帮助机器人理解你命令中的短语或句子。举例来说,如果你想创建一个 SFC,你可以创建 Intent@StartSFC,并用“ i want to start SFC 1234 at Operation ABC and Site XYZ”、“ Please start SFC 1234 at Operation ABC and Site XYZ”等短语训练它,并将 SFC 编号识别为 # number (Golden Entity in CAI) Entity,Operation number 为 # Operation Entity,Site 为 # Site Entity。

Step 4.2: You need to create a skill in SAP CAI for performing a action. In this section I will discuss about one particular skill but same way you can define other skills based on your need .I will show STARTSFC skill which will perform SAP ME start SFC transaction.

步骤4.2: 您需要在 SAP CAI 中创建执行动作的技能。在这一部分,我将讨论一种特殊的技能,但同样的方式,你可以根据自己的需要定义其他技能。我将显示 STARTSFC 技能,将执行 SAP 我启动证监会交易。

Create a Skill called STARTSFC and specify @StartSFC Intent (created in previous step) as triggering Intent of this skill and in the Requirement section check if SFC, Site, Operation number is present in the Phrase user provided, if not ask user for that and save the SFC, Site, Operation number in memory variable called SFC, Site, Operation.

创建一个称为 STARTSFC 的技能,并指定@STARTSFC 意图(在前一步中创建)作为触发此技能的意图,并在需求部分检查 SFC,Site,Operation number 是否存在于短语用户提供的短语中,如果没有要求用户提供该短语并保存 SFC,Site,Operation number 在内存变量中称为 SFC,Site,Operation。

Step 4.3: Once you are having all required parameter for your transaction to execute (for this case Start SFC is the transaction), you can go to Action tab of your skill and specify the API URL you have created in Step 3 and pass all necessary parameter in URL( For GET request) or in body(For POST Request) . Choose OAuth2 Authentication as authentication type and provide Client ID, Client Secret , Authorization URL which you got from step 3.3.

步骤4.3: 一旦你有了执行交易所需的所有参数(在这种情况下,Start SFC 是交易) ,你可以进入你技能的 Action 选项卡,指定你在步骤3中创建的 API URL,并在 URL (For GET Request)或主体(For POST Request)中传递所有必要的参数。选择 OAuth2身份验证作为身份验证类型,并提供从步骤3.3获得的客户端 ID、客户端秘密、授权 URL。

Now your bot is ready with Start SFC skill , train the bot also you can execute it from CAI tool .

现在你的机器人已经准备好了开始 SFC 技能,训练机器人也可以通过 CAI 工具来执行。

3d8eb17ee8ed70affaf6543ed46937ff.png

Step 5 : Develop a interface for your chat bot and enable voice :

第五步: 为聊天机器人开发一个界面并启用语音:

Now its time to give a interactive user interface to your chat bot application which I have developed using SAPUI5 . I have created one SAPUI5 Fragment with a button at bottom right to the corner of dialog, on click of which I am listening to user’s voice command. You can refer below pasted code for speech to text conversion and once you get the text out of speech need to call SAP CAI dialogue flow API (https://api.cai.tools.sap/build/v1/dialog) and pass your message.

现在是时候给你的聊天机器人程序提供一个交互式用户界面了,我已经用 SAPUI5开发了这个程序。我已经创建了一个 SAPUI5片段与一个按钮在底部右边的对话框,点击其中我正在听用户的语音命令。你可以参考下面粘贴的语音到文本的转换代码,一旦你得到的文本出语音需要调用 SAP CAI 对话流 API ( https://API.CAI.tools.SAP/build/v1/dialog ) ,并通过您的消息。

var recognition;try {//var SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition; recognition = new window.webkitSpeechRecognition();}catch(e) {  $('.no-browser-support').show();  $('.app').hide();}recognition.continuous = false;recognition.lang = 'en-US';recognition.interimResults = false;recognition.maxAlternatives = 1;recognition.start();recognition.onresult = function (event) {var vInWrittenVal=event.results[0][0].transcript;//here capturing the text from voice commands //Need to pass the text to  SAP CAI Dialog flow by calling https://api.cai.tools.sap/build/v1/dialog};

Conclusion:

结语:

After performing mentioned steps you will be able to talk to your SAP ME system and perform necessary operations.

在执行上述步骤之后,您将能够与您的 SAP ME 系统进行通信并执行必要的操作。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值