So, I\'m currently using this:
From Cilent Side
var d1 = window.WebChat.createDirectLine({ token })
window.WebChat.renderWebChat({
directLine: Object.assign({}, d1, {
postActivity: activity => {
var newActivity = Object.assign({}, activity, { channelData: { "param1": "test" } });
return d1.postActivity(newActivity);
}
}),
styleSet,
botAvatarInitials: 'CAB',
userAvatarInitials: 'You'
}, document.getElementById('webchat'));
})();
from BOt Framework
var channelObj = turnContext.Activity.ChannelData.ToString();
var channeldata = Newtonsoft.Json.Linq.JObject.Parse(channelObj);
var customdata = channeldata["param1"].ToString();
The other answer provided is helpful but it overwrites channelData. For others finding this answer and just wanting to send custom parameters, this will be helpful:
const originalDirectline = props.webchat.createDirectLine({
token,
})
const directLine = Object.assign({}, originalDirectline, {
postActivity: (activity: any) => {
const newActivity = Object.assign({}, activity)
newActivity.customParam = "custom value"
return originalDirectline.postActivity(newActivity)
}
})