Search code examples
c#botframeworkchatbot

How to pick up channel data using C#


I'm sending data from the web chat client, to the Bot via channel data, the following way:

const store = window.WebChat.createStore({}, ({ dispatch }) => next => action => {
  if (action.type === 'DIRECT_LINE/POST_ACTIVITY') {
   // The channelData submitted here is very similar to HTTP cookies and vulnerable to forgery attack.
   // Make sure you use signature to protect it and verify the signature on the bot side.
   // To minimize unexpected behaviors, we recommend to treat the "action" object as if it is immutable.
   // We use simple-update-in package to update "action" with partial deep cloning.
   action = window.simpleUpdateIn(
     action,
     ['payload', 'activity', 'channelData', 'myCustomProperty'],
     () => 'Custom value'
   );
 }

 return next(action);
}); 

https://github.com/microsoft/BotFramework-WebChat/blob/master/samples/04.api/b.piggy-back-on-outgoing-activities/index.html

How do I access this data on the server side using C#?


Solution

  • You can access it under channelData which is present under context object,full path below

    dialogContext.Context.Activity.ChannelData