score:4

Accepted answer

i'm assuming you are building on top of the minimizable web chat sample. instead of making a post request to direct line to send a message, i would recommend dispatching a sendmessage action from web chat's store. most of the logic is already there for you. you just need to import the sendaction method from web chat core and define a handlemenuitemclick function. take a look at the code snippets bellow.

minimizable web chat sample

...
// import `sendmessage` actiion from web chat core
import sendmessage from 'botframework-webchat-core/lib/actions/sendmessage';

...

export default class extends react.component {
  constructor(props) {
    super(props);
    ...
    // bind `handlemenuitemclick` to component
    this.handlemenuitemclick = this.handlemenuitemclick.bind(this);
    ...
  }

  // add `handlemenuitemclick` to component
  handlemenuitemclick({ target: { innertext }}) {
    const { store: { dispatch }} = this.state;
    dispatch(sendmessage(innertext));
  }

  render() {
    const { state: {
      minimized,
      newmessage,
      side,
      store,
      styleset,
      token
    } } = this;

    return (
      <div classname="minimizable-web-chat">
         ...
      </div>
  }
}

screen capture

enter image description here

hope this helps!


Related Query

More Query from same tag