In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
Today, I will talk to you about how to develop the simplest question and answer service for your Wechat Subscription account. Many people may not understand it very well. In order to make you understand better, the editor summarized the following content for you. I hope you can get something from this article.
Introduce how to develop a simple question and answer service for your Wechat Subscription account, which is very fun.
Realized scenario
When your Subscription account fans send a message to Subscription account, they will get the same text reply as the message sent, with the prefix "Add by Jerry:" in front of it.
It doesn't make any sense, does it? Because Subscription account's Wechat message server is now developed by ourselves, after receiving the text sent by fans on the message server, we can implement some interesting logic. For example, call some artificial intelligence Turing API to chat with Subscription account fans, like this:
Here are the detailed steps.
1. Open the server.js file in my github project:
Implement the following code. This server.js is the entrance to the entire message server. The function of routesEngine is to deal with different requests sent to the message server by Wechat platform. Of course, the specific implementation is in the index.js under the folder jerryapp/routes.
Var express = require ('express'); var routesEngine = require ('. / jerryapp/routes/index.js'); var app = express (); routesEngine (app); app.listen (process.env.PORT | | 3000, function () {console.log ('Listening on port, process.cwd ():' + process.cwd ();}))
two。 Now let's start implementing index.js. When the fan's text request is sent to the message server, call the self-implemented nodejs module "echoService" to process it.
Var request = require ('request'); var echoService = require (".. / service/echo.js"); module.exports = function (app) {app.route (' /') .post (function (req,res) {echoService (req,res);});}
Open echo.js to see the implementation:
From line 6 below, you can see the prefix "Add by Jerry:" added to the reply.
Turing Service with artificial Intelligence
If you don't want to reply "Add by Jerry:" to your Subscription account fans, comment out ecoService in index.js and use Turing API instead. The following figure is shown in line 29.
The invocation implementation of Turing API is located in tuning.js, which actually consumes an artificial intelligence service exposed through RestFul API:
Url is as follows:
Www.tuling123.com/openapi/api?key=de4ae9269c7438c33de5806562a35cac&info=
We only need to paste the text sent by Subscription account fans in Wechat App to the end of the above url, and call the API to get the response result of Turing API analysis. Take the weather forecast for Chengdu as an example:
After reading the above, do you have any further understanding of how to develop the simplest question and answer service for your Wechat Subscription account? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.