Function for adding buttons to an Avatar-based chatbot
Avatar is a Voximplant service that uses AI and NLP (natural language processing) for text and voice communication with customers.
In this example, you will create an avatar and train it to use buttons in customer conversations, for instance, when a one-word response is required: Yes/No, Transfer to agent/End conversation, etc. Next, you will create a function that adds reply buttons to a chat and passes the received responses to the avatar.
Contents
Connecting an integration
To start working with avatars, connect an integration to the service.
The integration can only be fully functional when the contact center is enabled. If the CC functionality is unavailable to you, contact your manager or Voximplant Kit support.
- Log in to your Voximplant Kit.
- Select Administration > Integrations > Marketplace.
- On the Voximplant Avatar tile, click Configure.

- In the Avatar account details group box, think up and enter the Username and Password of your Voximplant subuser. A subuser is a Voximplant platform control panel developer with limited permissions and access. Once you connect the integration, the system creates you a subuser with the credentials you specified. Your subuser has access to the Avatar section of the control panel, where you can build your avatars.

- Click Connect.
Creating and training your avatar
- In the Administration > Integrations > Marketplace section, click Open on the Voximplant Avatar tile. The system logs you in to the Voximplant platform control panel as your subuser.
- Click Create.

- Enter your avatar name, select the language it will use to chat with customers, define the timezone, and click Create again.

- Now add intents to your avatar and train it as needed in the Intents section. For details on how to create and train an avatar, go here.
- Go to the Dialog scenario section. Here you will find a standard dialog scenario with the avatar. You need to replace it with your own code (see below).
The dialog has several states: beginning of the conversation, order number verification, obtaining the customer's phone number, checking for bonuses, transferring the chat to an agent, and ending the dialog.
At the beginning of the dialog, the avatar greets the customer and receives a response. Depending on the customer's answer, the avatar can respond with pre-configured phrases, transfer the conversation to an agent, or offer response options in the form of buttons customData: 'needButton'
.
- Click Save.
- Go to the avatar list and copy the ID of the created bot.

Creating a function in Voximplant Kit
Now add the created avatar to a function. The function then displays buttons and passes customer responses to the avatar.
- Go back to your Voximplant Kit account and select Administration > Functions.
- In the Variables subsection, add the AVATAR_ID variable - the bot ID you copied earlier.

The system automatically captures your Voximplant account ID, subuser name, and password into the VOXIMPLANT_ACCOUNT_ID, VOXIMPLANT_AVATAR_LOGIN, and VOXIMPLANT_AVATAR_PASSWORD system variables (no need to enter them manually). These variables are the same for every avatar you create.
- Save your changes.
- Now go to the Management section and click New function.

- Add the required code depending on the channel you want to connect to your avatar and click Create.

CODE FOR A TELEGRAM CHANNEL
CODE FOR A WHATSAPP CHANNEL
CODE FOR A WEB CHAT CHANNEL
Connecting your function to a channel
- Go to Setup > Conversations > Channels.
- Select the channel in which you want to use your avatar.
- In the Redirect channel messages group box, click the Function radio button and select your avatar function from the drop-down list.

- Click Save changes.
Now your trained avatar is connected to the selected channel and is ready to process customer messages using buttons.