How to use a recurring Integration Endpoint for importing data
You are here
Using an AI Assistant to Provide Dynamic Help
Is it possible to train an AI to offer intelligent assistance in your Dynamics 365 F&O instance?
In a previous article, I showed how you could use AI to provide dynamic help to your users. This example simply allowed for a user to ask a ChatGPT generic model how to perform a task in Dynamics 365 for Finance and Operations. This was an example of how to incorporate an AI bot with some additional context and prompting info to be helpful to your users. This would include a specific prompt with context info to help with user provide a simple request and get a specifically helpful response. This was a fun and interesting demo for a use of the technology but its still fairly dumb. Rather than use AI to help provide assistance to my user, I could just train them. Using AI for this is a costly fix for an easy to fix problem. Just train people. In my opinion, my own example is pretty stupid in that the AI can provide a word slurry that seems fairly reasonable at first read. However, when you try to use the response to actually perform the task, everything is about 80% correct with some interesting guesses mixed in there. We can do better and provide users with specific, accurate steps with context cues accounted for so they can use the instructions to perform a specific task with context in a specific legal entity.
ChatGPT Assistant and APIs
You can read the docs from OpenAI on this, but in short if you want to make a bot for you, create a GPT. If you want a bot in your app, create an Assistant and use the APIs. Assistant creation has a very lightly documented UI available now so we'll be using that to create our Assistant rather than using an API. All consumption of the APIs though will happen in F&O using a C# connector that does all of the work. The UI at OpenAI for this also lets you see a list of all Assistants and do some basic management.
Creating an Assistant
First, go to https://platform.openai.com/assistants and click create. You may have to sign up for an account that is pre-funded. I already have prepaid for my account to get all features available so I can mess around with anything.
For our specific use, I want the Assistant to "know" some facts before hand so the knowledge for the LLM doesn't have to be dynamically fed in with each query. At the time of writing for this article, we want "retrieval" to be active so we have to use mode "gpt-4-turbo-preview". Set retrieval to be on. For this example we won't be using functions. If you have any process documents to upload, please add those. We'll walk through generating and uploading training data later.
Connect F&O to the Assistant
First, all code we'll be demoing or reviewing is available at https://github.com/NathanClouseAX/FOChatGPTExamples. Load this into your dev environment to review or extend as you see fit.
Once you have the code in your environment, go to System Parameters ( System Administration > Setup > System Parameters ). You should see two options for ChatGPT Integration. The first option from the last article and the new Assistant option. Expand the ChatGPT Assistant API Fasttab then click "Apply Defaults". After that, paste in your API and Assistant ID from the Assistant you just created then set "use ChatGPT Assistant API" to yes.
After that, you can open the help menu, click on the AI Assistant tab and ask a question. This example will be without any supplemental training material.
Tuning the Assistant
Now that we can talk with our AI Assistant, let's give it some additional training. There are lots of ways to do this but I thought I would give it two task recordings for how to create a customer in 2 different legal entities with some additional content for how to use the output from the task recordings. I'm only going to be uploading the word document that can be generated for a task recording. They can be found here and here.
Once we have some additional training data we can give the AI, we can upload it. To do this, you can edit your Assistant and upload any assets that you'd like at https://platform.openai.com/assistants.
We can also give the bot a better prompt. This can be whatever you like but it helps better instruct the Assistant to know what it can and cannot do and how to process any additional context data that is included with the end users prompt. Below is what I am using. You can tailor it to whatever you'd like in the Assistant as well as provide supplemental instructions from inside F&O.
The instructions giving to the Assistant AI:
You are an assistant to help users use Microsoft Dynamics 365 for Finance and Operations. This is a request for a user of Microsoft Dynamics 365 for Finance and operations that is already signed in. They should be asking for how to perform a task only within that context. If they ask for anything that seems outside the scope of Finance and Operations, please state that you are unable to answer. Coding questions are strictly forbidden. If a question may not be related to Finance and Operations, please tell the user that you are unable to assist until their question is more specific to Finance and Operations. Do your best to provide the most up to date instructions based on the most recent version of Finance and Operations. Do not state the name of the software in the reply. Do not include login steps as part of the response.
The Results
Now that we have an AI that knows the process of creating a customer for DEMF, USMF, and also in general, we will get much more specific answers to our customer creation prompt. We'll only get specific directions for processes that the model is specifically trained on but that's ok for this example.
DEMF
You can see the task recording word doc for DEMF that the Assistant was given here. This word doc was also given some additional prompting as part of it to help guide the AI. The process for DEMF is different than USMF and those differences are reflected in the task recording and the help offered from the Assistant.
To create a customer within the context you've outlined, where you are accessing the system with the roles of System Administrator and your legal entity is `demf`, here's how you can proceed:
1. **Navigate to Customers**
- On the dashboard, go to **Modules > Accounts Receivable > Customers > All Customers**. This will take you to the list page where you can view all existing customers.2. **Create New Customer**
- On the **All Customers** page, click **New** to create a new customer record.3. **Fill in Customer Details**
- **Account number**: You can either enter a customer account number manually or have the system generate it for you based on the number sequence configuration.
- **Name**: Enter the full name of the customer.
- **Customer group**: Select a customer group for the new customer. Customer groups help classify your customers and can be used for reporting and analysis.
- **Legal Entity**: Since you are in the legal entity `demf`, it should be automatically selected. If not, make sure you're operating under the correct legal entity.
4. **Address and Contact Information**
- Navigate to the **Address** fast tab to add the customer's address information. Click **Add** to input the address details, including street, city, state, and postal code.
- Switch to the **Contact Information** tab to add phone numbers, email addresses, and other contact details for the customer.5. **Currency, Payment, and Invoice Settings**
- Under the **Invoice and Delivery** fast tab, specify the preferred currency for transactions with this customer, which in your context will be EUR.
- Set up the payment terms, payment method, and delivery terms according to your company policy and the agreement with the customer.6. **Save the Customer Record**
- Once all the relevant details are filled in, click **Save** to create the customer record.Remember, if there is more specific information required for the customer based on business needs or regulatory requirements in the "deu" (Germany), make sure to enter that information in the respective fields or tabs available in the customer setup.
This process will create a new customer within your specified legal entity, adhering to the legal and currency settings you've mentioned.
USMF
You can see the task recording word doc for USMF that the Assistant was given here.
To create a customer within your specified legal entity, follow these steps:
1. **Navigate to Customers**: Go to **Accounts receivable** > **Customers** > **All customers**.
2. **New Customer**: Click on **New** in the action pane to create a new customer record.
3. **Customer Account**: The system will prompt you to enter a unique customer account number. If your system is configured to generate numbers automatically, this might be filled in already.
4. **Legal Entity**: Since you're operating under a specific legal entity, ensure that the correct legal entity is selected. In case of multiple entities, you might need to switch to the desired legal entity "usmf" which you mentioned.
5. **Customer Details**: Fill in the required customer details such as **Name**, **Address**, and contact information. Under the **General** tab, you can specify additional information like **Currencies**, where you would select USD as per your legal entity's currency.
6. **Address and Contact Information**: Under the **Address** book, enter the customer’s physical and mailing address. Use the **Contact information** tab to enter phone numbers, email addresses, and other relevant contact details.
7. **Payment Terms**: Set up payment terms for the customer under the **Invoice and delivery** tab, specifying how and when the customer is expected to pay.
8. **Save**: Once all necessary details are entered, click **Save**.
9. **Review and Confirm**: Review the information to ensure everything is correct and meet your business requirements.
Please note that some fields and sections might vary depending on the customizations and configurations specific to your system. As a System Administrator, you have the ability to adjust certain preferences and settings to streamline the customer creation process according to your business workflow.
Making It Even Better
Several tweaks we could also code in, prompt, or include in the task recording docs are below. However, you've probably noticed that context and knowledge are key to providing a meaningful, accurate, and helpful information. The more that can be communicated and known, the better the response from the Assistant will be. We're able to provide context and knowledge enough such that the AI knows the difference between "yelling at (a) cloud" and "yelling at Cloud". AI, in general, is getting better and we'll need to keep on providing it with more data and context in order for it to help us with out F&O specific processes. Also, all code is open source so please add in whatever features you'd like to see.
Update Task Recordings
The task recordings could be manually updated with the business rules around the specifics of creating a customer with field level call outs. An example of this could be "If customer sales is expected to be above 100 million, place in classification group 01. if above 50 million, place in group 02. Otherwise, 03". Any additional info or rules that can be included will be helpful in providing guidance for the user.
Prompt
The instructions for the Assistant can be further refined to provide a more standard response. You can see above for DEMF, the bot specifically mentions that it is in responding to a query from a user in DEMF while the example for USMF simply states "to do this in your current legal entity". Also, its more than likely possible you could train and prompt this into being able to create a task recording for the user on demand then dynamically send that to F&O for execution to actually guide the user through the process.
Other Ideas
We could provide context for where the user is specifically in F&O then provide a set of steps for the request from where the user is rather than from the main dashboard you get once you log in. Also, there is tons of room to provide security context info for processes, buttons, forms, and so on the user gets a set of instructions that are valid for their level of access and security.