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

Community site session details

Session Id :
Service | Customer Service, Contact Center, Fie...
Unanswered

issue with sending setContextProvider To the bot its self

(0) ShareShare
ReportReport
Posted on by 6
Subject: Custom Context Variables Not Passing from Omnichannel Live Chat Widget to Copilot Studio Bot at Chat Start
Hi everyone,
I'm trying to send a UserId to my Copilot Studio bot at the beginning of the chat (not just when an agent answers). The goal is to implement AI-powered personalized responses based on user account data from the moment the chat starts.
What I'm Trying to Achieve:
Send UserId (2108078 - temporary hardcoded value) to bot immediately when chat starts
Bot should receive this data to provide personalized AI responses
Context should be available for bot logic, not just agent summary
Current Implementation:
The context variables work perfectly and appear in the agent summary when a human agent accepts the chat. The issue is specifically with the bot not receiving this context data at chat initialization.

JavaScript (Working - logs successfully):
<script>
function contextProvider() {
    return {
        'UserId': { 'value': '2108078', 'isDisplayable': true }
    };
}
 
window.addEventListener("lcw:ready", function() {
    Microsoft.Omnichannel.LiveChatWidget.SDK.setContextProvider(contextProvider);
    console.log('Context Provider registered'); // ✅ This logs successfully
});
</script>
Omnichannel Configuration:
 Context variable UserId (Text type) defined in workstream
Bot configured as "Smart assist bot": "Copilot Omnichannel PVA Demo Bot"
 Workstream set to "Push" mode
Context variables section shows UserId properly configured
Copilot Studio Configuration:
 Created separate topic "Set context variables" (not invoked, as per documentation)
Variable Global.UserId configured with:
Global scope (any topic can access)
External sources can set values 
Reference: "Get value from this node if empty"
opilot Studio Configuration:
Created separate topic "Set context variables" (not invoked, as per documentation)
Variable Global.UserId configured with:
Global scope (any topic can access)
External sources can set values ✅
Reference: "Get value from this node if empty"
The Problem:
❌ Global.UserId remains empty in Copilot Studio
❌ System.Activity.ChannelData only contains technical data:
{
  "fromUserId": "XXXXXX",
  "microsoft.azure.communication.chat.bot.contenttype": "azurebotservice.command",
  "sourceChannelId": "omnichannel",
  "tags": "ChannelId-lcw,OmnichannelContextMessage,Hidden"
}
 
I have the same question (0)
  • AT-07091109-0 Profile Picture
    6 on at
    issue with sending setContextProvider To the bot its self
    Thank you for your help !
    Ok - so @Daniyal Khaleel - how can i in sure that the Value will insert to the global userid ? 
  • Daniyal Khaleel Profile Picture
    491 on at
    issue with sending setContextProvider To the bot its self

    you did the right thing by creating a Global variable (Global.UserId) with "external sources can set values" and a “Set context variables” topic (which doesn’t need to be invoked).
    The missing link is: Copilot Studio will not auto-populate Global.UserId unless you explicitly push it into the bot’s conversation payload when the session starts.

    That’s why you’re only seeing System.Activity.ChannelData (technical session info like widget/session IDs, locale, channel, etc.)  that data comes directly from Omnichannel/ACS, not from your custom injection.

    What’s Happening
    Global variable is defined correctly
    External sources can set values 
    But no value is ever assigned at runtime because Omnichannel chat widget (or ACS Web Chat) hasn’t been told to push UserId into the bot session.
    Result: Bot sees it as null/empty until agent handoff, because only at escalation does Omnichannel enrich the transcript with CRM session context.

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…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

Leaderboard > Service | Customer Service, Contact Center, Field Service, Guides

#1
Daniyal Khaleel Profile Picture

Daniyal Khaleel 67

#2
Tom_Gioielli Profile Picture

Tom_Gioielli 28 Super User 2025 Season 2

#3
Gerardo Rentería García Profile Picture

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

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans