Function for adding buttons to a web chat
In this example, you will create a function that adds buttons to a web chat and route channel messages to this function.
The maximum number of buttons in a web chat is 13. Text is required for each button and must not be greater than 40 characters.
- Create a web chat channel as shown here.
- Go to Administration > Functions > Management.
- Click New function.
![New function New function](/docs/kit-md-ad-generator/en/assets/images/setup-conversations-channels-webchat-function.png)
In this example, you add the following buttons:
What day is it today? - returns the current date
Agent needed - places the message in a queue
End the conversation - ends the conversation
- Copy the following code and paste it into the function.
- Click Create.
![Add function Add function](/docs/kit-md-ad-generator/en/assets/images/setup-conversations-channels-webchat-buttonfunction.png)
- Go to Setup > Conversations > Channels and select the web chat channel you created.
- Select Functions in the Redirect channel messages field.
- From the drop-down list, select the function you added earlier.
![Redirect chat messages to the function Redirect chat messages to the function](/docs/kit-md-ad-generator/en/assets/images/setup-conversations-channels-webchat-yourfunction.png)
- Click Save changes.
The three buttons will now display in response to a customer. If a customer selects the What day is it today? button - they will receive a response with the current date; if a customer clicks the Agent needed button - the bot will inform them that the chat will be transferred to an agent; if a customer selects End the conversation - the chat closes.
![Buttons Buttons](/docs/kit-md-ad-generator/en/assets/images/setup-conversations-channels-webchatbuttons.png)
The button options offered to the customer or the selected option then display in the History > Messaging history and Reporting > Live monitoring > Conversations sections.