Power Automate: Create Text With GPT & AI Prompts
The Power Automate Create Text With GPT action is the easiest way to use ChatGPT AI models inside of a flow. There is no need to setup an Azure Open AI instance or sign up for an Open AI developer account. Simply create a prompt in the new Power Platform AI studio, define the input variables and the output format. Choose which model to use: GPT 3.5 or GPT 4o and then add a single action to your flow. That’s all it takes!
Table of Contents
• Introduction: Parse An Address String And Save To SharePoint List
• Write An AI Prompt To Parse An Address Into JSON
• Add An Input Variable To The AI Prompt
• Choose The Output Type And Select A Model
• Test The AI Prompt To Parse An Address String
• Create A SharePoint List To Store Parsed Address String Values
• Build A Power Automate Flow With A Create Text From GPT Action
• Run The Power Automate Flow To Save The Address Values To SharePoint
Introduction: Parse An Address String And Save To SharePoint List
A marketing manager has a list of customer addresses that must be saved to a SharePoint list. The manager uses an AI prompt to parse the address into a street address, a city, a state and a zip code.
Then uses Power Automate to save the address details to multiple columns in a SharePoint list.
Write An AI Prompt To Parse An Address Into JSON
Open Power Automate and go to the AI Prompts menu. Start to construct a new prompt by selecting the tile named Create text with GPT using a prompt.
Name the prompt Parse Address String.
Then add this text to the prompt. It tells GPT to output the response as a JSON and which fields to include. Also notice that the State is formatted as a two-character state code.
Parse this single line address into a JSON:
The JSON should have the following fields:
- StreetAddress
- City
- State (This is two-character state code of the address)
- ZipCode
Add An Input Variable To The AI Prompt
We want to pass an Address as a text string into the AI Prompt. Open the Input section of the right menu and add a new input variable named varAddressString.
Include this address as sample data:
8245 James St. Myrtle Beach South Carolina 29577
Then insert the newly created variable into the prompt.
The varAddressString variable should be placed as shown here.
Choose The Output Type And Select A Model
There are two more setup steps we must do before testing the prompt. First, select the output type as JSON.
Then choose the model. The most powerful model currently available in AI Prompts is GPT 4o.
Test The AI Prompt To Parse An Address String
Before we can save the prompt we are required to test it. Press the test prompt button.
The prompt response will appear as a JSON.
{
"StreetAddress": "8245 James St.",
"City": "Myrtle Beach",
"State": "SC",
"ZipCode": "29577"
}
Then save the custom prompt and close the menu. The prompt now appears in My Prompts tab which means it is ready to be used.
Create A SharePoint List To Store Parsed Address String Values
We need a SharePoint list to store the address data in. Create a new SharePoint list named US Addresses and include the following columns:
- StreetAddress – single line of text
- City – single line of text
- State – single line of text
- ZipCode – single line of text
Build A Power Automate Flow With A Create Text From GPT Action
With the prompt created, and the SharePoint list setup, we can now create a Power Automate flow to parse an address from a text string string and save the result to a SharePoint list. Start a new flow with a manual trigger.
Add an input to the flow trigger named varAddressString. The user will input the address string text when starting the flow.
Next insert an AI Builder – Create Text With GPT Using A Prompt action. Select the Parse Address String prompt we built earlier and supply the trigger input varAddressString into the varAddressString field
Then use the Create Text With GPT output to create a new SharePoint list item. Add a SharePoint – Create Item action, select the US Addresses list and supply the StreetAddress, City, State and ZipCode.
Run The Power Automate Flow To Save The Address Values To SharePoint
Test the flow to ensure it works. Input a valid US Address into the varAddressString field and select run flow.
The flow uses the address string to create text with a GPT using a prompt…
…and saves the output to a SharePoint list.
Did You Enjoy This Article? 😺
Subscribe to get new Power Apps & Power Automate articles sent to your inbox each week for FREE
Questions?
If you have any questions or feedback about Power Automate: Create Text With GPT & AI Prompts please leave a message in the comments section below. You can post using your email address and are not required to create an account to join the discussion.
Thanks Matthew, good example of using AI prompts in Power Automate. This is a really powerful tool that have a lot of different applications in Power Automate. Worth noting that using GPT 4o is 10 times more expensive than GPT 3.5.
Arlid,
Yes, as of this date in October 2024 the current pricing is:
GPT 3.5
$0.001 per 1k input tokens
$0.003 per 1k output tokens
GPT 4o
$0.01 per 1k input tokens
$0.03 per 1k input tokens
How does the licensing work for this? Do you use your own ChatGPT API access or is it paid for through MS? Does a user need a premium license?
Phil,
Licensing is consumption based. You pay Microsoft for AI Builder credits which can be used to create text with GPT. No OpenAI account is needed.
Premium licenses also come with a base amount of AI Builder credits. Check your current capacity in Admin Center before making a purchase.
You can always check the current pricing by searching for the power platform licensing guide on Google.
Current pricing is:
GPT 3.5
$0.001 per 1k input tokens
$0.003 per 1k output tokens
GPT 4o
$0.01 per 1k input tokens
$0.03 per 1k input tokens
Thanks for the info!
Hey, Thank you! I managed to ‘Parse these multiple lines of addresses into a JSON’ for UK addresses in SP! 🙂
DSammie,
Nice! Good on you to make it work for another locale 🙂