web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Answered

Implementing GPT-Like Structure for Generating Random Jokes in Power Virtual Agent Using Azure AI

(2) ShareShare
ReportReport
Posted on by 59
I'm currently working on Power Virtual Agent and have a requirement to integrate a feature that generates random jokes, similar to the conversational style of GPT models. My initial plan is to leverage Azure AI services for this implementation. However, I'm unsure about the specific steps and techniques required to achieve this.

Could anyone provide guidance or ideas on how to proceed with integrating Azure AI to implement a GPT-like structure for generating jokes within Power Virtual Agent? Any insights, best practices, or recommended Azure services to use for this purpose would be greatly appreciated. Thank you!
 
 
I have the same question (0)
  • Verified answer
    Daivat Vartak (v-9davar) Profile Picture
    7,835 Super User 2025 Season 2 on at
    Hello Sohom Ghorai,
     

    You're on the right track! Using Azure AI services is the best way to add a GPT-like joke generation feature to your Power Virtual Agent (PVA) bot. Here's a breakdown of how to achieve this, along with steps and considerations:

    Recommended Azure AI Services:

    1. Azure OpenAI Service:

      • This is the most direct and powerful approach. It gives you access to GPT models like GPT-3.5 Turbo or GPT-4, specifically designed for conversational AI.

      • Advantages:

        • Excellent for generating natural-sounding, contextually relevant jokes.
        • Highly customizable prompts for tailoring the humor.
        • Easy integration with PVA via Power Automate. 

      • Considerations:

        • Requires access to the Azure OpenAI Service (which may require an application).
        • Cost associated with API usage.

        •  

    2. Azure Cognitive Services for Language (Question Answering):

       

      • If you have a pre-existing dataset of jokes or want to use a knowledge base, Question Answering could be suitable.

      • Advantages:

        • Good for retrieving jokes from a structured knowledge base.
        • Lower cost than Azure OpenAI Service for simple joke retrieval. 

      • Considerations:

        • Requires a curated knowledge base of jokes.
        • Less flexible for generating completely new jokes. 

        •  

    3.  

    Implementation Steps:

    1. Set Up Azure OpenAI Service (Recommended):

      • Create an Azure OpenAI Service resource in your Azure portal.
      • Deploy a GPT model (e.g., GPT-3.5 Turbo).
      • Obtain your API key and endpoint. 

    2. Create a Power Automate Flow:

      • In PVA, create a topic for the "joke" intent.
      • Add an "Action" node to the topic.
      • Select "Create a flow."

      • In Power Automate:

        • Use the "Power Virtual Agents" trigger.
        • Add an "HTTP" action to call the Azure OpenAI Service API.

        • Configure the HTTP action:

          • Method: POST
          • URI: Your Azure OpenAI API endpoint.

          • Headers:

            • Content-Type: application/json
            • api-key: Your Azure OpenAI API key 

          • Body:

            • {
                    "messages": [
                        {
                            "role": "system",
                            "content": "You are a witty comedian that tells short jokes."
                        },
                        {
                            "role": "user",
                            "content": "Tell me a joke."
                        }
                    ],
                    "temperature": 0.7,
                    "max_tokens": 150
                }

              • Adjust temperature for creativity (higher = more random).
              • Adjust max_tokens for joke length. 
               
             

        • Parse the JSON response from the Azure OpenAI API.
        • Use a "Respond to Power Virtual Agents" action to send the joke back to the bot.

        •  

    3. Integrate the Flow in PVA:

      • Back in PVA, select the Power Automate flow you created.
      • Use the output variable from the flow to display the joke in the bot's response. 

      •  

    4.  

    Key Considerations:

    • Prompt Engineering:

      • Craft clear and specific prompts for the GPT model.
      • Use system messages to define the bot's persona (e.g., "You are a witty comedian").
      • Experiment with different prompt variations to get the desired humor. 

    • Safety and Moderation:

      • Use Azure OpenAI's content filtering to prevent the generation of offensive jokes.
      • Implement additional moderation logic if needed. 

    • Error Handling:

      • Add error handling to your Power Automate flow to gracefully handle API failures. 

    • Cost Optimization:

      • Monitor your Azure OpenAI API usage and costs.
      • Optimize prompts and token usage to reduce costs. 

    • Context Management:

      • If you want the bot to remember previous jokes or maintain a conversation, you'll need to implement context management (e.g., using PVA variables or session storage). 

    • Testing:

      • Thoroughly test your bot with various joke requests. 

      •  

    •  

    Example Flow using Cognitive Services for Language (Question Answering):

    1. Create a knowledge base with question and answer pairs of joke questions and joke answers.
    2. Use the cognitive services connector in Power Automate to query the knowledge base.

    3.  

    Important Notes:

    • Azure OpenAI Service gives very good results, and is the recommended service.
    • Remember to handle the json from the response from the Azure OpenAI service correctly, so that the correct part of the json is displayed to the user.
    • Be sure to test the bot extensively.

    •  

    By following these steps and considerations, you can create a fun and engaging joke-generating feature in your Power Virtual Agent bot.

     
    If my answer was helpful, please click Like, and if it solved your problem, please mark it as verified to help other community members find more. If you have further questions, please feel free to contact me.
     
    My response was crafted with AI assistance and tailored to provide detailed and actionable guidance for your Microsoft Dynamics 365 query.
     
    Regards,
    Daivat Vartak

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 170 Super User 2025 Season 2

#2
#ManoVerse Profile Picture

#ManoVerse 61

#3
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 52 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans