Mashy Teaches WebApp/Website Development with BANanoVuetifyAD3 - The New Series

Mashiane

Expert
Licensed User
26. A demo of how a simple chat bot is created.

We have added the bot on pgIndex using the VBeautifulChat.

Step 1 - mounting content on the Chat

B4X:
Sub loadusers
    'clear participants
    VBeautifulChat1.ClearParticipants
    'add a support chat
    VBeautifulChat1.AddBot("Support", "./assets/bvad31.png")
    'add a bot menu
    VBeautifulChat1.AddBotMenu("1", _
    Array("Hi there, this is the BVAD3 ChatBox", "Please enter your choice below for us to begin."), _
    Array("Form", "Grid", "MQTT", "Other Databases", "All above.", "Menu"))
'show the menu
    VBeautifulChat1.BotShowMenu("1")
 End Sub

Step 2: When a user enters a choice, trap it and process accordingly.

B4X:
Private Sub VBeautifulChat1_Sent (msg As Map)
    'get the entered text
    Dim cm As ChatMessage = VBeautifulChat1.ToChatMessage(msg)
    Select Case cm.text
    Case "1"
        VBeautifulChat1.BotRespond("With forms, the best approach is to use the V-Form and V-Field components.")
    Case "2"
        VBeautifulChat1.BotRespond("A grid can have any number of rows. A row can have a number of columns, and the size of the columns should be equal to 12.")
    Case "3"
        VBeautifulChat1.BotRespond("MQTT is not yet implemented in BVAD3, we will inform you once its done.")
    Case "4"
        VBeautifulChat1.BotRespond("BVAD3 currently works with IndexedDB, MySQL, MSSQL, Firebase FireStore, SQLite and PouchDB, which DB Backend are you interested in?")
    Case "5"
        VBeautifulChat1.BotRespond("Enter the number corresponding to your area of interest.")
    Case "6"
        VBeautifulChat1.BotShowMenu("1")
    Case Else
        VBeautifulChat1.BotRespond("Please enter a number between 1 and 6!")
        Return                            
    End Select
End Sub

 
Top