About private domain traffic
In recent years, the topic of private domain traffic operations has been mentioned more and more.
Private domain traffic refers to traffic from the public domain (internet), other domains (platforms, media channels, partners, etc.) to its own private domain (official website, customer list), as well as the traffic (visitors) generated by the private domain itself. Private domain traffic is customer data that can be used for more than two links, contact, sales and other marketing activities.
A very important point of private domain traffic operation is how to automate and intelligently carry out customer operations.
At present, the office software of major companies supports the application form of robots, and this kind of robot is an important part of our private domain traffic operation.
what can robots do
Robots can do things including but not limited to the following in private domain traffic operations:
- message push
- Intelligent customer service
- customer management
- Build a group
- event marketing
- Enterprise interconnection
These scene nouns may be somewhat abstract, and a few concrete examples can be given.
- For example, after a user joins the group, they will receive a welcome ceremony automatically sent by the robot, which includes a new user voucher, etc. At the same time, this message is only visible to him and will not disturb other users.
- For example, users can get many common answers by asking intelligent customer service robots, saving labor costs.
- For example, the robot automatically initiates the registration of a marketing activity in the group without manual collection.
- For another example, through customer management, you can tag customers, and automatically send different activity offers for different customers.
- Another example is to collect business opportunities obtained from advertisement placement through robots, automatically create business opportunity leads, and synchronize them to the group to automatically @relevant sales, closing the entire business opportunity discovery path.
There are many, many imaginable spaces.
Why Serverless?
Why choose serverless to do it? The main benefits are as follows:
- The communication of the robot is to communicate with the enterprise WeChat through HTTP requests, and serverless charges by the number of calls, which has a very high cost performance.
- Robots are usually not used at night. If traditional server deployment is used, there will be a high idle rate. With serverless, the utilization rate can be nearly 100%.
- Robots may involve multiple usage scenarios, and different FaaS cloud functions can be used for different scenarios to achieve fine-grained management and problem isolation.
- Tencent Yunyun functions support all mainstream languages, do not need to care about the server, fast development, short cycle, a robot only takes 1 hour from development to launch.
Why does say free?
Because Tencent Yunyun functions include free quotas. The use of robots is not frequently called, so the free quota is enough to cover all the usage.
Free wool scoop up!
This article will choose enterprise WeChat as the platform, and explain how to use serverless cloud functions to complete an enterprise WeChat robot from the most basic scenario.
Enterprise WeChat Robot Principle
Let's first understand the principle of enterprise WeChat robot. As shown in the figure above, the left side represents our serverless cloud function robot, and the right side is the enterprise WeChat.
The arrows in the middle indicate the two communication methods between bots and enterprise WeChat:
- The robot sends a message to the enterprise WeChat in one direction
- Two-way messages between robots and enterprise WeChat
As can be seen from the figure, the one-way communication is a blue arrow, because there are no restrictions on one-way communication, the robot cannot obtain the relevant information of the enterprise WeChat. This mode is mainly suitable for all notification scenarios. Such as message push, global mass distribution, etc.
The red arrow has many restrictions, because if the enterprise WeChat can send out information, there are many security issues involved. Therefore, enterprise WeChat has made many restrictions on this situation:
- The sent message must be strictly encrypted and decrypted.
- The content of some special messages has certain validity. For example, to obtain session information, a temporary URL must be used. The validity period is only 5 minutes, and it will be invalid after being called once.
- The callback URL for two-way communication can be limited by the enterprise, for example, only the enterprise intranet URL is supported.
With two-way communication, all the scenarios mentioned above can be achieved, such as intelligent customer service, customer management, etc.
Robot combat
Then we will explain how to implement an enterprise WeChat robot from two simple scenarios.
- Message Notification - One-Way Communication
- Knowledge Base Search - Two-Way Communication
notification
First of all, you need to create a robot. The way to create it is to click on the upper right corner to add a group robot in any enterprise WeChat group.
Then select New to create a bot.
After the creation is complete, you get a webhook address. As shown below.
This webhook address is the address where you push messages to the enterprise WeChat.
There are many types of push messages, and six types of messages can be sent to group chat sessions: text, markdown, pictures, graphics, files, and template cards.
Taking text messages as an example, you only need to push the following JSON content to the webhook address, and the enterprise WeChat will receive the notification.
{
"chatid":"CHATID1 | CHATID2",
"msgtype":"text",
"text":{
"content":"广州今日天气:29度,大部分多云,降雨概率:60%",
"mentioned_list":["lisi", "@all"],
"mentioned_mobile_list":["13800001111", "@all"]
}
}
Then take cloud function as an example, how to create cloud function can refer to official website document .
Once created, it only takes a few lines of code to complete a notification sending bot. As shown below.
Note that to replace the url with your robot webhook address, the content must be utf8 encoded.
If you expect the weather forecast to be pushed regularly at 8:00 every morning, you only need to modify the above code, get the weather forecast from a weather forecast API, and then set a timing trigger, the trigger period is defined by CRON expression to trigger at 8:00 every day ,As shown below.
After this, at 8 o'clock every day, your enterprise WeChat group can receive the message as shown below.
Knowledge Base Search
The previous example was an example of one-way communication. Then this example is an example of two-way communication.
In enterprises and private domain traffic operations, we often have scenarios where we search knowledge bases to find answers. Here we take the example of searching Tencent Cloud documents to explain how to complete a knowledge base search robot with two-way communication.
All we have to do is to go to the Tencent Cloud document search results and return when we enter a keyword, while highlighting the keyword and document link.
First, again, you need to create a cloud function. However, this cloud function needs to receive messages from the enterprise WeChat. Therefore, based on the previous cloud function, we need to add an API gateway trigger so that the cloud function can receive API requests.
Create a trigger Select the API gateway trigger. After creation, as shown in the figure below, copy the URL of the access path, which is the URL that the enterprise WeChat needs to fill in the callback message.
Then go to Enterprise WeChat, place the mouse on the robot you created, click Configure, select [Receive Message Configuration], and fill in the URL copied above in the URL. As shown below.
Token and EncodingAESKey can be written by yourself or obtained randomly. They are used for encryption and decryption.
💡 When you click "Save" to submit the above information, Enterprise WeChat will send a verification message to the filled URL, the sending method is GET
. After the receiving message server of the group robot receives the verification request, it needs to make a correct response to pass the URL verification.
After completing the above settings, you can @bot in the group chat and enter the keyword you want to search for, your cloud function will receive the corresponding JSON message, msgContent
is the keyword you searched for.
{
"msgType": "text",
"msgContent": "函数计费",
"chatId": "XXX",
"botKey": "XXX",
"hookUrl": "http://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=XXXX",
"botName": "腾讯云文档搜索助手",
"userName": "XXX·",
"msgId": "CAIQ4",
"chatType": "group",
"chatInfoUrl": "http://qyapi.weixin.qq.com/cgi-bin/webhook/get_chat_info?code=XXX"
}
At this time, you only need to get the content of msgContent
, then call Tencent Cloud's document search API, get the JSON result, process the JSON result into the markdown format as shown in the figure below, and return it.
So our Tencent document search assistant is ready, and the effect is as follows.
So far, our two enterprise WeChat robots have been completed.
will not show the code here. Students who want to see how to write it can go to my source code .
Summarize
I explained how to make enterprise WeChat robots from two simple examples. Enterprise WeChat robots are an important step for us to operate private domain traffic. Meanwhile, Serverless perfectly helps us solve the technical selection of robots.
- With our pursuit of customer experience and service experience, we use automation to help us improve the response speed, and use intelligence to help us improve service accuracy.
- In today's pursuit of pre-sales and after-sales efficiency, the use of robots can save labor costs and time, and shorten customer waiting time.
- Serverless, as an elastic scaling and pay-as-you-go service, perfectly matches the usage scenarios of robots, and helps enterprises to quickly build and iterate businesses in private domain traffic operation scenarios in terms of cost and efficiency.
- Serverless, as a FaaS service, handles different business scenarios independently or in combination through the orchestration of multiple cloud functions, achieving fine-grained management and isolation from business fault tolerance.
In the future, I will continue to explore more scenarios and practices of serverless private domain traffic operations, and I will continue to share them with you.
If you have questions related to private domain traffic operation, please come and discuss with me.
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。