linkdin
Elazar Ohayon
March 26, 2023

ChatGPT With Microsoft Teams

ChatGPT is an artificial intelligence chatbot powered by natural language processing (NLP) technology. It is designed to provide an interactive and engaging experience for users by understanding their questions and providing relevant answers. ChatGPT is capable of understanding and responding to a wide range of topics, from general knowledge to specific topics. It can also provide personalized recommendations based on user preferences.

“It’s crucial to understand that the API relates to GPT-3, not ChatGPT, which leverages OpenAI’s GPT-3.5. For those who frequently use ChatGPT through the web interface, it’s worth noting that the API may have some limitations to be mindful of. However, as heavy users of Teams, it’s convenient to be able to quickly ask simple questions through ChatGPT.”

Credit To – Adam deMont for this solution.

How to Add ChatGPT to Microsoft Teams

Requirements:

  • Create an OpenAI account.
  • Power automate premium license ( if you don’t have a license you can use it with the Trial version)

create an account in openAI.

after you sign in go to > view API keys and create a new secret key.

No alt text provided for this image

click on – “Create new secret key” and keep your private key recommended for backup. if you don’t remember just create a new secret.

No alt text provided for this image

go to > PowerAutomate > Create > Automated cloud flow

No alt text provided for this image

Choose flow name – Example – ‘TeamsChatGPT’.

for the ‘Flow trigger‘ choose “when keywords are mentioned” and click create.

No alt text provided for this image
  • Message typeChannel
  • Keywords to search forChatGPT
  • Select the Team and Channel you want users to be able to submit questions into to get responses from ChatGPT
No alt text provided for this image

click on + ‘Add an action‘ choose ‘apply to each

No alt text provided for this image

select ‘value‘ and click on ‘add an action’

No alt text provided for this image

choose “Get message details”

  • Message: Message ID
  • Message type: Channel
  • Select your Team and Channel
  • Parent message ID: “Reply to message ID”
No alt text provided for this image

select action ‘HTTP’

  • Method: POST
  • URI: https://api.openai.com/v1/completions
  • HeadersAccept: application/xml
  • HeadersContent-Type: application/json
  • HeadersAuthorization: Bearer <API_key_goes_here>

Example – Bearer vvkoh5lqOPAGT2452342343BlbkFJPjHIFHXyRVdqLBCZABrl522526w2

  • Body:

Note

when you copy the JSON maybe it will change the quotes to curly quotes.

they should be straight.

{

 "model": "text-davinci-003",

 "prompt": "@{outputs('Get_message_details')?['body/body/content']}",

 "max_tokens": 2000,

 "temperature": 0

}

No alt text provided for this image

after you finish add the last action.

  • For the final action, choose ‘Reply with a message in a channel’
  • Post as: Choose Flow bot or User
  • Post inChannel
  • Message ID@{items(‘Apply_to_each’)?[‘replyToMessageId’]}
  • Select the same Team and Channel as the trigger
No alt text provided for this image
  • MessageUse the expression body(‘HTTP’)?[‘choices’][0]?[‘text’]
No alt text provided for this image

when you are done implementing the flow save the flow and try to run it from the channel.

At the beginning of this flow, we create “keywords to search for” for example, I use – ‘ChatGPT’

No alt text provided for this image

Test

“Hey ChatGPT, what the capital of Israel is?”

No alt text provided for this image

“Hi ChatGPT, please write me a script in PowerShell to enable phone numbers for multiple users.”

No alt text provided for this image