tencent cloud

Feedback

Integration Solution (No UI)

Last updated: 2024-02-27 16:23:55

    Prerequisites

    1. Understanding chatbot-related terminology and configurations, and have completed the following steps:
    Created a chatbot in the console, configured the Q&A database, and the chit-chat database.
    Configured the welcome card.
    2. Integrated the IM SDK and successfully tested functions such as login and sending one-on-one messages.

    Process

    This process explanation illustrates the journey from integrating a chatbot to having a conversation with it.

    Step 1: Create a chatbot

    Refer to the operation guide, create a chatbot on the IM console, and configure the Q&A, small talk libraries, and welcome cards.

    Step 2: Initiate a Welcome Card in the Bot Session

    Upon the user's first entry into the bot's chat session, a welcome card trigger message shall be sent to the chatbot. Subsequently, the bot will respond with a welcome card message.

    Step 3: Chat with the ChatBot

    A user interacts with a chatbot primarily through text messages. When the chatbot fails to grasp the user's intent, it issues a custom message containing guiding questions, offering multiple options for the user to select. The app is required to interpret these custom messages and respond with a corresponding text message based on the user’s selection. Furthermore, the welcome card is another form of custom message.

    Message Formats

    The chatbot is designed to handle only text and custom messages. Custom messages are used in scenarios like triggering and returning the welcome card, and when the bot issues guiding question messages. In this context, custom messages refer to the values derived from JSON deserialization of the data field in IM custom messages. Different platforms have their unique methods for accessing the data field of custom messages, detailed in their respective documentation (Android&iOS&Windows&Mac / Web / Flutter / Unity / React Native).
    In these custom messages, the bot differentiates between message types using the 'src' field within the JSON structure. An explanation and examples of these custom message fields are provided below.:
    Field name
    Field Type
    Field Description
    chatbotPlugin
    Number
    Chatbot self-definition message flag bit, this field is fixed to 1.
    src
    Number
    Define a customized message type; for instance, 15 signifies that this message is a branch-type message of the chatbot.

    Trigger the welcoming card

    When a user initiates their first chat session with the bot, a message should be sent to the chatbot's account to trigger the display of the welcome card.
    {
    "chatbotPlugin": 1,
    "src": 7
    }

    Welcome card message returned by the bot

    The welcome card message from the bot includes a selection of questions that users are likely to ask. If a user selects one of these questions, the App should send the text of the chosen question as a message to the bot.
    {
    "chatbotPlugin": 1,
    "src": 15,
    "subtype": "welcome_msg",
    "content": {
    "title": "Perhaps you might inquire",
    "content": "Welcome to using Instant Messaging intelligent robot!",
    "items": [
    {
    "content": "Where is the Instant Messaging image uploaded"
    },
    {
    "content": "Does the Instant Messaging support obscenity detection for the images, short videos, and voices being sent"
    }
    ]
    }
    }

    Guiding Question Message

    If the chatbot is unable to comprehend the user's intent, it will issue a message with guiding questions, providing a range of options for the user to select from. Upon selecting a question, the App must then sends a text message to the bot that corresponds to the selected question.
    {
    "chatbotPlugin": 1,
    "src": 15,
    "subtype": "clarify_msg",
    "content": {
    "content": "You might be wondering",
    "items": [
    {
    "content": "Where is the Instant Messaging image uploaded"
    },
    {
    "content": "Does the Instant Messaging support obscenity detection for the images, short videos, and voices being sent"
    }
    ]
    }
    }

    Stream Output

    Note:
    For users of TUIKit version 7.7.5282 or later, the platform inherently supports the display of a streaming output effect. However, if you're utilizing your own UI library, you'll have to interpret the custom message and ensure that this streaming output effect is visually represented in your App.
    When you activate the streaming output feature for Chatbot through the console, the backend will start sending responses using a custom streaming output protocol. The format of the initial output content is as follows.
    {
    "chatbotPlugin": 1,
    "src": 2,
    "chunks": ["hello"]
    }
    For content updates, the Chatbot backend will employ the 'Modifying History Message' feature. This process involves updating the message by adding new content to the 'chunks' array. Once the output is finalized, an extra field labeled 'isFinished':1 will be set to signify that the process is complete.
    {
    "chatbotPlugin": 1,
    "src": 2,
    "chunks": ["hello", " world"],
    "isFinished": 1
    }

    Customized Pass-Through Content

    Apps have the ability to forward specific content directly to their backend, which can then respond to users on behalf of the chatbot. When the app sends certain content, the IM backend triggers a 'chatbot passthrough message callback' to the app's backend. In response, when the app backend replies, the IM backend forwards this response in the same format back to the app.
    {
    "chatbotPlugin": 1,
    "src": 3,
    "data": "{\\"msg\\":\\"This is the self-defined passthrough content\\"}"
    }
    
    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support