Using our Znode ChatGPT Connector
In the first part of this blog series, we talked about using AI to solve a problem in B2B E-Commerce. We took a look at the Znode B2B E-Commerce platform and found an opportunity to use the power of AI to process incoming customer feedback (from an in-app feedback form), and summarize that feedback for Marketing, IT and Customer Service departments based on the specific things those departments care about. We also added a sentiment analysis so that we can choose to route positive/negative sentiments with different rules. We did all of this by building prompts in the OpenAI API Playground, which turned out to be a great way to design the AI prompts for this solution before writing a single line of code.
Install and Configure the Znode ChatGPT Connector
In this next part of the blog series, we will take a deeper dive into how this solution can be implemented in Znode using their Commerce Connector framework. If you’d like access to our Znode ChatGPT Connector, it is available to you under an MIT license to use however you’d like. Right now it includes the necessary logic to support the specific use case we are writing about (Classify, Categorize and Summarize Customer Feedback), and we have plans to build it out further as this blog series continues into more use cases.
To implement in a znode codebase, copy the directory ChatGPTConnector
from our github repository, and paste it directly in to the ERP Connector project traditionally located at ZnodeMultifront\Projects\Libraries\Znode.Engine.ERPConnector
. Note these instructions were written for and tested with Znode 9.7.5 but it will likely work on earlier versions.
At this point, if you’ve done nothing else, your git changes should look something like this:
There is one more change that we need to make to the ERPConnector
project. In visual studio, right click on the project and click “properties”. Then navigate down to Build Events, and paste the following into the Post-build event command line section:XCOPY "$(ProjectDir)ChatGPTConnector\ZnodeChatGPTConnector.config" "$(SolutionDir)\Znode.Engine.Api\Data\ERPScheduler" /Y
The above post-build script will copy the ZnodeChatGPTConnector.config file into the data folder of the Znode.Engine.Api project, which is required for Commerce Connector to see our new connector configuration and allow us to enable it in the UI.
Now that everything is configured, go ahead and run your Znode app locally, and sign in to the Admin application using your credentials. Then, navigate to ERP Configuration from the mega menu.
You will likely see an empty page if you do not have an ERP Connector currently in use.
Click ADD NEW at the top right. On the resulting page, select “ZnodeChatGPTConnector” from the Package Name menu. If you do not see ZnodeChatGPTConnector here, that means something went wrong in the prior steps. I would suggest double checking that the post-build script is set up properly.
After selecting ZnodeChatGPTConnector, provide the same value in the ERP Name field. Finally, select the Save & Close button at the top right.
Assuming you were able to successfully save and close, you should now see the ERP Connector page with your new ChatGPTConnector installed and activated! The last step for making this work is to go to ERP Connector Configuration in the mega menu (like we tried to before). This should now take you to a configuration page with 3 links on the left side bar.
Select the 3rd link on the left. This will take you to the configuration page, and will allow you to enter configurable settings. This is designed so that you can make changes to the behavior of our ChatGPT Connector without writing a single line of code!
Below are the settings we used for our example. Try generating your own API Key (or use the one you saved from part 1 of this blog series), and then use the rest of our settings verbatim for this example. Click the Save button at the top right of the page when done.
ChatGPT API Key: you will have to generate your own within your OpenAI account — and keep it secret! If someone gets ahold of this they will be able to use the OpenAI API and charge their transaction fees to your account.
ChatGPT Completion API URL: https://api.openai.com/v1/completions
Feedback Classifier Model: text-davinci-003
Feedback Classifier Prompt: Possible departments are IT, Marketing, Customer Service. IT cares about functionality and performance, not about data accuracy. Marketing cares about the accuracy and completeness of product information data and photos. Customer service cares about everything related to the customer's satisfaction. If IT or Marketing departments can not directly and immediately benefit from the feedback, they should not have an email included in the response.
After clicking save at the top right and successfully saving, the Znode ChatGPT Connector is now live and ready to use!
Connect from a Znode Service
Remember the feedback form from part 1? We now need to take the service method that runs the “out of the box” logic for this submission form, and customize it to utilize a method called ClassifyFeedback()
in our Znode ChatGPT Connector, instead of just emailing the feedback to the site administrator.
Znode makes it really easy to customize pretty much any of their Out of the Box logic. As a C#/.net application, the preferred way for overriding default behavior is by inheriting the base service and overriding any methods you wish to customize. For our particular use case, the method we want is located in a service class called WebStoreCaseRequestService
with a method name of CreateContactUs()
. Follow the naming convention in your existing application, but if none exists I would suggest creating a new service file named CustomWebStoreCaseRequestService
or {yourcompanyname}WebStoreCaseRequestService
.
See the logic below that we use to override the base functionality. Notice we still call the base method at the end — this isn’t always appropriate but in this case it seemed like a good idea, so that the out of the box email alerts continue to go to the site admin and our 3 departments will start to receive the AI-enhanced email alerts. The suggested location of this service customization is in the Znode.Api.Custom\Service\Service
folder, and the code for our example can be copied from below. Be sure to adjust the email addresses, or even better yet, use Znode’s global attribute system to manage these addresses in the Admin app rather than in code.
Last thing that you need to do is register the new custom service class in Znode.Api.Custom.Helper.DependencyRegistration
. There is one simple line of code to add for this:
builder.RegisterType<CustomWebStoreCaseRequestService>().As<IWebStoreCaseRequestService>();
Save and rebuild the app after this. Assuming the app starts up without any errors, we are ready to try our example out with the following steps:
In the webstore app, log in with any user account (or register one and then log in)
Navigate to {webstoreHost}:{webstorePort}/CaseRequest/customerfeedback - (https://localhost:44315/CaseRequest/customerfeedback using the default port running locally)
In the feedback form, enter the following feedback message (the same feedback message we used in Part 1 of the series to test our prompt). Enter any contact details you’d like.
I tried to place an order but the page errored out the first couple times. Also, the product that I ordered (20v cordless drill) did not have an accurate photo when I was searching for it.
Click submit
If everything is set up correctly, there should be 3 emails that were sent out: an email to marketing telling them about the incorrect product photo, an email to IT to tell them about the application error and when it happened, and an email to customer service that summarizes all of the feedback.
Wrapping Up
So there you have it! Znode’s seemingly infinite extensibility combined with OpenAI’s easy-to-use API lets us leverage the latest and greatest technologies for immediate time savings and improvements to data quality.
Using our prompts we put together in part 1 of this blog series, we were able to leverage our new Znode ChatGPT Connector combined with an extremely simple custom Znode service method to quickly and easily start leveraging AI to provide real value to any organization.
What’s Next?
As always, share your thoughts with us! Can you see the clear value a solution like this can provide to any organization, or not so much? Is there another use case that you would use AI for in the B2B E-Commerce world?
Try out our Znode ChatGPT Connector by downloading the source code and following the instructions in this blog.
Keep an eye out for part 3 of this blog, where we will explore using AI to generate product information within Znode’s built-in PIM system.