"use strict";(self.webpackChunknewoaks_help=self.webpackChunknewoaks_help||[]).push([[9924],{5114:(e,s,t)=>{t.r(s),t.d(s,{assets:()=>l,contentTitle:()=>h,default:()=>p,frontMatter:()=>d,metadata:()=>n,toc:()=>c});const n=JSON.parse('{"id":"api/set-messages-limit","title":"Set Messages Limit","description":"The  API enables you to set the maximum number of messages sent per session by sending a POST request to the /chat/Chatbot/SetSessionMessagesLimit endpoint.","source":"@site/developer/api/114.set-messages-limit.md","sourceDirName":"api","slug":"/api/set-messages-limit","permalink":"/guides/developer/api/set-messages-limit","draft":false,"unlisted":false,"tags":[],"version":"current","sidebarPosition":114,"frontMatter":{"sidebar_position":114},"sidebar":"sidebar","previous":{"title":"Get Chatbot Messages Count","permalink":"/guides/developer/api/get-chatbot-messages-count"},"next":{"title":"Webhook","permalink":"/guides/developer/category/webhook"}}');var i=t(4848),r=t(8453),o=t(767),a=t(8175);const d={sidebar_position:114},h="Set Messages Limit",l={},c=[{value:"Endpoint",id:"endpoint",level:2},{value:"Request Headers",id:"request-headers",level:2},{value:"Example Request",id:"example-request",level:2},{value:"Response",id:"response",level:2},{value:"Error Handling",id:"error-handling",level:2}];function u(e){const s={code:"code",h1:"h1",h2:"h2",header:"header",p:"p",...(0,r.R)(),...e.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(s.header,{children:(0,i.jsx)(s.h1,{id:"set-messages-limit",children:"Set Messages Limit"})}),"\n",(0,i.jsxs)(s.p,{children:["The ",(0,i.jsx)(a.A,{})," API enables you to set the maximum number of messages sent per session by sending a ",(0,i.jsx)(s.code,{children:"POST"})," request to the ",(0,i.jsx)(s.code,{children:"/chat/Chatbot/SetSessionMessagesLimit"})," endpoint."]}),"\n",(0,i.jsx)(s.h2,{id:"endpoint",children:"Endpoint"}),"\n",(0,i.jsx)(o.TM,{path:"/chat/Chatbot/SetSessionMessagesLimit",method:"POST"}),"\n",(0,i.jsx)(s.h2,{id:"request-headers",children:"Request Headers"}),"\n",(0,i.jsx)(o.iW,{headers:{Authorization:"<Your-Secret-Key>"}}),"\n",(0,i.jsx)(s.h2,{id:"example-request",children:"Example Request"}),"\n",(0,i.jsx)(o.r3,{method:"POST",path:"/chat/Chatbot/SetSessionMessagesLimit",headers:{Authorization:"<Your-Session-Key>"},requestBody:{MessagesLimit:100}}),"\n",(0,i.jsx)(s.h2,{id:"response",children:"Response"}),"\n",(0,i.jsx)(o.zV,{responseExample:{Data:!0},responseComments:{Data:"boolean - Success status","Data.Total":"integer - Total number of message credits allocated (-1 indicates unlimited credits)","Data.Used":"integer - Number of message credits that have been used","Data.Remain":"integer - Number of message credits remaining (-1 indicates unlimited remaining credits)"}}),"\n",(0,i.jsx)(s.h2,{id:"error-handling",children:"Error Handling"}),"\n",(0,i.jsx)(o.NH,{})]})}function p(e={}){const{wrapper:s}={...(0,r.R)(),...e.components};return s?(0,i.jsx)(s,{...e,children:(0,i.jsx)(u,{...e})}):u(e)}},767:(e,s,t)=>{t.d(s,{Ay:()=>m,NH:()=>p,TM:()=>d,VQ:()=>l,iW:()=>h,r3:()=>c,zV:()=>u});t(6540);var n=t(3532),i=t(8069),r=t(9303),o=t(4848);const a=function(e,s){void 0===s&&(s={});const t=JSON.stringify(e,null,2).split("\n"),n=[];return t.forEach((e=>{const t=e.match(/"([^"]+)":/);if(t&&s[t[1]]){const i=e.match(/^\s*/)?.[0]||"";n.push(`${i}// ${s[t[1]]}`)}n.push(e)})),n.join("\n")},d=e=>{let{path:s,method:t="POST"}=e;const i=(0,n.r)()(s)||`https://usapi.hottask.com${s}`;return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)("p",{children:[(0,o.jsx)("strong",{children:"Request URL:"})," ",i]}),(0,o.jsxs)("p",{children:[(0,o.jsx)("strong",{children:"Method:"})," ",t]})]})},h=e=>{let{headers:s={Authorization:"<Your-Secret-Key>","Content-Type":"application/json"},headersDescription:t={Authorization:"string, required - The secret key for authenticating the API request","Content-Type":"string, required - The content type of the request payload (must be application/json)"}}=e;return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("p",{children:"The API request must include the following headers:"}),(0,o.jsx)("ul",{children:Object.entries(s).map((e=>{let[s,n]=e;return(0,o.jsxs)("li",{children:[(0,o.jsxs)("code",{children:[s,": ",n]})," - ",t[s]]},s)}))})]})},l=e=>{let{requestBody:s,requestBodyParams:t,addCommentsToJson:n=a}=e;return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("p",{children:"The request body should contain the following parameters:"}),(0,o.jsx)(i.A,{language:"json",children:n(s,t)}),(0,o.jsx)("ul",{children:Object.entries(t).map((e=>{let[s,t]=e;return(0,o.jsxs)("li",{children:[(0,o.jsx)("code",{children:s})," - ",t]},s)}))})]})},c=e=>{let{method:s="POST",path:t,requestBody:a,headers:d={Authorization:"<Your-Secret-Key>","Content-Type":"application/json"}}=e;const h=(0,n.r)()(t),l="undefined"==typeof window?"usapi.hottask.com":new URL(h||`https://usapi.hottask.com${t}`).host,c={javascript:`const res = await fetch('${h||`https://usapi.hottask.com${t}`}', {\n  method: '${s}',\n  headers: ${JSON.stringify(d,null,2)},\n  body: JSON.stringify(${JSON.stringify(a,null,2)})\n});\n\nconst data = await res.json();\nconsole.log(data);`,python:`import requests\nimport json\n\nurl = '${h||`https://usapi.hottask.com${t}`}'\nheaders = ${JSON.stringify(d,null,4)}\ndata = ${JSON.stringify(a,null,2)}\n\nresponse = requests.${s.toLowerCase()}(url, headers=headers, json=data)\ndata = response.json()\nprint(data)`,bash:`curl '${h||`https://usapi.hottask.com${t}`}' \\\n  -X ${s} \\\n${Object.entries(d).map((e=>{let[s,t]=e;return`  -H '${s}: ${t}' \\`})).join("\n")}\n  -d '${JSON.stringify(a)}'`,http:`${s} ${t} HTTP/1.1\nHost: ${l}\n${Object.entries(d).map((e=>{let[s,t]=e;return`${s}: ${t}`})).join("\n")}\n\n${JSON.stringify(a,null,2)}`};return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(r.A,{as:"h3",children:"JavaScript (Fetch API)"}),(0,o.jsx)(i.A,{language:"javascript",children:c.javascript}),(0,o.jsx)(r.A,{as:"h3",children:"Python (Requests Library)"}),(0,o.jsx)(i.A,{language:"python",children:c.python}),(0,o.jsx)(r.A,{as:"h3",children:"cURL"}),(0,o.jsx)(i.A,{language:"bash",children:c.bash}),(0,o.jsx)(r.A,{as:"h3",children:"HTTP Request"}),(0,o.jsx)(i.A,{language:"http",children:c.http})]})},u=e=>{let{responseExample:s,responseComments:t,addCommentsToJson:n=a}=e;const r={...s,Version:"1.0.0",Success:!0,Code:200,Message:""},d={...t,Version:"string - API version",Success:"boolean - Operation success status",Code:"integer - HTTP status code",Message:"string - Error message if any"};return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("p",{children:"The API response will be a JSON object with the following structure:"}),(0,o.jsx)(i.A,{language:"json",children:n(r,d)})]})},p=e=>{let{errorHandling:s="If the request fails, you should:\n1. Check the HTTP status code for network-level errors\n2. Examine the `Code` and `Message` fields in the response for business-level errors\n3. The `Message` field will contain detailed error information"}=e;return(0,o.jsx)("div",{style:{whiteSpace:"pre-line"},children:s})};function m(e){let{title:s,path:t,method:i="POST",description:r="",requestBody:m={timeZone:"Asia/Shanghai",type:0},requestBodyDescription:g={timeZone:"The time zone of the chatbot. The standard time zone format: e.g., Asia/Shanghai or America/New_York.",type:"Create a generic chatbot with a fixed value of 0"},requestBodyComments:j={timeZone:"string, required",type:"integer, required"},responseExample:x={Data:"3254a9d0424c4806b9ea3d0763xxxxxx",Version:"1.0.0",Success:!0,Code:200,Message:""},responseComments:f={Data:"chatbot id"},headers:y={Authorization:"<Your-Secret-Key>","Content-Type":"application/json"},headersDescription:w={Authorization:"The secret key for authenticating the API request.","Content-Type":"The content type of the request payload."},errorHandling:b="If it's an HTTP network error, you should check the `HTTP status code`. If it's a business exception, you need to examine the `Code` and `Message` fields, which will provide the error details."}=e;const T=(0,n.r)()(t),S="undefined"==typeof window?"usapi.hottask.com":new URL(T||`https://usapi.hottask.com${t}`).host;JSON.stringify(y,null,2),a(m,j),JSON.stringify(y,null,4),a(m,j),i.toLowerCase(),Object.entries(y).map((e=>{let[s,t]=e;return`  -H '${s}: ${t}' \\`})).join("\n"),JSON.stringify(m),Object.entries(y).map((e=>{let[s,t]=e;return`${s}: ${t}`})).join("\n"),a(m,j);return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(d,{path:t,method:i}),(0,o.jsx)(h,{headers:y,headersDescription:w}),(0,o.jsx)(l,{requestBody:m,requestBodyParams:g,addCommentsToJson:a}),(0,o.jsx)(c,{method:i,path:t,requestBody:m,headers:y}),(0,o.jsx)(u,{responseExample:x,responseComments:f,addCommentsToJson:a}),(0,o.jsx)(p,{errorHandling:b})]})}},8175:(e,s,t)=>{t.d(s,{A:()=>r});t(6540);var n=t(5872),i=t(4848);function r(){let e=(0,n.K)()();return["newoaks.ai","www.newoaks.ai","eu.newoaks.ai"].includes(e)&&(e="NewOaks AI"),"appointify.ai"===e&&(e="Appointify AI"),(0,i.jsx)("code",{children:e})}},3532:(e,s,t)=>{function n(){return function(e){if("undefined"==typeof window)return"";const s=window.location.hostname;let t="";return t="www.newoaks.ai"==s||"newoaks.ai"==s?"https://usapi.hottask.com":"eu.newoaks.ai"==s?"https://euapi.hottask.com":`https://${s}`,e?`${t}${e.startsWith("/")?e:`/${e}`}`:t}}t.d(s,{r:()=>n})},5872:(e,s,t)=>{function n(){return function(){return"undefined"==typeof window?"":window.location.hostname}}t.d(s,{K:()=>n})}}]);