Article Recommendations

Note:Zendesk has renamed our bot capabilities. Answer Bot is nowZendesk bots.Article Recommendations are nowautoreplies.为更多的信息;n on this change, seethis announcement

A recommendation is a collection of help center articles with content that might be related to a customer's enquiry. Requesting an article recommendation from Answer Bot creates a recommendation.

JSON format

Articles are represented as JSON objects with the following properties:

Name Type Read-only Mandatory Description
article_id number false false The id of article
brand_id number false false The id of the brand
html_body string false false The body of the article in HTML
html_url string false false The url of the HTML body
label_names array false false The labels of this article
locale string false false The help center locale of the article
score number false false 本文对用户查询的分数
片段 string false false An excerpt of the article
title string false false The title of the article
url string false false The url of the article

Get Article Recommendations

  • POST /api/v2/answer_bot/answers/articles

Returns help center articles based on an end user's enquiry.

Allowed For

  • Authenticated requests

JSON format

Enquiries are represented as JSON objects with the following properties:

Name Type Read-only Mandatory Description
enquiry string false true The end user's question
labels array of strings false false Help center labels used to restrict article recommendations
locale string false false Help center locales used to restrict article recommendations. Example: "en-gb", "de", or "es". Must match an available help center locale
reference string false true An unique value for every request. This will be used to calculate the MAUs for the account
user_segment_ids array of integers false false Array of user segment ids. Article recommendations are restricted to articles that are accessible to these user segments

Example body

             
{"enquiry":"Consectetur adipiscing elit","labels":["magna"],"locale":"en-us","reference":"sdk-mobile-uid-customer-id","user_segment_ids":[2345123]}

Code Samples

旋度
              
旋度"https://{subdomain}.zendesk.com/api/v2/answer_bot/answers/articles"-X POST -H"Content-Type: application/json"\-u{email_address}:{password}\-d'{"enquiry": "Consectetur adipiscing elit","reference":"sdk-mobile-uid-customer-id","locale":"en-us","labels":["magna"]}'
Go
              
import("fmt""io""net/http""strings")funcmain(){url:="https://support.zendesk.com/api/v2/answer_bot/answers/articles"method:="POST"payload:=stringsNewReader(`{"enquiry": "Consectetur adipiscing elit","labels": ["magna"],"locale": "en-us","reference": "sdk-mobile-uid-customer-id","user_segment_ids": [2345123]}`)req,err:=httpNewRequest(method,url,payload)iferr!=nil{fmtPrintln(err)return}reqHeaderAdd("Content-Type","application/json")reqHeaderAdd("Authorization","Basic ")// Base64 encoded "username:password"client:=&httpClient{}res,err:=clientDo(req)iferr!=nil{fmtPrintln(err)return}deferresBodyClose()body,err:=ioReadAll(resBody)iferr!=nil{fmtPrintln(err)return}fmtPrintln(string(body))}
Java
              
importcomsquareupokhttp*;OkHttpClientclient=newOkHttpClient();HttpUrlBuilderurlBuilder=HttpUrlparse("https://support.zendesk.com/api/v2/answer_bot/answers/articles")newBuilder();RequestBodybody=RequestBodycreate(MediaTypeparse("application/json"),"""{\"enquiry\":\"Consecteturadipiscing elit\",\"labels\":[\"magna\"],\"locale\":\"en-us\",\"reference\":\"sdk-mobile-uid-customer-id\",\"user_segment_ids\":[2345123]}""");Requestrequest=newRequestBuilder()url(urlBuilderbuild())method("POST",body)addHeader("Content-Type","application/json")addHeader("Authorization",Credentialsbasic("your-email","your-password"))build();Responseresponse=clientnewCall(request)execute();
Nodejs
              
varaxios=require('axios');vardata=JSONstringify({"enquiry":"Consectetur adipiscing elit","labels":["magna"],"locale":"en-us","reference":"sdk-mobile-uid-customer-id","user_segment_ids":[2345123]});varconfig={method:'POST',url:'https://support.zendesk.com/api/v2/answer_bot/answers/articles',headers:{'Content-Type':'application/json','Authorization':'Basic ',// Base64 encoded "username:password"},data:data,};axios(config)then(function(response){consolelog(JSONstringify(responsedata));})catch(function(error){consolelog(error);});
Python
              
importrequestsimportjsonurl="https://support.zendesk.com/api/v2/answer_bot/answers/articles"payload=jsonloads("""{"enquiry": "Consectetur adipiscing elit","labels": ["magna"],"locale": "en-us","reference": "sdk-mobile-uid-customer-id","user_segment_ids": [2345123]}""")headers={"Content-Type":"application/json",}response=requestsrequest("POST",url,auth=('',''),headers=headers,json=payload)print(responsetext)
Ruby
              
require"net/http"uri=URI("https://support.zendesk.com/api/v2/answer_bot/answers/articles")request=Net::HTTP::Postnew(uri,"Content-Type":"application/json")requestbody=%q({"enquiry":"Consectetur adipiscing elit","labels":["magna"],"locale":"en-us","reference":"sdk-mobile-uid-customer-id","user_segment_ids":[2345123]})requestbasic_auth"username","password"response=Net::HTTPstart urihostname,uriport,use_ssl:truedo|http|httprequest(request)end

Example response(s)

200 OK
              
// Status 200 OK{"articles":[{"article_id":10192,"brand_id":10016,"html_body":"

Consectetur adipiscing elit. Quisque sit amet magna id tellus volutpat aliquet et nec lorem.

"
,
"html_url":"https://mondocam.zendesk.com/hc/lorem","label_names":["magna","tellus"],"locale":"en-us","score":0.38012391328882644,"snippet":"Consectetur adipiscing elit...","title":"Lorem ipsum","url":"https://mondocam.zendesk.com/article"},{"article_id":10192,"brand_id":10016,"html_body":"

Cras vehicula ipsum at maximus ullamcorper. Maecenas scelerisque ultricies dignissim.

"
,
"html_url":"https://mondocam.zendesk.com/hc/proin","label_names":["magna"],"locale":"en-us","score":0.8882646380123913,"snippet":"Cras vehicula ipsum...","title":"Proin sit amet","url":"https://mondocam.zendesk.com/article"}],"auth_token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhY2NvdW50X2lkIjo0MiwidXNlcl9pZCI6MTAwMDIsInRpY2tldF9pZCI6NSwiYXJ0aWNsZXMiOlsxMDEwMiwxMDE5Ml0sInRva2VuIjpudWxsLCJleHAiOjE1MjA2NjE1MTR9.VzS91dP0cLjXw_3pZd2tcEdru8xoOXQe7ZfqzA9uL3s","id":4,"interaction_access_token":"GciOiJIUzI1NiJ9eyJ0eXAiOiJKV1QiLCJhb.0aWNsZXMiOlsxMDEwMiwxMDE5Ml0sInRva2VuIjpudWxsLCJleHAiOjE1MjA2NjE1MTR9eyJhY2NvdW50X2lkIjo0MiwidXNlcl9pZCI6MTAwMDIsInRpY2tldF9pZCI6NSwiYXJ.VzS91dP0cLjXw_3pZd2tcEdru8xoOXQe7ZfqzA9uL3s"}