Reputation: 69
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>
)
}
}
Upvotes: 1
Views: 588
Reputation: 13918
I am not expert in React, but I found that in React, we only can update the input value via its state. And via source code, it seems that there is an entrance function called onChangeText()
.
So, please try following code snippet to update the input value:
componentDidMount(){
console.log(this.chat);
this.chat.shellRef.props.onChangeText('testMsg');
}
Upvotes: 1