Home >WeChat Applet >Mini Program Development >WeChat mini program robot automatic customer service function
Nowadays, WeChat mini programs are more popular in development. This article will teach you a new function of WeChat: a mini program for customer service robots. This mini program can also be used to create other types of automatic customer service programs. It can add corresponding questions and answers to the olami platform. The answer is, that's it.
The entire mini program interface contains two parts, one for displaying answers and the other for input boxes. The core of the applet is to send an http request to the olami server, then process the results and display them. For detailed usage of the olami interface, please refer to the two blog posts at the top. The code to process the input is as follows:
bindInput: function (e) { var that = this; var input = e.detail.value; var timeStamp = new Date().getTime(); var sign = '1df21860a96a4509bcb50957bbdd6eccapi=nliappkey=382c5f83fb67458a99ca7b2eee17473etimestamp=' + timeStamp + '1df21860a96a4509bcb50957bbdd6ecc'; var MD5 = require('../../utils/MD5.js') sign = MD5.md5(sign); wx.request({ url: 'https://cn.olami.ai/cloudservice/api', data: { appkey: '382c5f83fb67458a99ca7b2eee17473e', api: 'nli', timestamp: timeStamp, sign: sign, rq: JSON.stringify({ "data_type": "stt", "data": { "input_type": 1, "text": input } }), cusid: app.globalData.custId, }, header: { 'content-type': 'application/x-www-form-urlencoded' }, method: 'POST', success: function(res) { var result = ''; if (res.data.status == 'ok') { if (res.data.data.nli.length != 0) { result = res.data.data.nli[0].desc_obj.result } } that.setData({ userInfo: {}, userinput: '', result: result }) } }); },
The running effect is shown in the figure below:
Input
Result
Introduction to the help function
To implement the automatic customer service function, you only need the following A few steps:
1. Enter the nli system on the olami platform and create a new grammar module.
2. Enter the module, edit grammar, add questions that need support and corresponding answers.
The content in the picture is the supported questions. The platform's OSL grammar description language is used here, which can support multiple similar statements in one grammar. The osl language description is here. Of course, if you want to save trouble, you can just write a complete sentence, but in this case, you can only get the answer with this complete question.
Select the answer as the output method. You can add multiple answers below. These answers are randomly output. You can write multiple answers with the same meaning, so that it will not appear so monotonous.
Publish it after the grammar is completed.
If the module is configured in the application management, you can see in the mini program that the corresponding question has been answered. To add new supported questions in the future, just repeat steps 2 to 3.
The sentences supported by the customer service function are:
What kind of game is this?
What does this small program do?
What voice commands are there
How to play this game
The above is the tutorial on the automatic customer service function of the WeChat applet. I hope it will be helpful to everyone.
Related recommendations:
How to implement the image enlargement preview function in WeChat mini program
Introduction example of WeChat mini program development
Summary experience on mini program development
The above is the detailed content of WeChat mini program robot automatic customer service function. For more information, please follow other related articles on the PHP Chinese website!