Chat Bot Backend Integration

To integrate with our AI Chat Bot service, third-party backend systems must implement a proxy controller. This proxy acts as a gateway, appending the required headers and securely forwarding the request to our AI Chat Bot endpoint.

Scala + Spring Integration

Download Demo from: https://github.com/lzhao-bgl/smartdocs-ai-studio/tree/main/assistant-backend-demo

Here is the recipe for integration:


Java + Spring Integration

Download Demo from: https://github.com/lzhao-bgl/smartdocs-ai-studio/tree/main/assistant-backend-demo



Endpoints

1. Proxy API Requests

REQUEST /ai-assistant/{*segment}

This endpoint proxies general AI assistant requests.

2. Stream Assistant Events

GET /ai-assistant/{context}/threads/{threadId}/events

Streams Server-Sent Events (e.g., assistant messages).

3. Stream Assistant Run Output

GET /ai-assistant/{context}/threads/stream/{threadId}/runs

Streams assistant run output in real-time.


Required Headers

We require users to provide apiKey and a unique third party id for each api call.

X-ThirdParty-User-Id defines the owner of the thread, so please provide a unique id that no one else could use it.

Header NameDescription
X-API-KEYAPI key (provided by us)
X-ThirdParty-User-IdName or ID of the calling user that should be unique

Optional Headers

All the other headers start with "app-ai-assistant-function-call-" will be send to function call directly. For example, if given "app-ai-assistant-function-call-firm-id", firmId will be given to the function. You can define your own header name if needed. Following are some examples:

Header NameDescription
app-ai-assistant-function-call-firm-idFirm identifier or similar
app-ai-assistant-function-call-sourceIntegration source name
app-ai-assistant-function-call-entity-idEntity ID associated with the request

Required Dependencies

Make sure your Spring project includes:

  • spring-boot-starter-webflux
  • spring-cloud-starter-gateway
  • Security libraries that expose Authentication