search
HomeWeChat AppletMini Program DevelopmentWeChat 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

WeChat mini program robot automatic customer service function

Result

WeChat mini program robot automatic customer service function

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.

WeChat mini program robot automatic customer service function

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!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment