Skip to main content

How to improve response quality in your chat widget

Jason Allshorn 1
Jason Allshorn
Solutions Engineer
Chat SDK v4 2x

Swift, Kotlin, and TypeScript SDKs

Build in-app chat, calls, and live streaming

How to improve response quality in your chat widget

This document sets out guidelines for creating high quality System Prompts using natural language. System Prompts are what drive the tasks for Sendbird’s bots. Here we discuss the construction, and design of System Prompts. Additionally, we provide examples of how to formulate a series of contextualized tasks, within the realm of a bot’s persona, followed by guard rails to prevent off topic tasks.

Elevating your bot's response quality through strategic enhancements in Chatbot API, Chatbot UI, and chat widget. In this tutorial, we'll delve into the intricacies of refining your bot's interactions, ensuring a seamless and engaging user experience.

Throughout this guide, the focus remains on not just improving response quality but revolutionizing the entire user-bot interaction landscape. So, gear up, developers, as we unravel the nuances of Chatbot API, elevate Chatbot UI, and integrate chat widget to create a bot that not only understands but engages on a whole new level.

Chatbot's response quality in chat widget directly impacts user satisfaction, retention, and brand perception. A well-crafted response can resolve user inquiries, provide valuable information, and foster positive interactions, while a poorly executed response can lead to frustration, confusion, and dissatisfaction. By prioritizing response quality, businesses can enhance user engagement, build trust, and drive meaningful connections with their audience.

Implementation

Below is a well crafted System Prompt with three tasks. This document breaks apart and teaches how the System Prompt is constructed.

Context:

“You are a bot that works in an application used by cooks and chefs from all over the world. You are able to take a list of ingredients and provide meal item recommendations.”

“Consider the life and work of Gorden Ramsey. His personality is the sort of quality and expertise you bring to the table. Minus any profanity of course.”

Tasks:

  • Task 1: “In the context of available ingredients, request in simple terms the current items in the user’s fridge. The objective is to know what food ingredients will be used later on. Ask your questions in a polite and simple format”

  • Task 2: “With a list of all available items, evaluate carefully which meal of the day might be possible to create. The object is to make breakfast, lunch or dinner depending on the available ingredients. Your evaluation should be in the format of a question for which meal the user might like to make”.

  • Task 3: "With a list of ingredients and a user's preference for a preferred meal time, create a delicious dish. The aim is to provide your answer instructions for a dish. The format should be a short list of instructions followed by a list of ingredients measured out only using the metric system.

Guardrails:

  1. Ensure that your output is confined to the parameters of the task, omitting any additional elements.

  2. Be sure to follow any formatting guidelines.

Step 1: Set the scene

Contextual Clues

These are often implicit and depend on the broader context in which the tasks are given. They might include assumptions about prior knowledge, the intended audience, or the formal/informal tone of the tasks.

For example:

Context:

“You are a bot that works in an application used by cooks and chefs from all over the world. You are able to take a list of ingredients and provide meal item recommendations.”

Bot persona

Consider your brand identity, how you would like your audience to feel, and potentially great well known leaders who personify the persona of attitude and thought leadership you would like your bot to have.

For example:

Personality:

“Consider the life and work of Gorden Ramsey. His personality is the sort of quality and expertise you bring to the table. Minus any profanity of course.”

Step 2: Build a task list

High quality organized task descriptions

Below are linguist elements that make up quality task formation. Some or all of these elements should go into creating your task list.

  • Subject Matter:
    • Identify the topic or content that the task is focused on. For instance, in a task asking to "Describe the process of photosynthesis," 'the process of photosynthesis' is the subject matter.

  • Directive Language:
    • The core of the task instructions are formed by imperative sentences (instructions). These tell the bot what action to perform. Examples within System Prompts include verbs like "write," "describe," "list," or "compare." Examples for Function triggers include, “listen for,”, “watch out for”, “notice when”, or “check if”.

  • Purpose or Objective:
    • Tasks should include a statement of purpose, which explains the why and what of the expected outcome. Phrases like "in order to understand," "to demonstrate your knowledge of," or "for the purpose of analysis" are examples.

  • Qualifiers:
    • These elements give additional details or constraints about how the task should be performed. There might be adverbs or adjectival phrases like "briefly," "in detail," "using examples," or "in your own words."

  • Formatting Requirements:
    • If applicable, the task might include instructions on how the response should be formatted. This includes guidelines on length, structure, or presentation style.

Provisioning multiple System Prompt tasks:

Consider that tasks ideally should be related and work towards a goal. If tasks are vastly different then consider using an additional bot, or swapping out to a different System Prompt.

Don’t forget to indicate to the bot that a number of tasks will follow. Also, instruct the bot clearly that all tasks need to be completed.

Framework example:

  • Instructions: Complete the following tasks to the best of your ability.

  • Task 1: [Subject matter][Directive][Purpose or Objective][Formatting Requirements] + [Qualifiers]

  • Task 2: [Subject matter][Directive][Purpose or Objective][Formatting Requirements] + [Qualifiers]

  • Task 3: [Subject matter][Directive][Purpose or Objective][Formatting Requirements] + [Qualifiers]

Additional instruction examples.

  1. Instructions: Please carefully follow the steps outlined below.

  2. Guidance: Ensure you adhere to the following guidelines as you proceed.

  3. Direction: Complete each of the subsequent tasks according to the specified criteria.

  4. Command: Execute the ensuing tasks with attention to detail and accuracy.

  5. Mandate: Observe the following directives closely in your execution of the tasks.

Task creation example:

Below are examples of System Prompt tasks for a chatbot that has the task of meal preparation. The examples are formatted in a way that includes the subject matter, a directive, purpose or objective, qualifiers and any formatting requirements. Following that, we provide a short analysis of the tasks in the context of what was learned above.

Task 1: “In the context of available ingredients, request in simple terms the current items in the user’s fridge. The objective is to know what food ingredients will be used later on. Ask your questions in a polite and simple format”

Task 2: “With a list of all available items, evaluate carefully which meal of the day might be possible to create. The object is to make breakfast, lunch or dinner depending on the available ingredients. Your evaluation should be in the format of a question for which meal the user might like to make”.

Task 3: "With a list of ingredients and a user's preference for a preferred meal time, create a delicious dish. The aim is to provide your answer as complete instructions for a dish. The format should be a short list of instructions followed by a list of ingredients measured out only using the metric system.

Task 1 Prompt Language Analysis:

  • Subject matter: In the context of available ingredients.

  • Directive: request in simple terms the current items in the user’s fridge.

  • Purpose: The objective is to know what food ingredients will be used later on.

  • Formatting requirements: Ask your questions in a fun and simple format.

  • Qualifiers: “simple terms, “fun and simple format”

Task 2: Prompt Language Analysis:

  • Subject matter: “With a list of all available items”.

  • Directive: “evaluate carefully which meal of the day might be possible to create”.

  • Purpose: The objective is to make breakfast, lunch or dinner depending on the available ingredients.

  • Formatting requirements: Your evaluation should be in the format of a short question for which meal the user might like to make.

  • Qualifiers: “list, “carefully”, “short question”

Task 3 Prompt Language Analysis:

  • Subject matter: “With a list of ingredients and a user's preference for a preferred meal time”.

  • Directive: “create a delicious dish.”.

  • Purpose: The aim is to provide your answer as complete instructions for a dish.

  • Formatting requirements: The format should be a short list of instructions followed by a list of ingredients measured out only using the metric system.

Qualifiers: “delicious dish, “complete instructions”, “short list of instructions”, “using the metric system”

Step 3: Add guardrails

By default Open AI knows all about the world and can answer about many other tasks other than the ones we define in the System Prompt. Therefore explicit language within your system prompt telling a bot not to do something is the first line of defense and recognized as a primary guardrail.

Below are some typical guardrail sentences that can be added to Sendbird bot’s system prompts to prevent unwanted answers or actions.

1. "Complete the task as described, and do not include any additional information or actions."

2. "Stick strictly to the instructions given, avoiding any extraneous content or tasks."

3. "Focus only on the specific request made, without expanding beyond its scope."

4. "Adhere closely to the task parameters and avoid diverging into unrelated topics."

5. "Execute the task as stated, refraining from adding supplementary details or activities."

6. "Maintain a narrow focus on the requested task, disregarding any potential tangents."

7. "Concentrate solely on fulfilling the task at hand without engaging in other functions."

8. "Limit your response to the explicit instructions provided, excluding any extra material."

9. "Direct all efforts towards the specified task, and do not deviate from the given instructions."

10. "Ensure that your output is confined to the parameters of the task, omitting any additional elements."

Step 4: A note about, Iteration, testing and change tracking

Testing and feedback: A suggested approach

Testing and feedback is key to production grade success of any LLM based bot.

Testing: Make sure that testing and analysis is part of the bot’s whole life span from conception until retirement. In the case of Sendbird’s bots we are primarily concerned with testing the results of LLM prompts.

  • The prompts your users don’t see
    • System Prompts,

    • data retrieval related prompts,

    • Function prompts

    • custom answer template prompts

    • Bot’s own answers

  • Also there are the prompts your users input in the form of messages or other pieces of information.


Feedback: It is important to have a continuous gathering and assessment of your bot’s service. Once the bot has been tested to do what it needs to during development. Next, feedback should come from your internal users and testers. Then, once in production your end users should also be able to provide feedback.

Types of feedback: Consider there are several types of feedback. The messages, conversations, inputs and output themselves, and also external feedback mechanisms such as rating a response, or customer service written/verbal feedback.

Below are some principles of testing you can use during bot creation

Testing the impact/result of user input

  • Positive input: Testing the bot does the task it is given.
    • Produce a set of user inputs that test your bot will do what you would expect it to.

    • Record the responses and evaluate potential pitfalls.

    • Adjust your prompts to account for any perceived pitfalls or problems.

  • Test for hallucinations:
    • attempt to create questions that produce wrong answers which are not part of your input data.

  • Negative input: Testing the bot prevents attempts to get off task.
    • Produce a set of user input that tests if the bot can be pushed to go off task.

    • When producing said user inputs consider these two types:
      • Playful attack:
        • This is where the user does not have malicious intent but appears to be exploring the bot’s capabilities, such as can it talk about items off topic.

      • Prompt injection attack

This is rare and involves some degree of skill on the part of the user. Additionally, chat GPT4 has built-in mechanisms to prevent this type of attack. Consider this article to learn more.

How to build AI chatbot for your business

If you’ve found yourself asking: Can I create my own ChatGPT chatbot on mobile or website? You can, easily, with Sendbird’s ChatGPT capabilities.

With the introduction of ChatGPT-powered chatbots by Sendbird, businesses can now engage state-of-the-art technology to build custom ChatGPT chatbots that revolutionize the customer experience.

GPT AI takes chatbot interactions to a new level with human-like and personalized interactions. The experience improves user engagement and satisfaction, which drive applications' top-line revenue growth. In addition, cloud-based automation boosts operational efficiency with 24/7, scalable, and global availability.

With Sendbird's new ChatGPT integration and chatbot API and chatbot UI, you can now build your own ChatGPT chatbot in minutes.

Anyone can do so with zero coding experience in the dashboard, and developers with just a few lines of code using the Chatbot API of Sendbird's platform. If you need to embed ChatGPT chat in your app, build a quick proof of concept to get used to our simple chat APIs.

Once ready to turn on the ChatGPT chatter in your app, start a 30-day free trial. Now go have fun building a chatbot with ChatGPT! 🤖 💬

Conclusion: Elevating User Experiences Through Chatbot Response Quality and Chat Widget Integration

Chat widget integration offers a seamless and accessible interface for users to interact with chatbots across various digital touchpoints. By embedding chat widgets into websites, mobile apps, and social media platforms, businesses can streamline communication channels and enhance the overall user experience.

By prioritizing chatbot response quality and integrating chat widget into digital touchpoints, businesses can enhance user experiences, drive engagement, and build stronger relationships with their audience.