openapi对接

前提条件

构造签名获取token

对接duix-openapi-v2平台时,需在自己平台中集成生成token的代码,生成token的方法可参考以下代码:

如何获取Token

管理接口

管理类HTTP请求有一个共同的约定,需要在请求头中传token

交互流程

获取APP实时并发数

接口地址:

/duix-openapi-v2/sdk/v2/getconcurrentNumber

请求方式: GET

接口描述:

查询某APP下并发数

参数说明
参数名称类型传参方式参数说明
appIdStringQuery从平台创建的APPID

响应参数:

参数名称类型
codeString
dataConcurrentStatus
cropIdString
totalConcurrentNumberinteger(int32)
userConcurrentNumberinteger(int32)
messageString
successboolean

响应示例:

{
  "code": "",
  "data": {
    "cropId": "",
    "totalConcurrentNumber": 0,
    "userConcurrentNumber": 0
  },
  "message": "",
  "success": true
}

获取APP实时会话

接口地址:

/duix-openapi-v2/sdk/v2/getconcurrentList

请求方式: GET
接口描述:

查询某APP下的”通话中“的会话列表。

参数说明
参数名称类型传参方式参数说明
appIdStringQuery从平台创建的APPID

关闭APP所有会话

接口地址:

/duix-openapi-v2/sdk/v2/distroyCallSessionsByAppId

请求方式: GET
接口描述:

关闭某APP下所有的会话

参数说明
参数名称类型传参方式参数说明
appIdStringQuery从平台创建的APPID
响应示例:
{
  "code": "",
  "data": "",
  "message": "",
  "success": true
}

关闭指定会话

接口地址:

/duix-openapi-v2/sdk/v2/sessionStop

请求方式: GET
参数说明
参数名称类型传参方式参数说明
uuidStringQuerystart-complete事件返回的 sessionId 字段

第三方话术对接(非流式)

其他会话集成: 其他会话平台可以通过以下的方式提供给数字人使用。DUIX平台可以通过你的数字人,使用POST方式请求一个你定义的远程URL,来获取问题的答案。
会话平台集成样例: 可以参考这个会话平台集成的例子。这个开源的应用实现了一个对话平台集成,该样例应用实现闲聊会话功能。
请求规范: DUIX平台将问题请求(客户想你的数字人提出的)按照以下格式,通过POST方式发送至你远程URL。
参数说明
FieldTypeDescriptionRequired
sidString你的用户id,在创建用户时产生。可以在账号信息中查看。Y
dh-codeString数字人编号,在每个数字人创建时产生,可以在数字人概览查看。Y
dh-questionString你需要问数字的问题内容Y
dh-conversation-idString会话id,标识该会话的唯一标识Y
dh-contextString关于该会话期间产生的上下文信息,该信息为已经字符串化的JSON格式数据。N
请求示例:
{
  "sid": "100003",
  "dh-code": "187265485019156480",
  "dh-question": "who are you?",
  "dh-conversation-id": "0513e935-041f-48e0-9330-652ef4194511",
  "dh-context": "{}"
}

响应规范: 当你收到问题请求的时候,你需要按照下面的格式返回。

字段类型是否必须备注
codeStringY返回的状态码
msgStringN成功/错误的描述信息
dataobjectN返回的具体内容
successBooleanY是否成功

有效响应类型:

CodeStatusResponse
200OK按照下面规范的返回体
400Bad RequestRequest body/headers are invalid
401Unauthorized鉴权信息无效
403Forbidden鉴权失败
500Server Error服务异常

返回体规范:

FieldTypeDescriptionRequired
conversationIdString会话id,标识该会话的唯一标识,与请求参数体的dh-conversation-id一致。Y
questionString用户所问的问题。N
answerString用户问数字人的问题的答案,这是一个字符串化的 JSON 对象。Y
intentString问题匹配到平台的意图N
errorMsgString异常或者对错误的描述N
extraString额外信息,JSON字符串N
{
  "code": "200",
  "msg": "SUCCESS",
  "success": true,
  "data": {
    "conversationId": "0513e935-041f-48e0-9330-652ef4194511",
    "question": "who are you?",
    "answer": {
      "answer": "Welcome to UneeQ, how can I help?",
      "operations": {
        "tipPhrases": {
          "phrases": ["yes", "no"]
        },
        "canShowText": 1
      }
    },
    "intent": "introduce",
    "errorMsg": "",
    "extra": "{}"
  }
}

预期响应时间: 与数字人类的互动,由于他们的实时性,对延迟很敏感。因此,在处理来自DUIX平台的请求时,响应时间是需要考虑的一个重要因素。这些服务的响应时间需要95%以上在20秒以内。如果响应时间超过20s,该请求将报出超时错误,但是数字人将继续响应。

第三方话术对接(流式)

其他会话集成: 其他会话平台可以通过以下的方式提供给数字人使用。DUIX平台可以通过你的数字人,使用POST方式请求一个你定义的远程URL,来获取问题的答案。
会话平台集成样例: 可以参考这个会话平台集成的例子。这个开源的应用实现了一个对话平台集成,该样例应用实现闲聊会话功能。
请求规范: DUIX平台将问题请求(客户想你的数字人提出的)按照以下格式,通过POST方式发送至你远程URL。
参数说明
FieldTypeDescriptionRequired
sidString你的用户id,在创建用户时产生。可以在账号信息中查看。Y
dh-codeString数字人编号,在每个数字人创建时产生,可以在数字人概览查看。Y
dh-questionString你需要问数字的问题内容Y
dh-conversation-idString会话id,标识该会话的唯一标识Y
dh-contextString关于该会话期间产生的上下文信息,该信息为已经字符串化的JSON格式数据。N
请求示例:
{
  "sid": "100003",
  "dh-code": "187265485019156480",
  "dh-question": "who are you?",
  "dh-conversation-id": "0513e935-041f-48e0-9330-652ef4194511",
  "dh-context": "{}"
}

返回体规范:

FieldTypeDescriptionRequired
answerString返回答案Y
isEndboolean是否结束Y
{
    "answer": "Let the Cowherd and Weaver Girl meet on the Milky Way.",
    "isEnd": false
}

预期响应时间: 与数字人类的互动,由于他们的实时性,对延迟很敏感。因此,在处理来自DUIX平台的请求时,响应时间是需要考虑的一个重要因素。这些服务的响应时间需要95%以上在20秒以内。如果响应时间超过20s,该请求将报出超时错误,但是数字人将继续响应。

获取会话详情

接口地址:

/duix-openapi-v2/sdk/getConversationById?conversationId=[duix平台会话id]

请求方式: GET

接口描述:

根据duix平台创建的会话id,查询会话详情。

参数说明
参数名称类型传参方式参数说明
conversationIdStringQuery从平台创建的conversationId

响应参数:

参数名称类型说明
codeString返回code
dataJSON返回数据
detailDtoJSON会话资源详情(含模型、背景、tts)
detailDto.backgroundDtoJSON会话资源详情(背景)
detailDto.modelIdString模型id
detailDto.modelNameString模型名称
detailDto.modelIdTypeString模型类型(0:云端数字人,1:本地数字人)
detailDto.localModelInfoJSON本地数字人信息
detailDto.backgroundDtoJSON会话资源详情(背景)
detailDto.backgroundDto.backgroundUrlString背景地址
scriptDtoListJSON前置话术详情
scriptDtoList.scriptTypeString0唤醒词,1开场白,2等待语,3未知问题,4告别词,5打断词,6打断语句,7引导词)
scriptDtoList.scriptContentString前置话术文本
scriptDtoList.ttsContentString前置话术音频
messageString文本提示
successboolean成功标志

响应示例:

{
	"success": true,
	"code": "200",
	"message": "SUCCESS",
	"msg": "SUCCESS",
	"data": {
		"id": "108",
		"conversationName": "Unnamed-18:04",
		"language": "zh",
		"corpId": "1003645",
		"userId": "3959",
		"conversationConfigDto": null,
		"maxConversation": 2,
		"dataModelIsUsed": 1,
		"knowledgeIsUsed": 1,
		"fileIsUsed": 0,
		"thirdIsUsed": 0,
		"isFreedom": 0,
		"asrProvider": null,
		"conversationInfoDto": {
			"id": 109,
			"name": "1",
			"nickName": "",
			"gender": 1,
			"age": 0,
			"height": 0,
			"weight": 0,
			"characters": "",
			"backStory": ""
		},
		"detailDto": {
			"id": 95,
			"conversationId": "108",
			"proportion": "16:9",
			"terminalType": 0,
			"modelId": "321486924406853",
			"modelIdType": 0,
			"imageId": null,
			"sceneId": null,
			"modelName": "Model name",
			"sceneType": 0,
			"background": 1,
			"backgroundDto": {
				"id": 1,
				"backgroundCode": "1591003727513522176",
				"backgroundName": "zuoyi.jpg",
				"backgroundUrl": "/video-server/jpg/1592809647136509954.jpg",
				"fileType": 0,
				"proportion": "16:9",
				"userId": null
			},
			"modelConfig": null,
			"ttsId": "15",
			"ttsName": "guina",
			"ttsConfig": null,
			"ttsUrl": "",
			"ttsVolume": 0,
			"ttsSpeaker": "zhifeng_emo",
			"ttsSpeedRate": 0,
			"ttsPitch": 0,
			"ttsSource": 20,
			"samplePictureUrl": "/model/2023/02/06/c5348a17fac75feb0152a0c599b7af87.png",
			"videoWidth": 1920,
			"videoHeight": 1920,
			"humanProportion": "9:16",
			"humanWidth": 540,
			"humanHeight": 960,
			"humanX": 690,
			"humanY": 120,
			"localModelInfo": null
		},
		"knowledgeDtoList": [],
		"kbConversationDto": null,
		"modelDtoList": [
			{
				"id": 487,
				"conversationId": "108",
				"largeModelType": 0,
				"modelCode": 0,
				"largeName": "chatbot_law",
				"modelId": "1",
				"prompt": "Task: Your name is Zhang San, a real celebrity with a mischievous tone, humor, and a love for joking. Chatting with fans and friends, generating content replies in an oral style. \Requirements for generation: 1. Use my own name, 2. Meet the persona, 3. Prohibit the generation of English content, all must be generated in Chinese. 4. Within 30 words.",
				"botUrl": ""
			}
		],
		"thirdDto": null,
		"scriptDtoList": [
			{
				"id": 2728,
				"conversationId": "108",
				"scriptType": 0,
				"scriptContent": "Els silvrants",
				"ttsContent": null,
				"emotion": "0"
			},
			{
				"id": 2729,
				"conversationId": "108",
				"scriptType": 1,
				"scriptContent": "Hello, welcome to Duix",
				"ttsContent": "https://digital-public-dev.obs.cn-east-3.myhuaweicloud.com/tts-proxy/2024-02-20/1800-_-633043663081836544--FC34641E6EB0A22404C845E219904E81.wav",
				"emotion": "0"
			},
			{
				"id": 2730,
				"conversationId": "108",
				"scriptType": 2,
				"scriptContent": "Wait a moment, I'll think about it",
				"ttsContent": "https://digital-public-dev.obs.cn-east-3.myhuaweicloud.com/tts-proxy/2024-02-20/1630-_-633043667485855744--3F501A3CA51F4DFAFBACE254DD2E3E32.wav",
				"emotion": "0"
			},
			{
				"id": 2731,
				"conversationId": "108",
				"scriptType": 3,
				"scriptContent": "Sorry, I don't quite understand what you mean",
				"ttsContent": "https://digital-public-dev.obs.cn-east-3.myhuaweicloud.com/tts-proxy/2024-02-20/2300-_-633043669830471680--2C5A656A6FBEA2CE09037F21F3DF8434.wav",
				"emotion": "0"
			},
			{
				"id": 2732,
				"conversationId": "108",
				"scriptType": 4,
				"scriptContent": "Sorry, I don't quite understand what you mean",
				"ttsContent": "https://digital-public-dev.obs.cn-east-3.myhuaweicloud.com/tts-proxy/2024-02-20/560-_-633043672326082560--051995577E5C4B5818F952C04A7997E2.wav",
				"emotion": "0"
			},
			{
				"id": 2733,
				"conversationId": "108",
				"scriptType": 5,
				"scriptContent": "Stop talking",
				"ttsContent": null,
				"emotion": "0"
			},
			{
				"id": 2734,
				"conversationId": "108",
				"scriptType": 6,
				"scriptContent": "Okay, you can speak first",
				"ttsContent": "https://digital-public-dev.obs.cn-east-3.myhuaweicloud.com/tts-proxy/2024-02-20/1600-_-633043674196742144--FC70FD95B50E8CEC9D9151905AE13F7F.wav",
				"emotion": "0"
			},
			{
				"id": 2735,
				"conversationId": "108",
				"scriptType": 7,
				"scriptContent": "What is a digital person",
				"ttsContent": "https://digital-public-dev.obs.cn-east-3.myhuaweicloud.com/tts-proxy/2024-02-20/1080-_-633043676541358080--414A4CBCE8B52677F05DAECFD1437BD0.wav",
				"emotion": "0"
			}
		]
	}
}