ChatGPT Chatbots - How to Pass User Session Context to your Chatbot

When creating a ChatGPT chatbot for your website, it is very handy to pass user session information to the chatbot when a live chat session starts.  This can be very helpful if say you've trained your chatbot on your website product information, and the website visitor is initiating a live chat session from a particular product page.  Now with our JavascriptSDK, you can pass any custom parameters to your ChatGPT chatbot to provide additional context to the chatbot.

You can pass information like order id, order details, product information, delivery times, shipping details etc right to your ChatGPT chatbot to provide a great user experience.

In this article we'll show you how to easily pass any session information directly to your ChatGPT chatbot.

Prerequisites

High Level Steps

  1. Set up your ChatGPT Instruction Phrases and settings to optimize use of customer parameters
  2. Add your custom parameters to your live chat code snippet
  3. Test your session info in your ChatGPT Chatbot.

1. Set up your ChatGPT Instruction Phrases and settings for custom parameters

So this article assumes that you've already set up ChatGPT and Social Intents for a website chatbot as in this article.  Once that is done, Login to Social Intents and head to your Chatbot Settings tab - click My Apps, then Edit Settings in your Live Chat widget.

Once here, scroll down to the ChatGPT Instruction Phrases field and make sure to tell ChatGPT to use the context provided I the custom parameters.  Also, if available choose gpt-4 as your ChatGPT model and select a Temperature of around 0.5.  The higher the temperature, the more creative ChatGPT will get in its responses.  Play with this parameter to see what works best for your content and chatbot.

2. Add your custom parameters to your Live Chat code snippet

Now, that've set up the instructions, it's time to add any custom parameters you'd like to pass to ChatGPT as session info in your web page.  You've likely already added your code snippet for live chat to your website.  In this same section, you can add a Javascript code snippet using our Javascript SDK to pass custom values to your chatbot.

In our example, we'll pass order id, visitor name, and product information to the chatbot.  These parameters can be different on every page of your website, so you have a lot of flexibility on what you push over to ChatGPT

Make sure you add this code snippet in addition to the default chatbot code snippet you add to enable live chat.

3. Test your session info in your ChatGPT chatbot

Now that you have the code parameters set up in your live chat, it's time to test out your chat.  So for our example above, here's a sample of chat info.  You see ChatGPT responds with the visitor name, and understands the product and pricing information from the context provided.

ChatGPT Session Info

So now in addition to training your ChatGPT chatbot on your own custom data which is business related, you can provide session context to your chatbots for each individual visitor.

Get started today!