The data resides in SharePoint List and must be fetched dynamically based on the user request and current status.
PowerApps does not provide QnA Maker connector.
QnA Maker is static pre-filled FAQ knowledge base. It cannot connect further with a database to get latest data.
Microsoft Bot framework can get integrated with PowerApps using Direct Line Channel. But it is a lengthy and complex procedure.
a. Prepare the back end Service — Write a custom service which can connect to SharePoint List database and fetch data for a specific user request. In my case, I wrote it in Python Flask using SharePlum Package. Here is a sample end-point –
GET /leaveapi/v1/balance?id=<user id stored in sharepoint>
b. Create a QnA Maker service and create a knowledge base as given below –
Do the same for all other end-points or queries user would make
c. Connect QnA Maker service with PowerApps using custom connector. Refer the article for details.
d. Create a Custom connector for Custom Python Flask Service. Refer the article to create a custom connector in PowerApps.
e. Design PowerApps Screen — Refer the article to create a chat screen in PowerApps —
f. Connect to LeaveQnA (My custom connector for QnA Maker) using the given formula –
The above code snippet connects to QnA Maker and get response mapped against the Knowledge Base (KB)
g. Set user ID using Office 365 connector and then connect to LeaveDataFetcher (my custom connector for Python Flask) to get response based on user ID –
The above code snippet gets user ID (email) and then calls LeaveDataService (Custom Python service) to get data against a user for his/her casual leave balance.
h. Based on the response, call the custom data connector as given below –
“GetCasualLeaveBalance” in __response_from_qna,
“Hello ! Your total causal leave balance is — “ & Char(13) & Char(13) & __casual_leaves_bal