I have a scenario where I want my help and the main menu button is always present which comes with a welcome message and even if I am in between some other activity within the bot I can come and click on that button any time in the bot. Please suggest anyway how to achieve this scenario. This means they should always be present there.
-
I am hoping you are planning to use the restart button in your webchat app? – Rajeesh Menoth Feb 07 '22 at 05:20
-
Yes @RajeeshMenoth you can say like that. But the idea is more like my main menu and help button is coming from the welcome message but as soon as the other activity starts they went way up so is there any way my main menu and help will always be there whatever activity going behind doesn't affect it. or any other way you can suggest it. Thanks – Bipin Bhandari Feb 07 '22 at 12:19
-
If you are using webchat then in the hamburger menu you can maintain the main menu and the help button, if the user wants to click then they can click on the hamburger menu to choose the right button actions. – Rajeesh Menoth Feb 07 '22 at 13:21
-
@RajeeshMenoth is quite new to this can you share some code snippets on how to achieve this. Thanks in advance – Bipin Bhandari Feb 07 '22 at 13:49
-
@RajeeshMenoth Can you pls suggest something on this https://stackoverflow.com/questions/70982589/buttons-is-not-working-properly-bot-framework-when-text-is-long – Bipin Bhandari Feb 08 '22 at 06:32
-
Look at this webchat menu design https://user-images.githubusercontent.com/3864971/82658397-8b7aa000-9c44-11ea-8749-fe29feaa9796.png – Rajeesh Menoth Feb 08 '22 at 07:54
-
@RajeeshMenoth that I have checked it before but how do I indicate that from these welcome buttons this should be a hamburger menu. – Bipin Bhandari Feb 08 '22 at 11:45
-
@RajeeshMenoth my layout is like this any https://paste.pics/FXHKE – Bipin Bhandari Feb 08 '22 at 12:01
-
As per the screenshot that main menu you need to remove from the adaptive card and placed the left side of the chat panel using normal html/css code. once you clicked on any button or type any content in the chat panel the main menu options are still present in the chat panel left side section as per the reference link i have given in the above comment. The hamburger menu is enough no need to write "Main menu" text on the left side. – Rajeesh Menoth Feb 08 '22 at 12:58
1 Answers
If you look over the 04.api/d.post-activity-event sample, it shows you how you can add a button to a hosted page that interacts with the embedded Web Chat client (i.e. the bot).
How you decide to design the button has no bearing on the functionality you attach to it. So, whether it is a plain button or a hamburger menu, when the button is clicked, using the design demonstrated in the sample, the result will be the same.
This sample uses the React flavor of the Web Chat component and shows the React method for implementing this. This is not a React project, so don't let that stop you.
However, if you don't want to use React methods, you can achieve the same by use of an event listener.
First, get the button element. Then attach an event listener that responds to a 'click'. Make sure the event listener is placed in your page where Web Chat's store
object is accessible.
Here is an example implementing the store. However, all you will need is what is shown below in the code.
At this point, assuming everything is aligned correctly, when the button is clicked a message will be sent via Web Chat to the bot. If you want to explore other Web Chat actions, you can find a list of them here. The samples provided in the Web Chat repo demonstrate how many of the actions can be implemented, if you are unsure.
const store = window.WebChat.createStore( {}, ( { dispatch } ) => next => action => {
next( action );
} );
[...]
const button = document.getElementById('sendMsgBtn');
button.addEventListener('click', (e) -> {
e.preventDefault();
store.dispatch({
type: 'WEB_CHAT/SEND_MESSAGE',
payload: {
text: 'I pressed a button!'
}
});
});
On the off-chance you are wanting the button to live within the Web Chat transcript window, you can do so following the steps listed in this SO post. Again, for clarity, where the button lives and what it looks like doesn't matter. The functionality will be the same.
Hope of help!

- 6,078
- 2
- 16
- 35