I’m Prince Adimado, a proud Gold Student Ambassador from Ghana. As an active member of the Microsoft Learn Student Ambassadors program, I have organized and hosted numerous successful events, authored informative articles, and created helpful video tutorials.
Through the Microsoft Learn Student Ambassador program, I have gained valuable skills in event management, public speaking, and software engineering that I may not have otherwise obtained as a regular student. The program has given me a new sense of purpose in my career, and the confidence to speak at virtual meetings and engage with a global community. If you’re interested in becoming a Microsoft Learn Student Ambassador and unlocking these same benefits, be sure to check out this article or watch our informative video guide.
Have you ever wished for an AI language model that could complete text prompts with high accuracy and efficiency?
Well, ChatGPT is here to make your dreams a reality! Whether you’re a customer service representative or a content creator, ChatGPT can help you streamline your response process and improve your productivity.
The ChatGPT API (GPT-3) was announced in June 2020, making it available for developers to use
in their applications. Developers have developed many many applications with the API, from the web to mobile applications and now it has been integrated with the Microsoft Power Platform.
In this blog article, I will guide you through how to build a text-completion workflow using Microsoft Forms, Outlook, and Power Automate. I realized that sometimes when opening the ChatGPT web page, one needs to have good internet, or sometimes the page is down. So I thought to myself, why don’t I build a workflow using emails? Where I can submit a prompt via a form, then receive an email with the results.
This solution is convenient in areas where internet connectivity is low. So, buckle up and get ready to discover how ChatGPT can revolutionize your workflow!
We have been hearing a lot about ChatGPT but what is it about?
ChatGPT is an AI language model developed by OpenAI, which is designed to generate human-like responses to text prompts in natural language. ChatGPT is a derivative model of OpenAI’s GPT (Generative Pre-trained Transformer) language model, which has been pre-trained on a vast amount of text data to learn the patterns and structures of natural language.
The ChatGPT model has been fine-tuned for specific tasks such as question-answering and chatbot response generation, making it particularly well-suited for these types of applications. With its advanced language generation capabilities, ChatGPT can be used in a wide range of industries, including customer service, healthcare, education, and entertainment, to automate tasks and improve the user experience.
Building the workflow with Power Automate.
For this Power Automate workflow, we will need Microsoft Forms, Outlook and ChatGPT API, and the ChatGPT connector in Power Automate.
What comes to mind when you hear about a Power Automate workflow?
Power Automate is a cloud-based service provided by Microsoft that allows users to create automated workflows across multiple applications and services. A Power Automate workflow is a series of automated steps or actions that are triggered by a specific event or condition, such as a new email arriving in a mailbox, a new item being added to a SharePoint list, or a new form submission. These workflows can be created using a visual interface, which allows users to drag and drop pre-built connectors and actions to build the workflow.
Power Automate provides a wide range of connectors that allow users to integrate with many different applications, services, and data sources, including Microsoft Office 365, SharePoint, OneDrive, Dynamics 365, and many more. With Power Automate, users can automate repetitive or manual tasks, improve collaboration and communication, and streamline business processes.
Hey, you may have realized I’m explaining terms and I’m explaining the steps in building this use case. We have to keep in mind that this use may be someone’s first workflow built with Power Automate, hence the person must understand the terms used.
With this said and done let’s start building the flow.
If you’re new to Power Automate or Power Platform. You need to have a license to use these tools. Because Microsoft is kind and generous, they have a program that I and many others are part of, called the Microsoft 365 Developer Account. Once you sign up, you will get access to Microsoft 365 apps to help you learn and develop solutions such as these.
Get your Microsoft 365 Developer Account here.
Step 1: Create your form with Microsoft Forms
Remember, we will be using a form to serve as a prompt to the ChatGPT API, create a form with Microsoft Forms with these fields, “Question(Prompt)” and “email address”. Remember to set these two fields to required.
Once you are done creating the form, on the top-right side of your screen you will see a green button called “Collect responses”. Click to open it, when the page is open.
Under “Send and collect response”, set the option to “Anyone can respond”.
Why should you change this setting, Microsoft Forms by default is set to “Only people in my organization can respond”, which means only people with the domain address can access the form and will prevent anyone who is not part of that organization.
So setting it to anyone who can respond will make anyone in or outside the Microsoft 365 organization can respond. This means, your workflow can use used by anyone with the link.
Copy the full link to your form, then open any URL shortener website you normally use. For me I used Bitly. Then shorten the form link. If you copy the shortened link in Microsoft Forms, Bitly will throw an error. So copy the full link.
Step 2: Create a flow in Power Automate
Once you’re done building your form, still on Microsft 365 home page, use the app launcher to open the all apps if you don’t see Power Automate when you click the button.
On the Power Automate home page, click on “Create” to start creating your workflow.
You can see the types of flows you can create using Power Automate, but for this use case, we’ll be using the first option which is called “Automated Cloud Flows. Learn more about these types of flows here.
Give your flow a name and select the first trigger option which is, “When a new response is submitted”. Then click on “create” to create your flow.
Step 3: Set the Form ID
In this step, select the form you just created as the Form ID for the trigger connector.
Next, select the same “Form ID” and “Response ID”, click on the dynamic content, and select “Response ID”.
Step 4: Create a new connection with OpenAI Connector
Add a new action and search for “OpenAI”, then select “GPT3 Completes your prompts”.
Now you will need to access the ChatGPT API. You need to have an Open AI account, the account you use to access ChatGPT, head over to this page here
Create your API key, once it has been created copy the key and save it somewhere you will remember. Once you have your ChatGPT API key now, head over to Power Automate.
To use this connector you need two things, the connection name and the API key.
Give the connection a name, and for the API Key use, “Bearer YOUR API KEY”.
That is, “Bearer1234567890abcdefgh” where “1234567890abcdefgh” will be your API Key.
Once you’re done, click “Accept” to create a new connection with the connector.
Follow how I used I entered the values into the fields.
One thing I will like you to note is that, in the User field, you need to provide a unique identifier of the user will you use the workflow. To do this I use the email address for that field.
Also, the max_token refers to the number of tokens or words that the ChatGPT model will generate in response to a given input text prompt.
When you use the ChatGPT connector in Power Automate, you provide an input text prompt that the model uses to generate a response. The max_tokens parameter allows you to control the length of the generated response by setting an upper limit on the number of tokens or words that the model can generate.
For example, if you set the max_tokens parameter to 50, the model will generate a response of up to 50 tokens or words. If the model generates a response that exceeds this limit, it will truncate the response and return only the first 50 tokens.
The connector allows a maximum of 4000 tokens per input text prompt. So don’t set it to a maximum number like 100 or 200. Get more information on how to use this connector here.
Step 6: Connect the Send an Email Outlook connector
We are left with our last connector, which is after we submit the form, we should immediately receive our response via email.
To do this, we will need to use the Outlook “Send an email (V2)” connector.
Search for Outlook and click on Outlook for business. You will see a lot of connectors that Outlook can perform. Scroll down and select the “Send an email (V2)” connector.
Craft your email message and use add dynamic content to your email.
Make sure to add the Text(Completion Text), which is the answer generated by the AI.
With this said and done. Let’s test our flow to see whether it works.
On the top right corner, you will see Test, but before you do text your flow you must save it first. Click on “Save” to save the flow.
Now click on test, you can’t test your flow automatically because it has never run before. So select “Manually” then click on “Test” to test your flow.
Every flow needs a trigger, in our flow, our trigger is when a new form is submitted, let something happen. So go ahead and submit a response. Then check Power Automate to see how it’s running. After the flow has run successfully, check your email for your results.
If you have been able to make it this far, congratulations. For some, this may be your first Power Automate flow. Keep on building exciting solutions with Power Automate and Power Platform and after building do well to share what you have learned on LinkedIn and any other platform. Also, do well to share this article with your community and tag me on Linkedin (@Prince Adimado) and on Twitter (@_primado) so that we connect to celebrate our achievements.
Make sure to like this article if you find it helpful.