Pass Custom Parameters from webchat control to bot framework

后端 未结 2 838
闹比i
闹比i 2021-01-24 20:04

So, I\'m currently using this:



  
    
2条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-24 20:59

    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();
    

提交回复
热议问题