
Announcements
In Copilot Studio, achieving the described functionality requires integrating some custom logic. Here's how it can be approached:
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:
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.
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:
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);
});
});
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 }, '*');
}
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:
In Copilot Studio:
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: