How to use ChatGPT in Microsoft Teams.(Power Automate Cloud flow)
Introduction of how ChatGPT replies to Teams chats using Power Automate (Crowd flow).
Contents
Steps
Get the ChatGPT API key (secret key) in beforehand.
Then create an Automated cloud flow with a When a new channel message is added Trigger.
For the trigger, set the Team and Channel you want ChatGPT to reply to.
Then set up the Initialize variable Action.
Specify APY_KEY for Name, String for Type, and API key for Value.
Set up an HTTP Action.
Set up as follows.
Parameter | Value |
---|---|
Method | POST |
URI | https://api.openai.com/v1/completions |
Header, line 1, left | Content-Type |
Header, line 1, right | application/json |
Header, line 2, left | Authorization |
Header, line 2, right | Bearer @{variables('APY_KEY')} |
Body | { "model": "text-davinci-003", "prompt": @{triggerOutputs()?['body/body/content']}, "max_tokens": 2024, "temperature": 0, "top_p": 1 } |
Set up a Reply with a message in a channel Action.
項目 | 値 |
---|---|
Post as | Flow bot |
Post in | Channel |
Message ID | @{triggerOutputs()?['body/id']} |
Team | Same Team as the Trigger. |
Channel | Same Channel as the Trigger. |
Message | Specify the expression below. trim(body('HTTP')?['choices'][0]?['text']) |
This completes the flow. Enter a message on the designated channel and ChatGPT will reply. Triggers are generally time-delayed by about 5 minutes.
Discussion
New Comments
No comments yet. Be the first one!