We Use Cookies

We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with this.

See our cookie policy.

Send a prompt to ChatGPT and assign the response to a variable. Prompts can be assigned a Conversation Id if previous prompts/responses should be included when part of a conversation.

Built-In Action

Send a prompt to OpenAI ChatGPT and assign the response to a variable. You can send single one-off prompts or prompts that are part of a conversation. The ThinkAutomation ChatGPT action enables you to automate requests to ChatGPT and then use the response further in your Automation.

Before you can use this action you must create an account with OpenAI. Go to OpenAI and click the Get Started link to create an account.

On your account page select API Keys and generate a new secret key. Make a note of this key as it is only displayed once. This is your OpenAI API Key.

Specify your OpenAI API Key. You can create a Global Constant to use this key across all Automations if required.

The System Message is optional. This can help to set the behavior of the assistant. For example: 'You are a helpful assistant'.

The Prompt is the text you want a response to.


What category is the email below? Is it sales, marketing, support or spam? Respond with just sales, marketing, support or spam.
Subject: %Msg_Subject%
Response: sales              

Extract the name and mailing address from this email:
Dear Kelly,
It was great to talk to you at the seminar. I thought Jane's talk was quite good.
Thank you for the book. Here's my address 2111 Ash Lane, Crestview CA 92002
Name: Maya
Mailing Address: 2111 Ash Lane, Crestview CA 92002              

I am flying from Manchester (UK) to Orlando. What are the airport codes? Respond with just the codes separated by comma.
Prompts you send to ChatGPT have a limit of approximately 500 words.

Tip: When using ChatGPT to analyze incoming emails, you can use the %Msg_Digest% built-in field instead of %Msg_Body%. The %Msg_Digest% contains the last reply text only with all blank lines and extra whitespace removed. It is also trimmed to the first 750 characters. This is usually enough to categorize the text and will save your usage count.

The Model entry allows you to select the OpenAI Model to use. You can select from:

  • gpt-3.5-turbo
  • text-davinci-003
  • text-davinci-002
  • code-davinci-002
  • Your own fine-tuned model name

See the OpenAI documentation for details about the different models. GPT-3.5-turbo is the default and works for most scenarios, it is also the least expensive.

Specify the variable to receive the response from the Assign Response To list.

You can also optionally assign the number of tokens used for the prompt/response. Select the variable to receive the tokens used from the Assign Used Token Count To list. OpenAI charges are based on tokens used. For example, the current pricing for gpt-3.5-turbo is $0.002 per 1000 tokens.


You can optionally specify a Conversation Id. This is useful if multiple ChatGPT requests will be made within the same Solution and you want to include previous prompts/responses for context. The Conversation Id can be any text. For example, setting it to %Msg_FromEmail% will link any requests for the same incoming email address. If you set it to %Msg_MessageStoreId% then this will create a conversion for the currently executing message only.

The Max Conversation Lines entry controls the maximum number of previous prompts/response pairs that are included with each request. For example, if the Max Conversation Lines is set to 10 then the last (most recent) 10 prompt/response pairs will be sent prior to the current prompt. You should not set this too high as a large conversation may go above the ChatGPT max-tokens value.

Conversations are shared by all Automations within a Solution and conversation lines older than 48 hours are removed.

For example:

Suppose you send 'What is the capital city of France?' in one prompt and receive a response. If you then send another separate prompt of 'What is the population?' with the same conversation id then you will receive a correct response about the population of Paris because ChatGPT already knows the context. This would work across multiple Automation executions for up to 48 hours, as long as the conversation id is the same.

Using Your Own Model

You can also specify your own Model name if you have created your own fine-tuned model. Fine-tuning your own model enables you to add your own training data. This would then enable use cases, such as automating the process of answering incoming support or sales emails or using the ThinkAutomation Web API to respond to a web-based chat bot. See: OpenAI Fine-tuning.

Rate Limits

Your OpenAI account will set a rate limit for the maximum requests per minute. The Rate Limit Retries setting determines how many times ThinkAutomation will retry the request if a rate limit error is returned. It will automatically increase the wait time for each retry. The default wait period is 30 seconds. If the request still fails after the retries then an error will be raised.

ChatGPT Notes

ChatGPT has many uses. Other than being a regular chat bot that has knowledge of many subjects, you can use it to:

  • Parse unstructured text and extract key information.
  • Summarize text.
  • Classify emails.
  • Translate text.
  • Correct grammar/spelling.
  • Convert natural language into code (SQL, PowerShell etc).

and much more. See: Examples - OpenAI