Power Virtual Agents helps us create intelligent conversational chatbots without any code implementation. With these bots, we can engage with customers and employees in multiple languages across websites, mobile apps, Facebook, Microsoft Teams, or any channel supported by the Azure Bot Framework
In this article, we will see how to create a basic Appointment Booking System using Power Virtual Agent, Power Automate, and SharePoint Lists
We have a requirement where we need to set up an automated appointment booking system that will let the users book a specific doctor of choice for consultation on a specific day and keep the appointment record in the hospital back end so that the hospital can pull daily appointments reports for operational activities.
To achieve this, we will create a SharePoint List in the back end to store the appointment details with the columns:
- Patient Name
- Appointment Date
- Doctor Name
Let’s create the bot by selecting the bot option from the top right corner and selecting “New bot”. It will open up the window where we can specify the bot’s name and language. Once the bot is provisioned, we can create a new topic and select the trigger phrases to define the words that will invoke the conversation with the bot
The trigger phrases will help in defining the words and phrases that will start the conversation with the bot. We have defined 7 such phrases and the more different and related words we add to it, the better the chances of bot understanding the trigger condition.
Let’s add a welcome message to the Authoring Canvas
To get the customer’s name, we will add the node – Ask a question to get the customer details. Followed by that, we will add another ask a question node to get the reason why the user has initiated the conversation by giving choice options :
- Book a Doctor Consultation
- Book a Health Check Up
Based on the customer response, which is stored in the variable CustomerResponse, conditional branches will be automatically created in the authoring canvas. For the Book a Doctor Consultation branch, we will add another question, to give the user the option to select the doctor, while for the Book a Health Check-up branch, we will give the user the option to type in the date and time for health check-up booking.
For each of the Doctor Selection, authoring canvas will again automatically create branches for each choice. For each branch, we will add the ask a question node to get the date and time of the preferred booking and upon input from the user, we will show a message that the booking with the mentioned doctor has been booked.
As the last step in this branch, we will add the call an action node and connect to the Power Automate which will save the details to the back end SharePoint list.
The Power Automate in the previous step is created by selecting the Call an action and clicking on Create a flow
This will open the Power Automate window where we will define the 3 input variables which contains the Patient Name,Doctor Name and Appointment Time.
We will then add the create item action to save the details to the SharePoint list which will act as the appointment records which the hospital can pull information daily. As we don’t have any specific data to be returned to the PVA, we will leave the return values empty. If we want to add additional appointment checking logic during item creation, we can return the success/failure message back to the PVA to make the system more robust.
Once the Flow is created, we can add the call an action node and select the recently created power automate flow and specify the required variables in the input section. We have done this for all the 5 branches that we saw in the above section.
In case of health check-up, we will follow a similar pattern, where we will add the message to the end-user that the booking is done and call the Power Automate and pass the required values which will be saved to the SharePoint list. Finally, we will end the conversation with a survey, if we intend to add more logic, we can extend the conversation with more question actions.
Now let’s test the bot with a trigger word – Book Appointment
Upon giving the inputs and selecting the doctor, we can specify the date and time. We can enter a specific date or even enter free text like Today which will be converted into an equivalent date and time.
The appointment record has been created in the back end as well:
Thus, we saw how we can use Power Virtual agents to create an automated doctor appointment booking system that invokes power automate to save the appointment records to the back-end SharePoint list. This can be expanded to implement enterprise-scale appointment bots and published to Public-Facing websites as well as other channels like Teams, Slack, Facebook, etc: