The recent developments with AI have presented several opportunities for developers to build intelligent solutions. How can rising developers take positive advantage of this with the help of Power Platform?
You are a rising developer working for a specific company or part of developer/student community that constantly works with new trends and technologies. The key ask from your company/community is to compile a weekly newsletter with the latest trends about a specific technology (.NET, Python, React or Power Platform) for developers to stay up to date and make decisions on what new features, if any, should they deep dive on.
Here are key learn materials for this solution make sure to complete them:
You decide to build a solution that will do the heavy lifting for by taking advantage of ChatGPT3 and Power Platform.
Animation showing solution Preview
Watch the Step-by-Step Guide on demand.
Building the solution
- Go to the OpenAI website, click on API on the navigation bar and signup/sign in.
- Once signed in, click on your profile and then click on View API Keys.
- On the API page, click on Create new secret to generate the API key and then copy and paste on a notepad we will use it later.
- Navigate to the Adaptive Card Designer and then click on New Card.
- Paste the following JSON code onto the Card Payload Editor.
"text": "Power Platform Weekly Newsletter",
"placeholder": "Please enter the search text for the newsletter",
- The above will generate an adaptive card that you will use when building the solution to take the search text that will be sent to ChatGPT3.
- Go to the Stripo website, click on Sign up or Login.
- Once logged in, you will be met with a dashboard. Click on New Message to generate a new Newsletter from scratch or from a template.
- You will then have the option to choose from a variety of templates, choose the best one for you.
- You will be presented with a canvas to edit this template, once done with your edits you can click on Export.
- On the export pop-up, choose HTML to export your template.
- On the next pop-up, choose Show HTML Code. You will see the html code, then click on Copy to Clipboard. We will use this code later.
Let’s start building the actual solution to generate this newsletter!!!
- Sign in onto Power Automate.
- Click on Create and choose a Scheduled Cloud Flow.
- Give your flow a Name, choose the Starting Time and the set the Occurrence to 1 Week then choose Monday.
- After the flow is created click New Step and search for Get an @mention token for a tag then choose it. Provide the Team ID and Tag ID. Please not that you have to set tags on teams for the team you are using.
- Then add a new step, search for Post a message in a chat or channel. For Post as choose User, for Post in choose Channel and then specify the Team and Channel ID. On the message box add the dynamic content from the Get an @mention token for a tag action to mention the tag/team in teams.
- Add a new step, search for Post an adaptive card and wait for a response action. For Post as choose Flow Bot, for Post in choose Channel, for message paste the json code you copied from the pre-steps, then specify the Team and Channel ID. This way you flow will wait for a search text before it generates the newsletter.
- Add a new step, search for OpenAI and choose the ChatGPT3 Completes your prompt action. Provide a chosen and meaningful connection name, for API Key type in Bearer then leave a space and paste in the secret you copied on number 3 of the pre-steps and click Accept.
- Once the connection is established, make sure you have chosen DaVinci as your engine. For prompt, choose the txtSearch dynamic content of the Post an adaptive card and wait for a response action and put max tokens and 1000. This will enable your flow to generate a newsletter from the text coming from teams using ChatGPT3
- Add a new step, search for Send an Email V2 and provide the Recipient and Subject. For the message/email body, add in the Text dynamic content from the ChatGPT3 Completes your prompt action.
- Save your flow and run it but you might need to adjust your trigger for you to see the results right aways! Congrats you’ve built your Power Platform + Teams + ChatGPT3 solution!
Advanced steps for a precise newsletter
This part is more of extra stuff that you can do make your newsletter a bit more accurate from ChatGPT3.
- First up, let’s update the action in step 8. For the prompt add in the text shown in the image below. This will extract key entities from the search text, example "What's up with PowerApps and Power Automate lately " and the PowerApps and Power Automate entities will be extracted to get accurate results either from official PowerApps or Power Automate twitter accounts or from credible Power Platform developer's tweets.
- Then add a new step, search for Search Tweets and add that action. For search text, add in the Text dynamic content from ChatGPT3 Completes your prompt action. Click on show advanced options and set the max results to 10. This will search tweets that match the extracted entities from the previous steps, i.e if you were generating a newsletter for Power Platform news it would search all tweets using the #PowerPlatform or tweets from the official Power Platform twitter account.
- Add a new step, search for Filter Array. For the From, add in the Body dynamic content from the Search Tweets action. For the Map, you can map it similar to the following image or to your choosing. We are doing this to reduce the number of tokens from the tweets so that we do not exceed the ChatGPT3 token limit which is 4000.
- Add a new step, search for Compose add in the Outputs dynamic content from the Filter Array action as input.
- Add a new step, search for OpenAI and choose the ChatGPT3 Completes your prompt action. This time for the Prompt you will give it a command similar to the following image or to your choosing and set the max token to 2000. Set the Stop Item – to Tweets and Stop Item – 2 to Newsletter This step will generate the newsletter for you based on the command.
Add a new step, search for Compose and add in the Text dynamic content from the ChatGPT3 Completes your prompt 2 action as your Input. Rename your action from Compose to Get ChatGPT Outputs.
Add a new step, search for Compose and add in the following expression as your Input. This will convert the output from ChatGPT to a string and we want to extract only the text. Rename this action to Convert Outputs to String.
- Add a new step, search for Compose and add in the following expression as your Input. This will allow you to remove the HTML New Line (“\n”) and replace it with HTML Line Breaks tag (<br>) so that you can have a proper format for your newsletter. Rename this action to Replace New Line with Line Breaks.
- Add a new step, search for Compose and add in the following expression as your Input. This will allow you to remove unwanted characters from the text, so that the newsletter is properly formatted. Rename this action to Remove Unwanted Characters.
- Add a new step, search for Send an Email V2 and provide the Recipient and Subject. For the message/email body, paste in the HTML code copied from step 12 on the pre-steps and add in the Outputs dynamic content from the Remove Unwanted Characters action (the previous one). Make sure you add the dynamic content in the right place for a nice looking, well formatted Newsletter.
Congratulations! You have completed a Power Platform + Teams + ChatGPT3 solution! Would love to see how you can enhance this solution or a new solution that you have built using ChatGPT3 and Power Platform. Share in the comments.