logo

Webhook Usage Instructions

This document specifies the input and output values for the webhook interface provided by users.

There are two ways to use the interface: 1. Message Trigger Type 2. Task Push Type
Message Trigger Type: Triggered by matching user messages, replacing the ansContent in the webhook with the answer.
Task Push Type: This requires you to have a certain understanding of the task-based conversation feature in your bot management system. The request parameters are the input parameters given by us when calling your interface, and the request result is the information we need you to return in the specified format within the interface.

Webhook (Message Trigger Type)

1. Authentication Method

Formula

sign=SHA1(integrationName&appKey&timestamp)

Where:

  • integrationName: Integration name, the name configured in the webhook
  • key: Authentication key, configured in the webhook
  • timestamp: Timestamp, seconds from '1970-01-01 00:00:00' until now
  • Data is concatenated with '&'

Authentication Data Example

NameValue
integrationNameIntegration One
key221b368d7f5f597867f525971f28ff75
timestamp1496631984

Computer Signature:

sign = sha1("Integration One&221b368d7f5f597867f525971f28ff75&1496631984") ->
96d8271cd705d3f134d215e9b3c27bb73f1132ed

Request URL

  • POST HOST/{relative address}?timestamp={timestamp}&sign={signature}

Request Parameters

URL Parameters

PathTypeRequiredDescription
timestampIntegertrueTimestamp
signStringtrueSignature

Request Body

PathTypeRequiredDescription
integrationNameStringtrueIntegration name
regexStringtrueRegular expression
questionContentStringtrueQuestion content
extraObjectfalseAdditional parameter object
extra.weChatOpenIdStringfalseIf it's WeChat channel, it's the WeChat openId
customerExtraObjectfalseCustom additional object
customerExtra.customerIdIntegerfalseUser ID in customer service system

Request Result

PathTypeDescription
answerContentStringAnswer content

Example

$ curl 'HOST/API?timestamp=1513150103&sign=ab991af4ef65fc6061cf16c19d7d9d1bc1e12dcb' -i -X POST -H 'Content-Type: application/json' -d '{
          "integrationName" : "Integration One",
          "regex" : "[abc]",
          "questionContent" : "Question Content",
          "extra" : {
            weChatOpenId : "wechatId"
          }
        }'
Response
{
  "answerContent" : "This is the answer"
}

Webhook (Task Push Type)

Request Parameters

PathTypeRequiredDescription
taskNodeIdIntegertrueNode ID, the ID where the current task-based conversation matches
sessionIdIntegertrueSession ID, the ID of the conversation record
timestampLongtrueTimestamp
signStringtrueSignature
variablesMap<String, String>falseVariable Map, variables collected in the task tree configuration
customerExtraObjectfalseCustom additional object
customerExtra.customerIdIntegerfalseUser ID in customer service system
customerExtra.callerNumberStringfalseCaller number of voice bot (for voice bot usage)
customerExtra.dialogueDescStringfalseThis field is used for special purposes. It's used to fulfill the requirement of passing custom information from the customer to the bot via webhook. First, in the customer service system, in the custom fields for customers, set a field named "c_cf_dialogueDesc" Then set the value of this field for the customer After that, open the chat plugin and add this field to the path parameters, the format is as follows: https://xxx.udesk.cn/im_client/?web_plugin_id=41597&c_cf_dialogueDesc=******* This way, the system will automatically pass the value of this parameter as a parameter named dialogueDesc into the webhook. Special reminder: Both the customer service system and path parameters are passed with the parameter name "c_cf_dialogueDesc"

Signature

  • Content(key + taskNodeId + sessionId + timestamp)
  • Method(md5Hex)

Where:

  • key: Authentication key, configured in the webhook
  • taskNodeId: Passed in the request body, the ID of the node where the current task tree is located
  • sessionId: Passed in the request body, the identification ID of the current session
  • timestamp: Passed in the request body, timestamp, seconds from '1970-01-01 00:00:00' until now
  • Data is directly concatenated

Authentication Data Example

NameValue
taskNodeId100
sessionId100
keyabcde
timestamp1551510709

Computer Signature:

sign = md5Hex(abcde1001001551510709) ->
9195e2a5c1d84b86dc59819f29a0e300

Request Result

PathTypeDescription
resCodeIntegerResponse code [0 success / -1 failure]
resErrorStringNon-user-level error message
messageMessageUser message
variablesMap<String, String>Variable settings, you can modify the variable table
toTaskNodeIdIntegerJump to task node ID, effective for action of jumping to node
routeTypeIntegerType of jump node (1. Direct trigger 2. Wait for reply)
commandStringAction command

Message

PathTypeRequiredDescription
msgTypeStringtrueMessage type
msgContentObjecttrueMessage content

msg_type

ValueDescriptionCorresponding msgContent
plainPlain textString
richRich textString
selective_tableSelective tableselective_table
selective_listSelective listselective_list
show_productProduct displayshow_product
selective_productProduct selectionshow_product
custom_cardCard messagecustom_card

selective_table

PathTypeDescription
titleStringTitle
rowNumberIntegerNumber of rows
columnNumberIntegerNumber of columns
optionListList<Option>Option list

selective_list

PathTypeDescription
titleStringTitle
optionListList<Option>Option list

show_product

PathTypeDescription
titleStringTitle
showSizeIntegerDefault display quantity
turnFlagIntegerCarousel flag
productListList<OptionalProduct>Product list

custom_card

PathTypeDescription
idIntegerPrimary key
nameStringName
turnFlagIntegerWhether carousel flag 0 No 1 Yes default 0 Functionality for switching groups
showSizeIntegerNumber of card lists displayed, effective when turnFlag=1
titleStringTitle, if not empty, the title card is displayed
cardListList<Object>Card list
cardList[].idIntegerCard ID
cardList[].typeIntegerCard type 1. Rich text card 2. FAQ recommendation list card
cardList[].isHitIntegerWhether the card can be clicked Effective when type=1 0 No 1 Yes
cardList[].hitTypeIntegerCard click effect Effective when type=1&isHit=1 1 Hyperlink 2 Reply message
Reply message refers to providing a string of text to the user in the chat window
cardList[].hitContentStringCard click content Effective when type=1&isHit=1
hitType=1 is the link address hitType=2 is the message content to be replied
cardList[].contentStringRich text specific content Effective when type=1
cardList[].suggestContentStringText of FAQ recommendation cardEffective when type=2
cardList[].suggestListList<Object>List of recommended questions for FAQEffective when type=2
cardList[].suggestList[].idIntegerIdentifier ID of the question.Effective when type=2
cardList[].suggestList[].contentStringContent of the question.Effective when type=2
cardList[].suggestList[].typeIntegerQuestion typeEffective when type=2

optional_product

PathTypeDescription
idIntegerID
nameStringProduct name
imageStringProduct image
urlStringProduct link
infoListList<ProductInfo>Product information

product_info

PathTypeDescription
infoStringText
boldFlagStringBold flag
urlIntegerProduct link
colorStringColor

option

PathTypeDescription
idStringOption ID
valueStringOption value

Example

## appKey: abcde
## sign: md5Hex(abcde1001001551510709)
$ curl 'https://demo/webhook' -i -X POST -H 'Content-Type: application/json' -d '{
  "taskNodeId" : 100,
  "sessionId" : 100,
  "timestamp" : 1551510709,
  "variables" : {
	"city":"Beijing",
	"name":"Li Hao"
   },
  "sign" : "9195e2a5c1d84b86dc59819f29a0e300",
}'
Response
{
  "resCode": 0,
  "message": {
    "msgType": "rich",
    "msgContent": "Content returned by webhook"
  }
}