Skip to main content

Notifications

Power Platform Community / Gallery / Copilot Cookbook / Past Due Account Management

Past Due Account Management

Mitanshu Profile Picture Posted by Mitanshu 1,574

In this sample, I will showcase how to create a custom AI prompt for managing past due accounts.

This custom copilot prompt will:

  • Recommend whether we need to send another reminder to follow-up on the past due payment or not
  • Generate Email subject and Email Body
  • As a responsible AI, explain the reason for its recommendation

Prompt Builder

1 - Create a new AI Builder Prompt and for this demo, we will name it as Past Due Account Management

2 - Create two new input variables under Prompt Settings, we will name it as InpAccount and InpCommunication. Note that there is no option to specify the data type of the variables and it is assumed to be string

3 - While within the Prompt Settings, chose output as JSON.

4 - You can update model to GPT 4.0 for this use case.

5 - Under the Prompt box, add the following text:

You are managing past due accounts. Analyse the JSON @{InpAccount} containing account information and JSON array @{InpCommunication} containing communication history to help in identifying whether reminder needs to be sent (true) or not (false). If a reminder needs to be sent then recommend when the next reminder should be sent and also provide a sample email subject and email body. Also add an explanation for why you have given recommendation for whether a reminder is needed or not and how you arrive at the next_reminder_date (if applicable). Provide your output as a JSON object for example {"status":"success", "explanation": "add information here", "reminder_needed":true, "next_reminder_date": "July 01, 2025", "email_subject: "Reminder: Payment Overdue", ""email_body": "Dear Gamma Corp, We hope this message finds you well. Our records indicate that your account is 45 days past due, with an outstanding balance of $5000. According to our payment terms (Net 30), this payment is significantly overdue. We kindly request that you settle this balance at your earliest convenience to avoid any potential late fees or disruptions to your service. If you have any questions or need assistance, please do not hesitate to contact us. Best regards, [Your Company Name]"}.

The two input JSON may contain a primary key and foreign key to establish relation between the two tables. The account information input may contain terms and conditions, so please use them in providing your output. In case the input is not sufficient or in the right format, then let the user know in the JSON object using the "success" item. Please add message variations in different email subjects and email body. In determining whether a reminder needs to be sent, take into consideration all factors such as how many days is the account late, what are payment terms and what was the last communication with the account.

Replace @{InpAccount} and @{InpCommunication} with your input parameter.

Screenshot 2024-07-07 at 10.57.27 am.png

6 - Enter sample data under both input parameters and then click on Test Prompt. You may want to try different variations to ensure the prompt is working as expected.

 

Power App

Note: See the screenshots in the Demo section for further context of this section.

1 - In a canvas Power App, create two collections - One for Accounts and One for Communication History. These could be your datasource tables, but for the purpose of this demo; we are using Collections.

2 - Add the Custom AI Prompt (Past Due Account Management) in the Data Source

3 - Create a button control which is enabled after an Account is selected. Under the OnSelect property, add the following code:

Set(predictResults,
'Past Due Account Management'.Predict(
 JSON(
 Filter(
 Accounts,
 AccountID = Gallery1.Selected.AccountID
 )
 ),
 JSON(
 Filter(
 Communications,
 AccountID = Gallery1.Selected.AccountID
 )
 )
)
)

4 - Add a label which will hold the explanation with the text property as:

Text(ParseJSON(predictResults.Text).explanation)

5 - Add a button that will take user to the Email screen. Update DisplayMode property of the button as:

If(
Boolean(ParseJSON(predictResults.Text).reminder_needed),
DisplayMode.Edit,
DisplayMode.Disabled
)

6 - Add an Email screen where information for the Email Body and the Email subject is populated as:

Body: Text(ParseJSON(predictResults.Text).email_body)
Subject: Text(ParseJSON(predictResults.Text).email_subject)

 

Demo

Account 1 - reminder needed:

Screenshot 2024-07-07 at 10.51.03 am.png

Screenshot 2024-07-07 at 10.51.31 am.png

Screenshot 2024-07-07 at 10.51.39 am.png

Account 2 - reminder NOT needed: (Email button disabled)

Screenshot 2024-07-07 at 10.51.53 am.png

Account 3 - reminder needed

 

Screenshot 2024-07-07 at 10.52.17 am.png

 

Account 4 - reminder NOT needed (Email button disabled)

Screenshot 2024-07-07 at 10.52.31 am.png

 

Disclaimer: This code sample is focused on AI custom prompt and is not suggesting best way for user workflow. You may want to change the App workflow as per business requirements and flexibility needed for the users.

Categories:

AI Builder Canvas Apps Copilot

Comments

*This post is locked for comments