It's easy to call (send an HTTP request to) the Weixin Open Platform semantic understanding API. You can simply select the relevant services based on your business features to build a smart semantic service, without having to know anything about semantic understanding or the relevant technical details.

Send a semantic understanding request

HTTP request method: POST (HTTPS protocol should be used)

https://api.weixin.qq.com/semantic/semproxy/search?access_token=YOUR_ACCESS_TOKEN

POST data format: JSON

POST data example:

{
"query":"Query China Southern Airlines tickets from Beijing to Shanghai tomorrow",
"city":"Beijing",
"category": "flight,hotel",
"appid":"wxaaaaaaaaaaaaaaaa",
"uid":"123456"
}

Parameters

Parameter Required Type Description
access_token Yes String The token obtained based on the AppID and AppSecret
query Yes String Enter a text string
category Yes String Service type. Separate multiple types with commas (,). This parameter cannot be left blank.
latitude See the API protocol documentation. Float Latitude coordinates, provided with longitude coordinates at the same time. This parameter is not required if "city" is specified.
longitude See the API protocol documentation. Float Longitude coordinates, provided with latitude coordinates at the same time. This parameter is not required if "city" is specified.
city See the API protocol documentation. String City name. This parameter is not required if "latitude" and "longitude" are specified.
region See the API protocol documentation. String Region name. This parameter is not required if "city" or "latitude" and "longitude" are specified.
appid Yes String The unique identifier of an Official Account, which is used to identify the Official Account developer.
uid No String The unique ID of the user (not the developer). This is used to distinguish between users under an Official Account (we recommend using the user's openid). If this field is left blank, you cannot use the context understanding feature, because this requires both the AppID and UID.

Note: As a single category has a more clear intent and a relatively large coverage of recognition, if you only use a specific category, it is recommended to set "category" to this category only.

Response description For a successful request, Weixin returns the following JSON packet:

{
"errcode":0,
"query"":"Query China Southern Airlines tickets from Beijing to Shanghai tomorrow",
"type":"flight",
"semantic":{
"details":{
"start_loc":{
"type":"LOC_CITY",
"city":"Beijing city",
"city_simple":"Beijing",
"loc_ori":"Beijing"
},
"end_loc": {
"type":"LOC_CITY",
"city":"Shanghai city",
"city_simple":"Shanghai",
"loc_ori":"Shanghai"
},
"start_date": {
"type":"DT_ORI",
"date":"2014-03-05",
"date_ori":"Tomorrow"
},
"airline":"China Southern Airlines"
},
"intent":"SEARCH"
}

Response Parameters

Parameter Required Type Description
errcode Yes Int Indicates the request status
query Yes String The string entered by the user
type Yes String The global type ID of the service. See the definition of the vertical service protocol in the protocol documentation.
semantic Yes Object The structured identifier after semantic understanding (different for each service)
result No Array The results for some categories
answer No String The results for some categories displayed in HTML5 (currently unsupported)
text No String Special reply instructions

For more detailed information and protocol description, see: <a href="https://open.weixin.qq.com/zh_CN/htmledition/res/assets/smart_lang_protocol.pdf target="_blank">Semantic Understanding API Protocol Documentation.