Considering what I have seen online these days, I can assume that ChatGPT needs no introduction. This chatbot developed by OpenAI has the ability to understand and answer an infinity of questions in natural language. I have tested ChatGPT on several occasions, asking very different things, such as: writing code, optimizing existing code, summarizing text or asking simple information. The results were always surprising.
The thing that particularly caught my attention is the API service made available by OpenAI that allows developers to access and use its functionality and models, including GPT model, in third-party applications. I used these APIs to create an interface with Dynamics 365 Business Central ERP.
To better understand what I have done, it is beneficial to have a knowledge of Business Central and its functionality. However, this article can also be useful for acquiring a general overview.
My idea is to create a simple internal chatbot in Business Central that can provide users help with the ERP functionality. To do this, I studied the OpenAI technical documentation  that describes in detail how to invoke the API service. The main steps for the API access are the following:
- Register on OpenAPI.
- Request the API Key for authentication.
- Follow the instructions on the site that describe how to invoke the API.
Remember that at the moment there is a restriction (rate limit) that an API imposes on the number of times a user or client can access in a specific period of time. Here more info.
Interface with Business Central
In Business Central, I created the following setup table where to indicate the parameters required for the OpenAI API.
Then, I implemented the logic inside a dedicated codeunit needed to invoke the API. Currently, the response of the chatbot is displayed in a simple field on the page, however, in the future I will consider making some improvements to make the display more effective.
Finally, I inserted a support action in some Business Central pages to allow users to request information from the chatbot about the current entity. This is a example on the purchase order page:
The open source project can be found in my GitHub repository.
Keep in mind
I asked to chatGPT directly what are the most important aspects to keep in mind while using it.
Following is the response generated by the chatbot.
When using ChatGPT there are a few things to keep in mind:
Data Bias: Because ChatGPT is trained on a massive dataset of text data, it can inadvertently perpetuate any biases present in that data. It’s important to be aware of these biases and to take steps to mitigate them.
Misunderstanding: ChatGPT, like any AI model, is not perfect and may misunderstand or misinterpret certain statements or questions. It’s important to be aware of this and to provide enough context or information to help the model understand what you’re asking.
Privacy and security: As with any AI model that uses personal data, it’s important to ensure that the data is collected, stored and processed in compliance with data protection regulations.
Transparency: AI models can be opaque and difficult to understand, which can make it challenging to interpret the results or diagnose errors. It’s important to be transparent about how the model works and to provide explanations for its decisions.
Human supervision: It’s important to have humans oversee the usage of ChatGPT, to ensure that the model is being used ethically, and that it is not providing harmful or inappropriate responses.
Use case: ChatGPT has been trained on a large dataset of internet text, and it’s not always able to understand the specific context of your use case, it’s important to fine-tune the model for your specific use case to improve its performance.
Quality of data: It’s important to ensure that the data used to fine-tune the model is high-quality and relevant to the specific use case.”
When I started developing this experimental solution, I hoped to get through the OpenAI API the same results as ChatGPT. After several tests I can say that the results returned by chatGPT are much more detailed and consistent than the results obtained through the OpenAI API. This is due to the fact that ChatGPT adds a layer of logic and natural language processing that allows for better results .
In conclusion, it is important to note the recent news that Microsoft will soon offer OpenAI services through its Azure platform . This move shows how it is attempted to simplify access to artificial intelligence models. This could encourage the native implementation of these models in many applications that we use on a daily basis.