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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Copilot Studio / Chatbot Answer Questio...
Copilot Studio
Answered

Chatbot Answer Questions Based on User Webpage Activity

(0) ShareShare
ReportReport
Posted on by 2
Hey, I want to know if this is a possibility for a Copilot Studio chatbot.
 
Basically, when a user clicks on a link inside a website, I want the chatbot to automatically know that the question the user will ask is related to the link they have clicked on (the chatbot was already given the knowledge of the contents of each link in the website).
 
So, instead of having the user asking "Can you tell me content X about link Y?", I want the chatbot to ask "What question do you have about Y?" as soon as the user clicks on link Y and is redirected to the contents in the link.
 
Is it possible to do this natively in Copilot Studio? Or would I require JavaScript?
Categories:
I have the same question (0)
  • Verified answer
    VASANTH KUMAR BALMADI Profile Picture
    266 on at

    In Copilot Studio, achieving the described functionality requires integrating some custom logic. Here's how it can be approached:

    Native Capabilities in Copilot Studio

    Copilot Studio is powerful for building conversational agents, but it does not natively handle events triggered by external user actions (like clicking a link on a website) without some external integration. Out-of-the-box, it:


    • Responds to user inputs and queries.

    • Leverages knowledge sources to provide relevant information.

    • Offers context-aware responses based on the conversation history.

    However, the functionality of automatically detecting a user's context based on their interaction with a website (like clicking a link) is not directly supported.

    Customizing with JavaScript and Web Integration

    To achieve your goal, you would need JavaScript to handle the user's interaction with the webpage and send context information to the chatbot. Here's a high-level approach:

    1. Track the Link Click Event:

    Use JavaScript on your website to track when a user clicks on a specific link. For example:

    document.querySelectorAll('a').forEach(link => {
        link.addEventListener('click', (event) => {
            const linkContext = event.target.textContent || event.target.getAttribute('href');
            sendContextToChatbot(linkContext);
        });
    });

    2. Send Context to the Chatbot:

    Pass the context (e.g., the content of the clicked link) to the chatbot. This can be done by appending the context as metadata or an initial message when the chatbot session starts.

    Example with an iframe chatbot:

    function sendContextToChatbot(context) {
        const chatbotFrame = document.getElementById('chatbot');
        chatbotFrame.contentWindow.postMessage({ type: 'linkClick', context }, '*');
    }

    3. Update the Chatbot's Prompt:

    Modify the chatbot to recognize the context. If you’re embedding the chatbot in your webpage using an iframe or JavaScript SDK, the chatbot can be configured to handle the passed context dynamically.

    Example:


    • Set an initial message like: "What question do you have about [context]?" based on the provided context.

    • Alternatively, update the knowledge source or parameters to focus the chatbot's responses on the specific topic.

    4. Handle Dynamic Context in Copilot Studio:

    In Copilot Studio:


    • If your chatbot leverages APIs or custom functions, you can process the passed context to tailor the chatbot's response.

    • Use a "pre-prompt" or custom initialization logic (if supported) to set the chatbot's context.

     

    Practical Considerations


    • User Experience: Ensure the chatbot doesn’t overwhelm the user by automatically initiating a conversation unless it’s clear the interaction is intended.

    • Privacy: Be mindful of what data is tracked and sent to the chatbot to comply with privacy regulations like GDPR or CCPA.

    • Fallback Handling: Include logic to handle cases where the context isn't available or recognized.
     
     

    Summary

    While Copilot Studio cannot directly handle event-triggered interactions, combining its capabilities with JavaScript on your website can enable the desired behavior. You'll need to:


    1. Use JavaScript to detect link clicks and send context to the chatbot.

    2. Configure the chatbot to use the passed context for initializing conversations.

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Copilot Studio

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 270 Super User 2025 Season 2

#2
Romain The Low-Code Bearded Bear Profile Picture

Romain The Low-Code... 181 Super User 2025 Season 2

#3
S-Venkadesh Profile Picture

S-Venkadesh 93 Moderator

Last 30 days Overall leaderboard