Order number validation API

Updated at:

This document describes the contract for a validation API that collects order numbers. It explains how to implement, configure, and verify this API.

1. Overview

During a dialog, a chatbot may need to collect an order number from a user. This process can involve multiple questions to confirm and complete the information. This validation API validates the user's input at each step. When a user provides only a partial order number, the chatbot sends this input to the validation API. The API then responds, indicating whether the input is complete and correctly formatted. You must implement this API. The request includes the partial order number, and the response provides validation details, such as its completeness, format, and length.

2. API reference

The validation API only supports POST requests.

Request parameters:

Parameter

Type

Description

billCode

String

The order number.

{
  "billCode":"7789373123445"
}

Response parameters:

Parameter

Type

Required

Description

status

boolean

Yes

Indicates whether the input is a valid order number.

statusCode

String

No

The status code. This field is returned only when status is false.

LENGTH_LESS_ERROR: More input is required.

LENGTH_MORE_ERROR: The input is too long.

FORMAT_ERROR: The format is incorrect.

message

String

No

Details about the error. For example:

The order number must start with 77.

Note: If the statusCode is LENGTH_MORE_ERROR or FORMAT_ERROR, you must provide a reason in the message field. The chatbot relays this message to the user.

{
  "status":false,
  "statusCode":"FORMAT_ERROR",
  "message":"Invalid order number format. Please try again."
}

The chatbot includes its instance ID in the robotInstanceId field of the HTTP request header. You can use this ID to authenticate requests.

3. API configuration

Configure your validation API in the chatbot's API plugin. After configuration, you can select the API from a node's API configuration settings.

image.png