ChannelData Is Empty on Server Side
See original GitHub issueScreenshots
n/a
Version
lastest
Describe the bug
We are posting an event via DirectLine with channeldata. However, the channel data is empty on the bot side. I feel like I am missing something very basic but I cannot figure out what it is.
To Reproduce
CLIENT-SIDE
// create directLine variable
var dl = window.WebChat.createDirectLine({ "token": tokenResponse });
// render webchat control
window.WebChat.renderWebChat(
{
directLine: dl,
renderMarkdown: markdownIt.render.bind(markdownIt),
groupTimestamp: groupTimestamp,
styleOptions: styleOptions,
userID: userId
},
document.getElementById('webchat')
);
// post activity to start conversation and trigger welcome message
var activity = {
from: {
id: userId
},
name: 'startConversation',
type: 'event',
value: '',
channelData: {
"personId": userId,
"environment": window.location.host,
"usercontext": payloadUserContext,
}
};
dl.postActivity(activity).subscribe(function (id) {
if (console) {
console.log('"trigger requestWelcomeDialog" sent');
}
});
SERVER-SIDE
public override async Task OnTurnAsync(ITurnContext turnContext, CancellationToken cancellationToken = default)
{
_logger.LogDebug(turnContext.Activity.ChannelData); // always empty
}
Expected behavior
turnContext.Activity.ChannelData should contain object with data.
Additional context
[Bug]
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
ChannelData is returning null - Stack Overflow
I have tried back channel mechanism but failed to get any value from the server side inside ChannelData. I have script tag src="https://cdn....
Read more >Implement channel-specific functionality in Bot Framework SDK
To implement channel-specific functionality, you can pass native metadata to a channel in the activity object's channel data property.
Read more >Creating Channels - React chat - GetStream.io
You can achieve this by leaving the channel ID empty and providing channel type and members.
Read more >Work with channel data | Android Developers
The Android TV system database maintains records of channel data for TV inputs. In your setup activity, for each of your channels, ...
Read more >Configuring Server Side Tags In Google Tag Manager
Google introduced server-side tagging in 2020. By implementing a server ... You should see an empty tag assistant summary dashboard.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Consider using Web Chat’s store to update an activity when posted, as demonstrated in the 04.api/b.piggyback-on-outgoing-activities sample.
Please note: There are security considerations when posting potentially sensitive data from the page to the bot. As mentioned here, this can open you up to forgery attacks.
To send data back to the bot from the page, first add this script to your page:
Next, create the Web Chat store and filter on the action type for
DIRECT_LINE/POST_ACTIVITY
actions and pass in your data:Lastly, pass the store as a property in
renderWebChat()
:This does append the data to every outgoing message from the page to the bot. You will need to alter the code to fit your needs, if you only want the data sent with specific activities.
Hope of help!
Ok, I see it now. IT was confusing because Emulator and DirectLine trigger events differently. I moved my welcome code into OnEvent, and for specific Event Name I process user context.