botframework - 如何使用钩子向消息的 channelData 添加值
问题描述
我正在使用Customization Plain UI 示例,需要将自定义数据添加到 channelData。使用此示例时,实现此目的的最佳方法是什么?
解决方案
您可以将存储中间件添加到自定义纯 UI示例,该示例通过将自定义存储作为道具传递给Composer
组件来添加自定义通道数据。有关更多详细信息,请查看Piggyback Data Web Chat Sample。
export default () => {
...
const store = useMemo(() => createStore({}, () => next => action => {
if (action.type === 'DIRECT_LINE/POST_ACTIVITY') {
action = simpleUpdateIn(
action,
['payload', 'activity', 'channelData', 'email'],
() => 'johndoe@example.com'
);
}
return next(action);
}), []);
...
return (
<React.Fragment>
...
{!!directLine && (
<Components.Composer directLine={directLine} store={store}>
<PlainWebChat />
</Components.Composer>
)}
</React.Fragment>
);
};
推荐阅读
- c++ - 我的 getline 是否阻止我的代码循环?
- java - 我正在我的应用程序中构建选项卡布局,在调试时我不断收到此错误,阻止应用程序工作并不断崩溃,我该怎么办?,
- swift - 线程 1:“UICollectionView 必须使用非零布局参数初始化
- security - Delphi中的缓冲区溢出漏洞
- python - 放入 main() 定义时代码不起作用
- jquery - 当用户到达页面中的特定点时如何打印内容?(不依赖于任何类或 ID 元素)
- java - 使用 ObjectRocket 插件将带有 MongoDB 应用程序的 jHipster 部署到 Heroku
- java - 单击按钮时Android应用程序崩溃
- selenium - 如何管理手动打开的选项卡
- mysql - ORM 如何从数据库中获取数据