如何将文本注入Microsoft botframework-webchat的React组件?(How to inject text in to React component of Microsoft botframework-webchat ?)
我想在Microsoft chatbot中添加和发送消息,而无需在Bot窗口底部的textArea上键入该消息。 我需要把这个消息作为反应组件的一个道具(botframework-webchat)。
我尝试了此链接提供的建议,但对我无效。
我怎样才能做到这一点?
我试过这个。
import { Chat } from "botframework-webchat"; class ChatBox extends Component { componentDidMount() { document.getElementsByClassName('wc-shellinput')[0].value = "testMsg" document.getElementsByClassName('wc-send')[0].click() } render() { return ( <React.Fragment> <div> <Chat directLine={{ secret: "...." }} user={{ id: "Test" }} bot={{ id: "Demo" }} resize={"detect"} ref="chatBox" /> </div> </React.Fragment> ) } }
I want to add and send a message in Microsoft chatbot without typing that message on textArea which is at the bottom of the Bot window. I need to give the message as a props to the react component (botframework-webchat).
I tried suggestions given in this link and it does not work for me.
How can I do that?
I tried this.
import { Chat } from "botframework-webchat"; class ChatBox extends Component { componentDidMount() { document.getElementsByClassName('wc-shellinput')[0].value = "testMsg" document.getElementsByClassName('wc-send')[0].click() } render() { return ( <React.Fragment> <div> <Chat directLine={{ secret: "...." }} user={{ id: "Test" }} bot={{ id: "Demo" }} resize={"detect"} ref="chatBox" /> </div> </React.Fragment> ) } }
原文:https://stackoverflow.com/questions/50522576
最满意答案
当用户点击提醒时,它会在指定页面上导航。 这是提醒的默认操作。 您只需在添加之前在提醒对象中指定导航uri。 这是一个例子
Uri navigationUri = new Uri("/ShowDetails.xaml", UriKind.Relative); Reminder reminder = new Reminder(name); reminder.Title = titleTextBox.Text; reminder.Content = contentTextBox.Text; reminder.BeginTime = beginTime; reminder.ExpirationTime = expirationTime; reminder.RecurrenceType = recurrence; reminder.NavigationUri = navigationUri; // Register the reminder with the system. ScheduledActionService.Add(reminder);
还有一件事可以通过提醒而不是警报来完成。
When A user taps on the reminder it navigates on a specified page. That is default operation of reminder. You just have to specify a navigation uri in a reminder object before adding it. Here is an example
Uri navigationUri = new Uri("/ShowDetails.xaml", UriKind.Relative); Reminder reminder = new Reminder(name); reminder.Title = titleTextBox.Text; reminder.Content = contentTextBox.Text; reminder.BeginTime = beginTime; reminder.ExpirationTime = expirationTime; reminder.RecurrenceType = recurrence; reminder.NavigationUri = navigationUri; // Register the reminder with the system. ScheduledActionService.Add(reminder);
One more thing this can be done only with reminders not alarms.
相关问答
更多-
此语法意味着“实例化”一个大小为10的Reminder的空数组,并将其分配给名为reminder变量: reminder = new Reminder[10]; 这个意味着创建单个Reminder实例并将其分配给名为reminder的Reminder变量(不是数组): reminder = new Reminder(name); “ 如何将这两者结合起来 ”实际上并不是一个明确的要求。 无论如何,这演示了如何创建Reminder实例并根据注释中发布的链接将它们存储在数组的每个元素中: reminder ...
-
使用html5(提醒应用)访问电话警报(本机资源)(Access phone alarm (native resources)using html5 (Reminder app))[2022-07-13]
经过漫长的运行过程后,我设法为Android设备提供解决方案。 1)使用javascript访问本机代码是可能的 2)使用javascript界面引发xss漏洞的威胁,但在最新API级别19中消除了这一点。 (阅读更多...) 让代码说话; MainActivity代码优先 @SuppressLint({ "JavascriptInterface", "SetJavaScriptEnabled" }) public class MainActivity extends DroidGap 1)onCreat ... -
从Windows Phone 8上的SMS自动启动应用程序(Launch application automatically from an SMS on Windows Phone 8)[2022-04-19]
由于某些安全原因,这在Windows Phone 8上是不可能的。 这可能在Windows Phone 8.1中可能。 我读到8.1支持第三方SMS客户端的地方。 这可能意味着收到新短信时可能会触发某些事件。 我不确定。 我仍然建议你使用推送通知。 This is not possible on the Windows Phone 8 due to some security reasons. This might be possible in Windows Phone 8.1. I read somew ... -
您需要将警报添加到ScheduledActionService以便向系统注册警报,以便它停止运行。 假设alarmTime是存储警报应该关闭的时间的变量,请执行以下操作: var alarm = new Microsoft.Phone.Scheduler.Alarm(System.Guid.NewGuid().ToString()) { Content = "Alarm Text", BeginTime = alarmT ...
-
不(抱歉) - 无法自定义内容(文本除外)或UI本身。 No (sorry) - there is no way to customize either the content (other than the text) or the UI itself.
-
您可以将该应用声明为位置跟踪应用。 在那种情况下,WP允许您的应用在后台运行。 但要小心这会耗尽电池。 http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj681691(v=vs.105).aspx http://msdn.microsoft.com/en-us/library/windowsphone/develop/ jj247548(v = vs.105)的.aspx 以下是最佳做法 但是,有可能每15分钟左右进行一次位置回调, ...
-
WP Silverlight 8.1应用程序 - 提醒触摸时不启动应用程序(WP Silverlight 8.1 App - Reminder not launching app when touched)[2022-12-15]
只是想说,对于发现自己在这个问题上挣扎的人,我 - 那种 - 解决了这个问题。 我联系了一位微软开发者传播者,他告诉我,这个功能确实从8.1 API中删除了。 他拒绝承认这只是一个错误,即使他同意“Uri”财产仍然存在的事实令人困惑。 我不确定是否相信他(我仍然认为这是一个错误),但至少我发现问题不在于我。 最后,唯一可行的解决方案是将整个项目转换回WP 8.0。 由于Visual Studio不允许通过简单编辑项目文件来执行此操作,因此我必须手动将所有文件复制到新项目中。 幸运的是,这样做没有重大问题。 ... -
Windows Phone点击警报或提醒启动应用程序(Windows Phone Tapping an alarm or Reminder launched Application)[2023-07-28]
当用户点击提醒时,它会在指定页面上导航。 这是提醒的默认操作。 您只需在添加之前在提醒对象中指定导航uri。 这是一个例子 Uri navigationUri = new Uri("/ShowDetails.xaml", UriKind.Relative); Reminder reminder = new Reminder(name); reminder.Title = titleTextBox.Text; ... -
直到今天,还没有用于以编程方式解除警报/提醒的API。 Until today there is no API for dismiss alarm/reminder programatically.
-
在App.Xaml.cs ,您可以订阅Obscured和Obscured事件。 RootFrame.Obscured += new EventHandler
(RootFrame_Obscured); RootFrame.Unobscured += new EventHandler(RootFrame_Unobscured); 弹出警报时,将触发RootFrame_Unobscured ; 解雇后, RootFrame_Obscured将被解雇。 Inside ...