# Enhancing Conversational Agent Development Through a Semi-Automatization Development Proposal
## 4 Proposal
### Integration with GPT-3 as an Alternative for Resolving User Queries
The least complicated way to do this is to concatenate the last message at the end and add a start sentence so that the model generates the text from what was previously displayed. The three elements mentioned above were designed for a prompt that will be used in one of the GPT-3 base models. If fine tuning is planned, elements 1 and 2 should be replaced or removed, and a large number of instances of element 3 should be used instead. In addition, it is recommended to filter the text generated from the model to standardize the response format, in order to prevent or minimize inappropriate responses, e.g., by checking the length of the text provided by the model or checking if it contains inappropriate words. In addition, use can be made of the temperature parameter and stop sequences at the convenience of the chatbot designer. By following this procedure, the recommendation system can be built quickly regardless of the area of application of the conversational agent. However, it is important to mention that this proposal was designed especially for chatbots used in customer service, so adaptations may be necessary depending on the designer's objectives. Figure 6 shows an example in which this proposal is applied, in which the OpenAI playground is used to generate a suggestion; the text formed by GTP-3 is shown in green. The procedure for generating suggestions via GPT-3, as detailed in this article, was seamlessly integrated into a Xatkit project to enhance the responsiveness of conversational agents in scenarios where user input cannot be classified into predefined intents. This integration represents a significant step toward improving the adaptability and user experience of chatbots developed within the Xatkit framework. The suggestion generation process is activated when a user submits a message that the NLP service fails to classify into any of the intents defined in the conversational agent's model. In such cases, the system transitions to the fallbackState, a designated state where the suggestion generation mechanism is executed. Within the fallbackState, a dynamic prompt is constructed to facilitate the GPT-3 text generation process. The prompt comprises three predefined components that establish the context and structure for the generation of GPT-3 response. To personalize the prompt, the user's message, retrieved programmatically through the context.getIntent().getMatchedInput() method, is appended when necessary. This approach ensures that GPT-3 has sufficient context to generate relevant and coherent suggestions aligned with the user's query. Once the prompt is completed, a request is sent to the OpenAI API to initiate the text generation process. To enable seamless communication  
Figure 6: Prompt recommendation example. between the Xatkit project and the OpenAI GPT-3 service, the TheoKanning openai-java library [40] is used. This library serves as a robust interface for interacting with the OpenAI API within Java-based projects. The workflow for generating GPT-3-based suggestions within the Xatkit framework can be summarized as follows:  
User Input Detection: The conversational agent identifies user messages that do not match any predefined intents, triggering the fallbackState. Prompt Construction: A dynamic prompt is created, incorporating predefined components and user input retrieved from the agent context. API Request: The constructed prompt is sent to the OpenAI API via the TheoKanning openai-java library. Text Generation: GPT-3 processes the prompt and generates a suggestion or response. Response Delivery: The generated suggestion is returned to the conversational agent, who provides it to the user. The integration of GPT-3 into the Xatkit framework addresses a common limitation in rule-based conversational agents: their inability to handle unclassified user inputs effectively. By invoking GPT-3 in fallback scenarios, the system ensures that users receive meaningful responses even when predefined intents are insufficient.