logo

Interaction Flow

Interaction Diagram

General Udesk API Instructions

Documentation reference: <https://www.udesk.cn/website/doc/apiv2/intro/ > Glossary:

  • urobot, robot: These terms are synonymous and represent the Udesk robot.

Create Customer

Documentation reference: <https://www.udesk.cn/website/doc/apiv2/customers/#_10 >

Create Session (Request Customer Service Assignment)

POST /im/sessions

Request Parameters

Parameter NameTypeRequiredDescription
customer_tokenStringYesUnique identifier for the customer on the application side
assign_typeStringNoExpected assignment type, options are 'robot', 'urobot', 'agent', default is 'robot'
agent_idIntegerNoSpecify the customer service ID for assignment, if provided, ignores assign_type and group_id
group_idIntegerNoSpecify the customer service group ID for assignment, if provided, ignores assign_type
channelStringNoCustom channel
robot_role_idStringNoCustomer role for the Udesk robot
robot_idIntegerNoUdesk robot ID
scene_idIntegerNoUdesk robot corresponding scene ID

customer_token should be consistent with the open_api_token used when creating the customer If neither agent_id nor group_id is specified, and assign_type is 'agent', the system will assign according to the system's rules robot_role_id needs to be set up in the Yunwen side first When assign_type is 'urobot', robot_id and scene_id are required, and robot_id is the robot ID defined in Udesk, see Get urobot List for how to obtain it If the user with this customer_token does not exist in the system Udesk will automatically create a user named API Anonymous User (customer_token) The customer_token in parentheses is the value passed in the parameter

Example

curl  'https://demo.udesk.cn/open_api_v1/im/sessions?email=admin@udesk.cn&sign_version=v2&timestamp=1648432914&sign=8a6wfe5dfd404d11a1e7fd5b7410b05ebdd561a4&nonce=1648632914&customer_token=828cw3d9-6a61-4afe-9efe-2c071d0e7cb3&assign_type=robot&agent_id=397' \
-X POST \
-H 'Content-Type: application/json' \
-d '{
   "agent_id":"397",
   "customer_token":"827wd5r9-7a61-4afe-9efe-2c071d0e9cb2",
   "assign_type":"agent"
}'

Response Data

Attribute NameTypeDescription
codeIntegerExecution result code, 1000 represents success
messageStringWelcome message upon successful assignment, error message upon failure
assign_typeStringAssignment type, 'robot', 'agent', 'urobot'
assign_infoObjectAssignment result information

The structure of assign_info varies depending on the value of assign_type.

Robot Response

When assign_type is 'robot', the structure of assign_info is as follows:

Attribute NameTypeDescription
robot_nameStringRobot name
robot_avatarStringRobot avatar
welcome_messageStringWelcome message
unknow_messageStringUnknown answer message

Example

{
  "code": 1000,
  "message": "Request successful",
  "assign_type": "robot",
  "assign_info": {
    "robot_name": "Udesk Customer Service Robot",
    "robot_avatar": "https://rd-dota.udesk.cn/entry/images/agent-avatar-3e6a68e1e1fcb4db653d9e93263f7946.png",
    "welcome_message": "<p>Hello, I am the intelligent customer service robot, I can answer your related business questions, ask me anything! It's my pleasure to serve you!</p><p><br/></p>",
    "unknow_message": "<p>I'm sorry, I can only answer common business-related questions! This question is currently out of my knowledge range, I will continue to work hard to learn! You can also ask me with simpler language...Maybe I can answer you...</p>"
  }
}

When assign_type is 'urobot', the structure of assign_info is as follows:

Attribute NameTypeDescription
sessionIdIntegerSession ID
logIdIntegerLog ID of this entry
leadingWordStringLead-in phrase
helloWordStringWelcome phrase
robotNameStringRobot name
logoUrlStringRobot avatar
topAskObjectList of common questions

Example

Request

curl  'https://test.udesk.cn/open_api_v1/im/sessions?email=admin@udesk.cn&timestamp=1494474404&sign=6892f1b794071c260e1b1eac15df588fc919c9e86eb742affaa742ad6c03cb52&nonce=2d931510-d99f-494a-8c67-87feb05e1594&sign_version=v2' \
-X POST \
-H 'Content-Type: application/json' \
-d '{
  "customer_token":"test20191018224601",
  "assign_type":"urobot",
  "scene_id":39,
  "robot_id":12362
}'

Return

{
  "code": 1000,
  "message": "Request successful",
  "assign_type": "urobot",
  "assign_info": {
    "sessionId": 23702,
    "logId": 55392,
    "robotName": "Test",
    "logoUrl": null,
    "leadingWord": "Hello, it's my pleasure to serve you!",
    "helloWord": "Hello, it's my pleasure to serve you!",
    "topAsk": [
      {
        "quesitionType": "Question Type 1",
        "quesitionTypeId": 2,
        "optionsList": [
          {
            "quesition": "Question 1",
            "quesitionId": 2122
          },
          {
            "quesition": "Question 2",
            "quesitionId": 3222
          }
        ]
      }
    ]
  }
}

Agent Response

When assign_type is 'agent', the structure of assign_info is as follows:

Attribute NameTypeDescription
im_sub_session_idIntegerSession ID
countIntegerQueue position
queueStringQueue name
agent_idIntegerAssigned customer service ID
agent_nameStringAssigned customer service name
agent_avatarStringCustomer service avatar URL
survey_optionsObjectSatisfaction survey settings

Example

Request
curl  'https://test.udesk.cn/open_api_v1/im/sessions?email=admin@udesk.cn&timestamp=1494474404&sign=6892f1b794071c260e1b1eac15df588fc919c9e86eb742affaa742ad6c03cb52&nonce=2d931510-d99f-494a-8c67-87feb05e1594&sign_version=v2' \
-X POST \
-H 'Content-Type: application/json' \
-d '{
  {
  "customer_token":"test20191018224601",
  "assign_type":"agent"
}
}'
Correct Return
{
  "code": 1000,
  "message": "Request successful",
  "assign_type": "agent",
  "assign_info": {
    "im_sub_session_id": 1234,
    "count": 0,
    "agent_id": 3,
    "agent_name": "Tom",
    "agent_avatar": "",
    "survey_options": "See survey_options section",
  }
}
In Queue Return
{
  "code": 2001,
  "message": "The current customer service is busy, you are in the 3rd place in line.",
  "assign_type": "agent",
  "assign_info": {
    "count": 3,
    "queue": "queue:company:1:agent:486"
  }
}
Assignment Threshold
{
  "code": 2001,
  "message": "Customer service assignment in progress!",
  "assign_type": "agent",
  "assign_info": {
    "count": 0,
  }
}
Customer Service Offline
{
  "code": 2002,
  "message": "There is no customer service online at the moment",
  "assign_type": "agent",
  "assign_info": {
    "count": 0,
  }
}
survey_options
"survey_options":
    "enabled": true,   # Whether it is open
    "name": "Satisfaction Evaluation",
    "title": "How do you evaluate this service?",  # Prompt shown to the customer
    "desc": "Thank you for your support, in order to better serve you, please evaluate this service (reply with a letter) ",  # Weibo API satisfaction evaluation guide language
    "remark_enabled": true,  # Whether to allow remarks
    "remark": "You can leave a remark for the evaluation", # Evaluation remark prompt
    "show_type": String text|exp| expression|star  // Show type
    text: {  // Optional, when show_type is text display
        default_option_id:
        options: [{
          id:
          text: Very satisfied|Satisfied|Average|Unsatisfied|Very unsatisfied (can be modified, displayed in BI)
          desc: Cannot be modified
          tags: "tag1,tag2"  // Custom evaluation tags such as: Good service, strong professionalism, good attitude...
          remark_option: hide|required|optional
          }]
      },
      expression: { // Optional, when show_type is expression display
        default_option_id:
        options: [{
          id:
          text: Satisfied|Average|Unsatisfied
          tags: "tag1,tag2"
          remark_option: hide|required|optional
          }]
      },
      star: {  // Optional, when show_type is star display
        default_option_id:
        options: [{
          id:
          text: Satisfied|Average|Unsatisfied
          tags: "tag1,tag2"
          remark_option: hide|required|optional
          }]
      },
    "options": [    # Compatible mode, evaluation options / id corresponds to /im_sessions/survey option_id
      {
        "id": 36,
        "text": "Super satisfied",
        "enabled": true
      },
      {
        "id": 37,
        "text": "Satisfied",
        "enabled": true
      },
      {
        "id": 38,
        "text": "Average",
        "enabled": true
      },
      {
        "id": 39,
        "text": "Unsatisfied",
        "enabled": true
      },
      {
        "id": 40,
        "text": "Very unsatisfied",
        "enabled": true
      }
    ],
    "methods": [  # Satisfaction evaluation methods
      {
        "id": 7,
        "flag": "after_session",
        "text": "Pop up after the session ends",
        "enabled": true
      },
      {
        "id": 74,
        "flag": "agent_invite",
        "text": "Customer service actively invites",
        "enabled": true
      },
      {
        "id": 1485,
        "flag": "customer_invite",
        "text": "Customer actively evaluates satisfaction (only supported by web and Android/iOS SDK)",
        "enabled": true
      }
    ],
    "resolved_enabled": true,
    "resolved_options": {
      "title": "Has your problem been resolved?",
      "options": [
      {
        "option_select": true,
        "option_name": "Resolved"
      },{
        "option_select": true,
        "option_name": "Unresolved"
      }],
      "value": "0" # Option default value
    }

Close Session

The client actively closes the specified session. DELETE /im/sessions/:session_id

Request Parameters

Parameter NameTypeRequiredDescription
session_idIntYesSession ID, in URL

Response Data

Attribute NameTypeDescription
codeIntExecution result code, 1000 represents success

Example

$ curl -XDELETE 'https://demo.udesk.cn/open_api_v1/im/sessions/123?session_id=123&email=admin@udesk.cn&sign_version=v2&timestamp=1645198019&sign=925f7a1a4ec944f52d59d33a9e35cb6e2478e589&nonce=1648194019'

Delete Session

Delete a session that has been closed.

Request Method

DELETE /im/sessions/destroy_session

Request Parameters (Query String)

Parameter NameRequiredTypeDescription
start_timeYesStringExample "2022-05-19 19:50:33"
end_timeYesStringExample "2022-05-19 20:50:33"
customer_idNoIntIf this parameter is passed, only the conversation records of the customer in the corresponding time period will be deleted; if not, all conversation records in the corresponding time period will be deleted

The start_time and end_time query the creation time of the session.

Response Data

Attribute NameTypeDescription
codeIntExecution result code, 1000 represents success

Example

Request

curl -X DELETE 'https://test.udesk.cn/open_api_v1/im/sessions/destroy_session?email=admin@udesk.cn&timestamp=1494474404&sign=6892f1b794071c260e1b1eac15df588fc919c9e86eb742affaa742ad6c03cb52&nonce=2d931510-d99f-494a-8c67-87feb05e1594&sign_version=v2&start_time=2022-05-19%2019%3A50%3A33&end_time=2022-05-19%2020%3A50%3A33&customer_id=123123'

Response

{
"code": 1000
}

Abandon Queue

The client actively closes and abandons the specified queue. DELETE /im/sessions/close_queue

Request Parameters

Parameter NameTypeRequiredDescription
customer_tokenStringYesUnique customer identifier on the application side.
queueStringYesQueue data returned when creating a session and queuing.

Response Data

Attribute NameTypeDescription
codeIntExecution result code, 1000 represents success.

Example

$ curl -XDELETE 'https://test.udesk.cn/open_api_v1/im/sessions/close_queue?customer_token=123qwe&queue=queue:company:1:agent:486&email=admin@test.com&sign=61b00dedbc749691232386fed059898af61b92c&timestamp=1526293384'

Send Message Preview

The API sends a message preview from the customer to the agent (the assign_type of the session needs to be agent). PUT /im/sessions/:session_id/message_preview

Note: This interface requires separate activation. This interface has its own frequency limit: 3 times per session_id per second.

Request Parameters

Parameter NameTypeRequiredDescription
session_idIntYesSession ID, in URL.
contentStringYesPreview content text, will clear the preview if it's an empty string, in request body.

Ways to clear the message preview:

  1. The preview content will be automatically cleared when the agent receives a message from the customer.
  2. When calling this interface with an empty string in content, it will also clear the message preview for the corresponding session.

Response Data

Attribute NameTypeDescription
codeIntExecution result code, 1000 represents success.

Error Response

Code ValueMessage Description
2062Session not found or closed.
2065Interface not activated.

Example

Request

curl 'https://test.udesk.cn/open_api_v1/im/sessions/1/message_preview?email=admin@udesk.cn&timestamp=1494474404&sign=6892f1b794071c260e1b1eac15df588fc919c9e86eb742affaa742ad6c03cb52&nonce=2d931510-d99f-494a-8c67-87feb05e1594&sign_version=v2' \
-X PUT \
-H 'Content-Type: application/json' \
-d '{"content": "Test preview"}'

Response

{
"code": 1000
}

Send Message

The API allows the customer to send a message to the agent (the assign_type of the session needs to be agent). POST /im/messages

Note: For messages sent to the robot, the type parameter currently only supports 'message'.

Request Parameters

Parameter NameTypeRequiredDescription
customer_tokenStringYesUnique customer identifier on the application side.
im_sub_session_idIntYes1. Session ID
2. ID is 0 or empty for robot questions
3. ID is -1 for Udesk robot questions
4. -2 for IM workbench messages
5. -3 for messages sent while queuing
message_idStringYesMessage ID/company message unique identifier (Udesk robot can omit)
Only letters, numbers, "_", "-", special characters are not allowed
typeStringNoMessage type, 'message', 'image', 'audio', 'rich', default is 'message'
dataObjectYesMessage content (see Message Content Format)
robot_idIntNoUdesk robot ID (required for Udesk robot)
scene_idIntNoUdesk robot corresponding scene ID (required for Udesk robot)
urobot_session_idIntNoUdesk robot corresponding session ID
agent_idIntNoSpecify the agent ID to assign (use with im_sub_session_id=-2)
group_idIntNoSpecify the agent group ID to assign (use with im_sub_session_id=-2)

Response Data

Attribute NameTypeDescription
codeIntExecution result code, 1000 represents success

Error Response (when assign_type is 'robot')

Code ValueMessage Description
19200Session not found or closed
22062Missing parameters

Example

Request

curl 'https://test.udesk.cn/open_api_v1/im/messages?email=admin@udesk.cn&timestamp=1494474404&sign=6892f1b794071c260e1b1eac15df588fc919c9e86eb742affaa742ad6c03cb52&nonce=2d931510-d99f-494a-8c67-87feb05e1594&sign_version=v2' \
-X POST \
-H 'Content-Type: application/json' \
-d '{
  "customer_token":"1234123123",
  "im_sub_session_id":11,
  "message_id":"1",
  "type":"image",
  "data":{
      "content": "Don’t just walk by, come check out our company’s promotional products! You won’t want to miss these great deals! <a href=\"https://xxx.com/1.png\">hotsale.com</a>"
    }
}'

Response

{
"code": 1000
}

Get Customer Offline Unread Messages

Get the number of offline unread messages and details sent by the agent to the customer in the specified session. GET /im/messages/unread_customer_offline

Request Parameters

Parameter NameTypeRequiredDescription
im_sub_session_idIntYesSession ID
customer_idIntYesCustomer ID
app_idIntNoSDK app_id (required for SDK channel sessions)

Response Data

Attribute NameTypeDescription
codeIntExecution result code, 1000 represents success
countIntNumber of unread messages
unread_messagesArrayMessage collection, see Message Content Format for details

Request Example

curl https://demo.udesk.cn/open_api_v1/im/messages/unread_customer_offline?im_sub_session_id=1419314&customer_id=5855308&email=admin@udesk.cn&sign_version=v2&timestamp=1646827326&sign=06f59041bbbec54bd2a0b15b45672c9f43539135&nonce=1646827326

Response Data

Attribute NameTypeDescription
codeIntExecution result code, 1000 represents success
countIntNumber of unread messages
unread_messagesArrayMessage collection, see Message Content Format for details

Request Example

curl https://demo.udesk.cn/open_api_v1/im/messages/unread_customer_offline?im_sub_session_id=1419314&customer_id=5855308&email=admin@udesk.cn&sign_version=v2&timestamp=1646827326&sign=06f59041bbbec54bd2a0b15b45672c9f43539135&nonce=1646827326

Modify Customer Online Status

Modify the customer's online status. POST /im/customer_online_state

Request Parameters

Parameter NameTypeRequiredDescription
customer_tokenStringYesOpenApi unique customer identifier
stateIntYesOffline: 0; Online: 1

Response Data

Attribute NameTypeDescription
codeIntExecution result code, 1000 represents success

Request Example

curl https://demo.udesk.cn/open_api_v1/im/messages/unread_customer_offline?im_sub_session_id=1419314&customer_id=5855308&email=admin@udesk.cn&sign_version=v2&timestamp=1646827326&sign=06f59041bbbec54bd2a0b15b45672c9f43539135&nonce=1646827326

Modify Agent Message Read Status

Modify the read status of agent messages. POST /im/messages/read_messages

Request Parameters

Parameter NameTypeRequiredDescription
session_idIntYesSession ID
message_idsArrayYesArray of message IDs

Response Data

Attribute NameTypeDescription
codeIntExecution result code, 1000 represents success

Request Example

curl https://demo.udesk.cn/open_api_v1/im/messages/read_messages?session_id=1234&message_ids=['123','123456']&email=admin@udesk.cn&sign_version=v2&timestamp=1646827326&sign=06f59041bbbec54bd2a0b15b45672c9f43539135&nonce=1646827326

Get Customer Sensitive Word Configuration

Get the customer's sensitive word configuration. GET /im/im_sensitive_words

Response Data

Attribute NameTypeDescription
codeIntExecution result code, 1000 represents success
customer_words_stringStringConfigured sensitive words, separated by commas (e.g., "a,b,c,d")
customer_is_openInt1 for enabled, 0 or empty for disabled

Request Example

curl https://demo.udesk.cn/open_api_v1/im/im_sensitive_words?email=admin@udesk.cn&sign_version=v2&timestamp=1646827326&sign=06f59041bbbec54bd2a0b15b45672c9f43539135&nonce=1646827326

Get Agent Unread Messages

Agent unread messages are messages successfully sent to the agent by the customer that the agent has not yet read. Get the number of unread messages for the specified session and the number of unhandled messages left within 7 days. GET /im/messages/agent_unread_messages

Request Parameters

Parameter NameTypeRequiredDescription
agent_idsArrayYesAgent ID array, limited to 30

Response Data

Attribute NameTypeDescription
codeIntExecution result code
resultsArrayResult set
results.agent_idIntAgent ID
results.unread_session_message_numIntNumber of unread messages
results.unsolved_leave_message_numIntNumber of unhandled messages left within 7 days

Request Example

curl https://demo.udesk.cn/open_api_v1/im/messages/agent_unread_messages?email=admin@udesk.cn&sign_version=v2&timestamp=1646817998&sign=7ab7fb49d9c32ea246504b3af75a9w65210bca87&nonce=1646827998&agent_ids[]=13

Send Customer Message Read Status

Request Method

Send the customer message read status. POST {Receiving Message URL}

The Receiving Message URL should be set in the Admin->Settings->Channel Management->Interface Messages.

Request Parameters

Parameter NameTypeRequiredDescription
session_idIntYesSession ID
message_idsArrayYesMessage ID list

Response Data

Return HTTP status code 200, and the response body should be empty. Note:

  • Please respond within 5 seconds; otherwise, UDesk will consider the send timeout.
  • If there are 10 timeouts within 60 seconds, UDesk will stop calling the address for 60 seconds starting from the last timeout.

Reply Message Notification

Request Method

The agent pushes a message to the API customer. POST {Receiving Message URL}

The push format is JSON. The Receiving Message URL should be set in the Admin->Settings->Channel Management->Interface Messages.

Request Parameters

Parameter NameTypeRequiredDescription
customer_tokenStringYesUnique identifier for the customer on the application side
assign_typeStringYesAssignment type, 'robot', 'agent', 'urobot'
messagesArrayYesMessages
The format of the messages object varies depending on the assign_type.
When assign_type is 'robot', the messages format is as follows:
messages: Array
  type: Message type
  message_id: Message ID, String
  data: Message content
    question_id: 0 for greetings library, non-0 for Q&A; non-0 can evaluate the usefulness of Q&A
    question_title: Question content, String
    answer: Text of the question answer, String
    gus_list: Question guidance list
      - question_title: Question content, String
    relate_list: Related question list
      - question_title: Question content, String
    third_url: Related recommended link
      url: Link address, String
{
  "customer_token": "axb",
  "assign_type": "robot",
  "messages": [{
    "type": "message",
    "message_id": "f862f80d-89aa-4f31-92d9-ccd4fcacffcf",
    "data": {
      "question_id": 210530,
      "question_title": "What is the company's business?",
      "answer": "Hi, we are a company that does cloud customer service. Different developments can communicate and manage users on Weibo and WeChat web.",
      "gus_list": [
        {"question_title": "What business do you do"},
        {"question_title": "What business does your company have"}
      ],
      "relate_list": [
        {"question_title": "Where is the company located"},
        {"question_title": "What are the contact details"}
      ],
      "third_url": {
        "url": "https://www.udesk.cn"
      }
    }
  }]
}

When assign_type is 'urobot', the messages format is as follows:

messages: Object
  sessionId: Session ID, String
  logId: Message ID
  aid: Answer ID
  ansContent: Answer content
  ansType: Answer type (1 for normal answer, 2 for answer and suggestion list, 3 for suggestion list, 4 for returning greetings, 6 for unknown speech, 8 for sensitive words)
  hitQuestion: Question content
  suggestQuestionList: Suggestion list
  flowId: Current process ID
  flowTitle: Current process title
  flowContent: Current process answer
{
  "sessionId": 1835244,
  "logId": 3574331,
  "aid": 12,
  "ansContent": "Appeal process",
  "ansType": 1,
  "hitQuestion": "Account appeal",
  "suggestQuestionList": [
    {
      "id": 434,
      "content": "Question 1",
      "type": 1
    }
  ]
}

When assign_type is 'agent', the messages format is as follows:

messages: # Array
  type: Message type, 'message', 'image', 'audio', 'video', 'file', 'rich(rich text message)', 'struct(structured conversation)', 'survey(satisfaction evaluation related events)', 'transfer(transfer event)', 'info_transfer(transfer event, attribute distinction)'
  message_id: Message ID
  agent_id: Agent ID
  agent_name: Agent name
  agent_avatar: Agent avatar
  im_sub_session_id: Session ID
  message_created_at: Message creation time "20170711 09:52:11"
  data: # Same as the content of the sent message
    font: Font, only supports message
    content: Content
{
  "customer_token": "axb",
  "assign_type": "agent",
  "messages": [
    {
      "type": "start_session",
      "message_id": "xxxxx",
      "agent_id": 1,
      "agent_name": "TOM",
      "agent_avatar": "https://123.com/1.png",
      "im_sub_session_id": 3,
      "message_created_at": "20170711 09:52:11",
      "data": {
        "content": "Dialogue started"
      }
    },
    {
      "type": "message",
      "message_id": "xxxxx",
      "agent_id": 1,
      "agent_name": "TOM",
      "agent_avatar": "https://123.com/1.png",
      "im_sub_session_id": 3,
      "message_created_at": "20170711 09:52:12",
      "data": {
        "font": "Font, only supports message",
        "content": "Hello, what can I help you with?",
      }
    },
    {
      "type": "rich",
      "message_id": "xxxxx",
      "agent_id": 1,
      "agent_name": "TOM",
      "agent_avatar": "https://123.com/1.png",
      "im_sub_session_id": 3,
      "message_created_at": "20170711 09:52:13",
      "data": {
        "content": "Our company's promotional products are hot-selling. Don't miss it. <a href=\"https://xxx.com/1.png\">Hot sale.com</a>",
      }
    },
    {
      "type": "close",
      "message_id": "xxxxx",
      "agent_id": 1,
      "agent_name": "TOM",
      "agent_avatar": "https://123.com/1.png",
      "im_sub_session_id": 3,
      "message_created_at": "2018-01-01 00:00:00",
      "data": {
        "close_type": "normal(normal)|redirect(redirect)|force(force)"
        "content": "Close the session",
        "survey_options": "See survey_options section",
      }
    }
  ]
}

Response Data

Return HTTP status code 200, and the response body should be empty. Note:

  • Please respond within 5 seconds; otherwise, UDesk will consider the send timeout.
  • If there are 10 timeouts within 60 seconds, UDesk will stop calling the address for 60 seconds starting from the last timeout.

Message Content Format

Type and Supported List

TypeTypeMeaningSendReceiveRemarks
messagemessageText message✓✓
messageimageImage message✓✓
messageaudioVoice message✓×Supports amr format
messagevideoVideo message✓×Supports mp4 format
messagefileFile message✓×
messagerichRich text message✓✓Supports common html tags
messagestructStructured conversation message××Not supported yet
eventstart_sessionDialogue start×✓Pushed to the customer when the dialogue starts
eventtransferTransfer event×✓Pushed to the customer when they are transferred, customers need to modify im_sub_session_id to the new one
eventinfo_transferTransfer event with display content××Displayed to the customer when they are transferred
eventcloseSession close event✓✓Pushed to the customer when the session is closed
eventsurveySatisfaction evaluation related events××Only displayed in the customer service IM workbench
eventactive_guestCustomer service initiating conversation event××Only supports web visitors
eventinfo_appointCustomer service assigning customer event××Not supported yet
eventformSend form message event××Not supported yet
eventform_receivedAccept form message event××Not supported yet
eventinfoPre-inquiry form is_receive: false××Only for customer service display
eventrobot_transferRobot transfers the conversation××Only for customer service display

Note: Messages that are not supported/temporarily not supported/only for customer service display should not be displayed and processed in the client.

Message Content Details

Depending on the type, the structure of the data field also varies:

# Ordinary message
type: 'message'
data:
    font: Font format, optional, for example
    content: Text content  Note: Text content can contain rich text html tags
# Image message
type: 'image'
data:
    content: url
# Voice message
type: 'audio'
data:
    content: url
    filename: 'football.mp4' #
    filesize: "4.3M"
    duration: 200       # Voice duration, may not have # Unit is seconds
type: 'video'  # Only supports mp4
data:
    content: url
    filename: 'football.mp4' # File name
    filesize: "4.3M"    # File size
type: 'rich'  # Supported
data:
    content: <p>Hello, Xiao Ya customer service is happy to serve you. May I help you with anything?</p>
# type: struct  Structured message, currently only supports web/sdk
# Related documentation <https://www.udesk.cn/website/doc/apiv1/im/#im_2>
# start_session Session starts, usually pushed in an array, followed by a welcome message message
type: "start_session",
data:
    content: "Dialogue started"
# transfer The session is transferred, usually pushed in an array, followed by the transfer content message such as: 'Session transfer successful, customer service xx is serving you'
type: "transfer",
data:
    content: "Session transfer"
type: "info_transfer",
data:
    content: "Customer service Jerry213 transfers the session"
type: "close",
data:
    content: "Session closed"

Robot Q&A Evaluation

Parameters

Parameter NameTypeRequiredDescription
customer_tokenStringYesUnique identifier for the customer on the application side
message_idStringYesMessage ID of the robot's answer to be evaluated
question_idIntegerYesQuestion ID
usefulBooleanYesWhether the question is useful

Return

Attribute NameTypeDescription
codeIntExecution result code, 1000 represents success

Urobot Robot Session Evaluation (Urobot Usage)

POST /im/sessions/robot_survey

Parameters

Attribute NameTypeRequiredDescription
customer_tokenStringYesUnique identifier for the customer on the application side
im_sub_session_idIntYesSession ID
option_idIntYesEvaluation option ID (2: Satisfied, 3: Average, 4: Unsatisfied)
remarkStringNoEvaluation remark
robot_idIntYesUdesk robot ID (obtained in the system IM Robot module)
scene_idIntYesUdesk robot corresponding scene ID

Return Data

Attribute NameTypeDescription
codeIntExecution result code, 1000 represents success
messageStringReturn message

Example

Request

curl https://demo.udesk.cn/open_api_v1/im/sessions/robot_survey?email=admin@udesk.cn&timestamp=1494474404&sign=6892f1b794071c260e1b1eac15df588fc919c9e86eb742affaa742ad6c03cb52&nonce=2d931510-d99f-494a-8c67-87feb05e1594&sign_version=v2
 \
-X POST \
-H 'content-type: application/json' \
-d '{
"customer_token":"1234121123123",
"im_sub_session_id":101,
"option_id":2,
"robot_id":1101,
"scene_id":39,
"remark":"Very good"
}'

Return

{
"code": 1000,
"message": "Thank you for your feedback"
}

Session Evaluation (Evaluating Customer Service)

POST /im/sessions/survey

Request Parameters

Attribute NameRequiredTypeDescription
im_sub_session_idYesIntSession ID
option_idYesIntEvaluation option ID
remarkNoStringEvaluation remark
resolved_state_v2NoIntWhether resolved option value (0: option 1 indicates resolved, 1: option 2 indicates unresolved)
  • Note: The range of option_id values refers to the evaluation IDs returned when creating a session. Specifically, refer to the survey_options example to determine the type of show_type returned when creating a session, and the id values range from the current satisfaction type's options parameter.

Return Data

Attribute NameTypeDescription
codeIntExecution result code, 1000 represents success

Example

Request

curl https://demo.udesk.cn/open_api_v1/im/sessions/robot_survey?email=admin@udesk.cn&timestamp=1494474404&sign=6892f1b794071c260e1b1eac15df588fc919c9e86eb742affaa742ad6c03cb52&nonce=2d931510-d99f-494a-8c67-87feb05e1594&sign_version=v2
 \
-X POST \
-H 'content-type: application/json' \
-d '{
  "im_sub_session_id":1001001000,
  "option_id":"111"
}'

Return

{
"code": 1000,
"message": "Thank you for your feedback"
}

Answer Evaluation (Only for Urobot Usage)

POST /im/messages/answer_survey

Request Parameters

Attribute NameTypeRequiredDescription
customer_tokenStringYesUnique identifier for the customer on the application side
message_idIntegerYesMessage ID where the answer is located
im_sub_session_idIntegerYesSession ID
option_idIntegerYesEvaluation option ID (1: Satisfied, 2: Unsatisfied, default is satisfied)
robot_idIntegerYesUdesk robot ID
scene_idIntegerYesUdesk robot corresponding scene ID

Return Data

Attribute NameTypeDescription
codeIntExecution result code, 1000 represents success
messageStringReturn message

Example

Request

curl https://demo.udesk.cn/open_api_v1/im/messages/answer_survey?email=admin@udesk.cn&timestamp=1494474404&sign=6892f1b794071c260e1b1eac15df588fc919c9e86eb742affaa742ad6c03cb52&nonce=2d931510-d99f-494a-8c67-87feb05e1594&sign_version=v2
 \
-X POST \
-H 'content-type: application/json' \
-d '{
  "customer_token":"123411111",
  "message_id":111,
  "im_sub_session_id":11,
  "option_id":1,
  "robot_id":12,
  "scene_id":1
}'

Return

{
"code": 1000,
"message": "Thank you for your feedback"
}

Flow Question Interface

POST /im/messages/flow Only for Urobot usage

Request Parameters

Attribute NameTypeRequiredDescription
customer_tokenStringYesUnique identifier for the customer on the application side
im_sub_session_idIntYesSession ID
flow_idIntYesSelected flow_id
robot_idIntYesUdesk robot ID
scene_idIntYesUdesk robot corresponding scene ID

How to get the flow_id: When you receive a push message with a messages.flowContent field and tags that contain data-type="2", you can call this interface. For example:

<p><b data-type="2" class="flow-item" data-id="81" data-robotid="54">Flow subitem A jumps to subitem -1</b></p><p>Flow subitem A jumps to subitem -2<br/></p>
<p><b data-type="1" class="flow-item" data-id="307" data-robotid="54">Classification question A</b></p><p>Classification question B</p>

When you click on Flow subitem A jumps to subitem -1, you can use flow_id=81 to call this interface.

Return Data

Attribute NameTypeDescription
codeIntExecution result code, 1000 represents success

The push data refers to the return data of the Urobot reply message notification interface.

Example

Request

curl https://demo.udesk.cn/open_api_v1/im/messages/flow?email=admin@udesk.cn&timestamp=1494474404&sign=6892f1b794071c260e1b1eac15df588fc919c9e86eb742affaa742ad6c03cb52&nonce=2d931510-d99f-494a-8c67-87feb05e1594&sign_version=v2
 \
-X POST \
-H 'content-type: application/json' \
-d '{
  "customer_token":"1234121123123",
  "messgae_id":1001,
  "im_sub_session_id":17001700,
  "option_id":1,
  "robot_id":1,
  "scene_id":1
}'

Return

{
"code": 1000
}

User Click Behavior Interface

POST /im/messages/hit

Request Parameters

Attribute NameTypeRequiredDescription
customer_tokenStringYesUnique identifier for the customer on the application side
im_sub_session_idIntYesSession ID
message_idIntYesMessage ID of the robot's answer
robot_idIntYesRobot ID
questionIntNoQuestion content
query_typeIntYesClick type

Return Data

Attribute NameTypeDescription
codeIntExecution result code, 1000 represents success

Example

Request

curl https://demo.udesk.cn/open_api_v1/im/messages/hit?email=admin@udesk.cn&timestamp=1494474404&sign=6892f1b794071c260e1b1eac15df588fc919c9e86eb742affaa742ad6c03cb52&nonce=2d931510-d99f-494a-8c67-87feb05e1594&sign_version=v2
 \
-X POST \
-H 'content-type: application/json' \
-d '{
  "customer_token":"111",
  "message_id":1,
  "im_sub_session_id":10,
  "robot_id":1,
  "scene_id":1,
  "question_id":1,
  "query_type":1
}'

Return

{
"code": 1000
}

Get Urobot List

GET /im/urobots

Return Data

Attribute NameTypeDescription
codeIntExecution result code, 1000 represents success
messageStringReturn result information
urobot_listArrayDetailed information about the robot list

urobot_list

Attribute NameTypeDescription
idIntUrobot robot ID
nameStringRobot name
logoStringRobot avatar
scene_listArraySuitable scene information, including id (scene ID), name (scene name)
created_atStringTime the robot was created

Example

Request

curl https://demo.udesk.cn/open_api_v1/im/urobots?email=admin@udesk.cn&timestamp=1494474404&sign=6892f1b794071c260e1b1eac15df588fc919c9e86eb742affaa742ad6c03cb52&nonce=2d931510-d99f-494a-8c67-87feb05e1594&sign_version=v2

Return

{
  "code": 1000,
  "message": "Request successful",
  "urobot_list": [
    {
      "id": 2,
      "name": "Default Robot",
      "logo": "",
      "scene_list": [
        {
          "id": 114,
          "name": "Default Scene"
        },
        {
          "id": 116,
          "name": "System Default Scene"
        }
      ],
      "created_at": "2018-01-23T10:55:20.000+08:00"
    },
    {
      "id": 3,
      "name": "Test",
      "logo": "",
      "scene_list": [
        {
          "id": 120,
          "name": "System Default Scene"
        }
      ],
      "created_at": "2018-02-05T11:25:30.000+08:00"
    }
  ]
}

Transfer to Human Statistics Interface (Urobot Usage)

POST /im/sessions/transfer_survey

Request Parameters

Parameter NameTypeRequiredDescription
im_sub_session_idIntYesSession ID
robot_idIntYesRobot ID
scene_idIntYesRobot scene ID

Return Data

Attribute NameTypeDescription
codeIntStatus
messageStringRequest result

Example

Request

curl https://demo.udesk.cn/open_api_v1/im/sessions/transfer_survey?email=admin@udesk.cn&timestamp=1494474404&sign=6892f1b794071c260e1b1eac15df588fc919c9e86eb742affaa742ad6c03cb52&nonce=2d931510-d99f-494a-8c67-87feb05e1594&sign_version=v2
 \
-X POST \
-H 'content-type: application/json' \
-d '{
  "im_sub_session_id":"111",
  "robot_id":1,
  "scene_id":10
}'

Return

{
    "code": 1000,
    "message": "success"
}

Query Queue Status

GET /im/queue_status

Request Parameters

Parameter NameRequiredDescription
customer_tokenYesUnique identifier for the customer on the application side

Return Data

Attribute NameTypeDescription
codeIntExecution result code, 1000 represents success
statusStringQueue status, 'In queue', 'Not in queue', 'In session', 'Assigning'
countIntQueue position

Example

Request

curl https://demo.udesk.cn/open_api_v1/im/queue_status?email=admin@udesk.cn&timestamp=1494474404&sign=6892f1b794071c260e1b1eac15df588fc919c9e86eb742affaa742ad6c03cb52&nonce=2d931510-d99f-494a-8c67-87feb05e1594&sign_version=v2
&customer_token=1234121123123

Return

{
    "code": 1000,
    "status": "Not in queue",
    "count": 0
}

Query Customer Status

Used to check if a customer is in a session, supports querying with customer_token, web_token, or sdk_token. GET /im/customer_status

Request Parameters

Parameter NameRequiredDescription
customer_tokenNoOpenApi unique customer identifier
web_tokenNoWeb unique customer identifier
sdk_tokenNoSDK unique customer identifier
session_keyNoWhen web_token exists, supports different session statuses for multiple sessions

Note: One of customer_token, web_token, or sdk_token must be present, taking the first parameter with a value in order.

Response Data

Attribute NameTypeDescription
codeIntegerExecution result code, 1000 represents success
status_codeInteger0, 1, 2, 3
statusString'No session', 'In session', 'In queue', 'Invalid customer'

Example

Request

curl https://demo.udesk.cn/open_api_v1/im/customer_status?email=admin@udesk.cn&timestamp=1494474404&sign=6892f1b794071c260e1b1eac15df588fc919c9e86eb742affaa742ad6c03cb52&nonce=2d931510-d99f-494a-8c67-87feb05e1594&sign_version=v2
&customer_token=1234121123123&session_key=179306259

Response

{
    "code": 1000,
    "status_code": 0,
    "status": "No session"
}

Query Agent Status

View the online status of all current agents. GET /im/agent_status

Request Parameters

Parameter NameRequiredDescription
group_idNoIf specified, only view agents in the given group

If not specified, all agents are returned.

Response Parameters

Attribute NameTypeDescription
codeIntegerExecution result code, 1000 represents success, 11012 if the specified group does not exist
agentsArrayReturns agent data, see Agent Status Details for more information

Agent Status Details

Attribute NameTypeDescription
idInteger
nameStringAgent's name
nickStringAgent's nickname, used to display to customers; if empty, the agent's name is displayed
avatarStringAgent's avatar
im_statusStringOnline status: online/busy/offline (Online/Busy/Offline)
im_custom_statusStringCustom status, only valid when im_status is busy
im_session_numIntegerCurrent number of customers being served, only valid when im_status is online/busy, may be 0, has no significant meaning
im_max_join_numIntegerMaximum number of customers an agent can serve, only valid when im_status is online/busy, may be 0, has no significant meaning

Example

Request

curl https://demo.udesk.cn/open_api_v1/im/agent_status?email=admin@udesk.cn&timestamp=1494474404&sign=6892f1b794071c260e1b1eac15df588fc919c9e86eb742affaa742ad6c03cb52&nonce=2d931510-d99f-494a-8c67-87feb05e1594&sign_version=v2
&group_id=37540

Response

{
    "code": 1000,
    "agents": [
        {
            "id": 43230,
            "name": "Tom",
            "im_nick": "Tom",
            "avatar": "",
            "profile": "all",
            "im_status": "offline",
            "im_custom_status": "",
            "im_session_num": 1,
            "im_max_join_num": 10
        },
        {
          ...
        },
        ...
    ]
}

Abandoned Queue Inquiry

Used to obtain information about users who have abandoned the queue.

Request

GET /im/im_queues

Parameters

Parameter NameRequiredDescription
start_timeYesStart time
end_timeYesEnd time
pageNoPage number, starting from 1, default is 1
per_pageNoNumber of items per page, default is 30, maximum is 100
  • Note: When sending a request with other tools, do not set the Content-Type header to application/json, otherwise an error will occur.

Response Data

Attribute NameTypeDescription
codeIntegerExecution result code, 1000 represents success
shut_queuesArrayList of customers

shut_queues Element Data Structure

Attribute NameTypeDescription
customer_idIntegerID
customer_nameStringCustomer nickname
channelStringChannel, such as web, wechat, ios, android, weibo, api, mchat
queue_start_timeStringTime when the customer started queuing
queue_secondsStringTime spent in the queue
queue_nameStringName of the queue
current_pageIntegerCurrent page number
total_pagesIntegerTotal number of pages
countIntegerTotal number of items on the current page

Example

Request

curl https://demo.udesk.cn/open_api_v1/im/im_queues?email=admin@udesk.cn&timestamp=1494474404&sign=6892f1b794071c260e1b1eac15df588fc919c9e86eb742affaa742ad6c03cb52&nonce=2d931510-d99f-494a-8c67-87feb05e1594&sign_version=v2
&start_time=2019-02-10&end_time=2019-02-15

Response

{
    "code": 1000,
    "shut_queues": [
        {
            "id": 123,
            "customer_id": 1234,
            "channel": "web",
            "queue_start_time": "2022-03-25T15:55:20.000+08:00",
            "queue_seconds": 27,
            "queue_name": "xxx",
            "customer_name": {
                "id": 12345,
                "email": "123.123.123.123@temp.com",
                "signature": null,
                "notify": null,
                "weibo_name": null,
                "weixin_openid": null,
                "nick_name": "xxx",
                "weibo_id": null,
                "company_id": 1,
                "created_at": "2022-03-25T15:55:03.000+08:00",
                "updated_at": "2022-03-25T15:55:04.000+08:00",
                "organization": null,
                "cellphone": null,
                "telephone": null,
                "weixin_id": null,
                "authentication_token": null,
                "description": "IM user:ip(123.123.123.123)",
                "qq": null,
                "platform_id": 4,
                "ticket_show_filters": {
                    "show_user": "true",
                    "show_assignee": "true",
                    "show_created_at": "true",
                    "show_priority": "true",
                    "show_status": "true",
                    "show_platform": "true"
                },
                "wechat_status": "offline",
                "custom_fields": {
                    "SelectField_3999": [
                        "0"
                    ]
                },
                "leave_msg_expire_at": null,
                "customer_import_record_id": null,
                "web_token": "1f85c1b8-61b9-44f3-3468-9f5w164d099f",
                "sdk_token": null,
                "is_anonym": false,
                "owner_id": null,
                "ip": "123.123.123.123",
                "from": "xxxxx",
                "weibo_status": null,
                "weibo_leave_msg_expire_at": null,
                "deleted": false,
                "weixin_api_status": null,
                "weixin_appid": null,
                "weixin_appsecret": null,
                "owner_group_id": null,
                "source_channel": "web_im",
                "weixin_channel_id": null,
                "province": "xx",
                "city": "xx",
                "phone_service_provider": null,
                "isp": "xxx",
                "last_contact_at": null,
                "first_contact_at": null,
                "contact_count": null,
                "last_contact_at_via_phone": null,
                "first_contact_at_via_phone": null,
                "contact_count_via_phone": null,
                "last_contact_at_via_im": null,
                "first_contact_at_via_im": null,
                "contact_count_via_im": null,
                "latest_device_info": {
                    "os": "Win7",
                    "browser": "Chrome99",
                    "resolution": "1920*1080"
                },
                "organization_id": null,
                "is_blocked": false,
                "generated_channel": null,
                "weibo_channel_id": null,
                "level": "normal",
                "open_api_token": null,
                "current_ticket_id": null,
                "mchat_openid": null
            },
            "im_web_plugin_id": 16,
            "menu_names": "xxx"
        }
    ],
    "meta": {
        "current_page": 1,
        "total_pages": 1,
        "count": 1
    }
}

Send IM Structured Message

This interface is used to send structured messages to customers through IM. Rate limit: 1 time/2 seconds

Authentication

The signature method is described in Authentication Method, but note the following two points:

  • The order of the Query String must be im_sub_session_id, customer_id, agent_id, timestamp;
  • Replace the shared secret with the "Structured Message KEY". You can find it in the backend of the website under 'Management Center' -> 'Channel Management' -> 'Instant Messaging' -> 'Structured Messages'.

Request Method

POST /im/sessions/struct_messages

Request Parameters (Query String)

Parameter NameRequiredDescription
im_sub_session_idYesSession ID
customer_idYesCustomer ID
agent_idYesAgent ID
timestampYesTimestamp

Note: Customers created through the API cannot be used for this interface.

Request Parameters (Request Body)

Parameter NameRequiredTypeDescription
jid_resourceNoStringSDK Channel Source
dataYesObjectStructured Message

data

Parameter NameRequiredTypeDescription
titleYesStringTitle
descriptionYesStringDescription
img_urlYesStringImage URL
buttonsYesArrayButtons List

buttons Element Structure

Parameter NameRequiredTypeDescription
typeYesStringButton Type
textYesStringButton Title
valueYesStringButton Value
callback_nameNoStringCallback Name, only valid when type is sdk_callback

type Values

ValueMeaning
linkLink Button
phonePhone Button
sdk_callbackCallback Button (SDK only)

Response Data

Attribute NameTypeDescription
statusIntegerExecution result code, 1000 represents success
messageStringExecution result description

Example

curl https://demo.udesk.cn/open_api_v1/im/sessions/struct_messages?im_sub_session_id=1&customer_id=1&agent_id=1&timestamp=1494814031&sign=129da7df812jdfsa9912jfdadf81 \
-X POST \
-H 'content-type: application/json' \
-d '
{
    "data": {
        "title": "Test API sends structured message",
        "description": "This message is from the API.",
        "img_url": "https://www.udesk.cn/images/index/banner01.jpg",
        "buttons": [
            {
                "type": "link",
                "text": "Visit",
                "value": "https://www.udesk.cn"
            },
            {
                "type": "phone",
                "text": "Dial a phone call",
                "value": "010-12345678"
            },
            {
                "type": "sdk_callback",
                "callback_name": "sdk_callback",
                "text": "Callback button",
                "value": "v1"
            }
        ]
    }
}'

Response

{
  "status": 1000,
  "message": "Send Success"
}

Custom IM Structured Messages List Page

Custom IM structured messages list page is an HTML page provided by you, which contains commonly used structured messages for customer service to quickly select and send to customers in the Udesk IM console. To use a custom IM structured messages list page, you need to follow these two steps:

  1. First, you need to write an HTML page and provide the public address of the page;
  2. Set the "Embedded Link" in Udesk 'Management Center' - 'Structured Messages'.

Writing HTML Page

Udesk will present your HTML page to customer service in an iframe when they need to select a structured message, and pass the following parameters to your HTML page as query strings:

Parameter NameDescription
im_sub_session_idSession ID
customer_idCustomer ID
agent_idAgent ID
jid_resourceSDK Source
timestampTimestamp
Additionally, the signature calculated in accordance with the Authentication Method will also be passed as the sign parameter.

The calculation of the signature is slightly different from Authentication Method and consistent with the Send IM Structured Message Interface. When you receive the request, it is recommended to first verify whether the sign value is valid before deciding to return the HTML page. At the same time, in the HTML page, you can use the above parameters to call the Send IM Structured Message Interface to complete the sending of structured messages.

Settings

  1. Log in to the Udesk system as an administrator;
  2. Go to 'Management Center' - 'Channel Management' - 'Instant Messaging' - 'Structured Messages';
  3. Set the "Embedded Link" to the public address of the HTML page you provided.

Example

Assuming the following settings in the Management Center:

  • Embedded Link: https://www.demo.com/struct_messages
  • KEY: 708ff6dc-41d5-4med-9ebc-0388zz9d76f1 When the customer service agent clicks the "Structured Messages" list icon in the IM console chat interface, Udesk will display an iframe page containing an address similar to the following:
https://www.demo.com/struct_message?im_sub_session_id=1&customer_id=1&agent_id=1&jid_resource=12dsafdaslj129das-12fds912-12dsa&timestamp=1484272693&sign=4666293b3dfe91aa97179dc701be7afc

Note that the calculation method of the sign is as follows:

md5("im_sub_session_id=1&customer_id=1&agent_id=1&timestamp=1484272693&708ff6dc-41d5-4med-9ebc-0388zz9d76f1")
# => 4666293b3dfe91aa97179dc701be7afc

FAQ

What conditions do we need to meet to use this API interface?

This API interface requires a significant amount of development and has high requirements. You must meet the following conditions:

  • You must have your own Instant Messaging platform.
  • Udesk is only responsible for pushing to your server, not to your customers.
  • You must already have an instant messaging platform or the ability to build one, or use a third-party platform.
  • If your customers are all on the WeChat/Weibo platform, you can be considered to have an instant messaging platform.
  • You must have strong backend development capabilities and need to perform the following work:
  • Maintain customer information and update users to the Udesk platform
  • Maintain customer sessions
  • Maintain conversation content and push customer service responses to customers
  • [Optional] Maintain satisfaction display and results

What is the format of the request sent to the server address we specify?

It is a POST request in JSON format.

Why does the customer not exist when I request a session?

Before requesting a session, you need to request the creation of a customer, see:

Our server does not receive customer service responses, how can we confirm if Udesk has pushed them?

It is recommended to:

  • Use nginx/apache as a front-end, so you can see the logs whether the request has been received regardless of whether the backend application is processed correctly
  • The application server should first print the received request body to the log to see if the request has been received, and then proceed with business logic development

Why does the reply message return multiple messages at different times?

  • When some events and messages have strong order bindings, such as the start of a session event and the welcome message.