Pages

1/29/2022

Easy way to make chat bot on Business Central with Power Virtual Agent

I will show how to fast and easy create chat bot on Business Central. 

For this solution we need : 
  • Power Virtual Agents - (https://powervirtualagents.microsoft.com/en-us/ there is free subscription for 60 day, Later it cost from 450$ till 1000$) 
So when you have subscription  then you need to create chat bot:

Let's name it "BC Virtual Consultant
":

When we created chatbot we can manage topic on what chatbot will give answers.
Let's create topic on "Sales document":


Create answer's.  Click on "Go to authoring canvas"
There you can create your answers

When our chat bot topics already created then we can publish chat bot. 
Go to the publish area.



Click on Publish button

Then click on "Go to Channel" and select "Custom website"

Copy html code snippet. We will need it later.

Now we can go to create Busness Cenrall extension for that chat bot.

Create new page in BC extension project:

page 50001 "Chat Bot Card"
{
    PageType = Card;
    ApplicationArea = All;
    UsageCategory = Administration;

    layout
    {
        area(Content)
        {
            usercontrol(ControlName; "Microsoft.Dynamics.Nav.Client.WebPageViewer")
            {

                ApplicationArea = All;
                trigger ControlAddInReady(callbackUrl: Text)
                begin
                    CurrPage.ControlName.SetContent('<!DOCTYPE html><html><body>
<iframe src=" Copy your own link"
frameborder="0" style="width: 100%; height: 100%;"></iframe>
</body></html>');
                end;

                trigger Callback(data: Text)
                begin
                    CurrPage.Close();
                end;

            }
        }
    }

}



Run project and let's try our chat bot :)

We get answer on topic