Search code examples
botframework

How to add button for "Send Transcript" to Directline WebChat


I would like customers to be able to click a button to send themselves a transcript at any point in the conversation. This button should essentially send a message to the bot which would initiate an “email transcript" dialog to prompt for their email and send the transcript. I was able to add a button to the directline webchat client (in my title bar) but I can't figure out how to have it create an activity for the bot. I have a custom store that sends an "inactive" activity but I wasn't able to use this same method to make the button send an activity. Can this be achieved? Or is there another way for customers to get a copy of their transcript?

I have achieved the actual transcript retrieval and emailing in code, initiates by a LUIS intent, I just want to provide an intuitive "always there" option to do this.


Solution

  • The WebChat offers a simple sample that shows you how to send activities programmatically to the bot. In this sample they are creating a separate button with an Event Listener, which will sent your message as a message activity.

    If you would like to sent it as an event in the background, you could have a look at this sample, which you could combine with the event listener of the first example.

    Note: you need to use the JavaScript WebChat, it is not possible to add this functionality to the iFrame version of the Bot Service.