Sometimes it can be useful to quickly change the welcome message in a chatbot. For example, during a crisis or incident, the usual friendly greeting may not be appropriate, and you might want to provide messages related to the ongoing situation.
Introduction
It is easy enough to change the welcome message in an agent in Copilot Studio. It is located as a “send a message” node in the system topic “Conversation Start”
This is suitable for permanent changes to the welcome message but not ideal for quickly replacing it during a crisis, especially when you have Power Platform environments for DEV, TEST, and PROD..
Solution
To quickly change the welcome message for an agent in production, you can store the new message in a table in Dataverse. The agent can then check if it is in “crisis mode” and read the new message if necessary.
- Create a Table in Dataverse:
- Create a table called MyAgentSettings with two text columns: Setting and Value. Change the Maximum character count to 1000 characters for the Value column.
- You can also use this table for other settings for your agent if needed.
- Enter Values in the Table:
- Setting: Crisis Management
- Value: Yes
- Setting: CrisisManagementText
- Value: The message you want as your welcome message
We will use these values in Copilot Studio to check if the agent should switch the welcome message to the crisis message.
In the Copilot Studio agent, go to the Conversation Start topic, add a node between the trigger and the welcome message. Select “Add an Action” and select “New Power Automate flow”.
At the top left, rename your flow, for example, “Update welcome message”.
In Power Automate, we’re adding a “Dataverse List Rows” action, which should read our settings from the MyAgentSettings table
We filter on the “Settings” that start with “Crisis Management” as those are the only records we need at this time.
We then add a “Filter Array” action. Add the “body” value from the “List Rows” step and set the “Filter rows” as in the picture. Name the action “Filter array Crisis Management”. This gives us the “CrisisManagemet” setting.
After this, we add a “Compose” action where we enter the following expression:
first(body(‘Filter_array_CrisisManagement’))[‘bv_value’]
This gives us the value of the “Crisis Management” setting, in our case “Yes”
We use the “first” feature in expression to avoid Power Automate adding an “Apply to Each” loop.
Repeat the same with a “Filter Array” action and a “Compose” action to retrieve the “CrisisManagementText” setting.
The two actions look like this:
And the expression in “Compose” action then becomes:
first(body(‘Filter_array_CrisisManagementText’))[‘bv_value’]
Finally, we configure the “Respond to Copilot” action with the information we want to send back to our agent. In our case, it is “Yes” or “No” for whether the agent should be in crisis mode or not, and “CrisisManagementText” which is the welcome message we want to show when the agent is in crisis mode. We have this information in the two “Compose” actions we just created.
So then we create two text outputs, these we can call CrisisManagement and CrisisManagementText, these we will use when we are back in Copilot studio and our agent.
Save the Power Automate flow.
Back in Copilot Studio, you should now find a Power Automate flow called “Update welcome message”.
Add this between the trigger and the message node.
This will automatically create two variables that contain the values we sent back from Power Automate.
Add a “Condition” node and check the value of the variable “CrisisManagement”, check if it equals “No”, create a “Send message” node under this “Condition” and copy the regular welcome message from its “Message” node before you can delete it.
Under «All other conditions» add a new «Message» node, In this node we add the variable «CrisisManagementText». This is the welcome message that will be used in a crisis situation.
Finally, you can of course create a simple Power Apps on empty of Dataverse to have a user interface where it is easy to both turn crisis mode on/off and change the actual text of the associated welcome message.
Customize Copilot and Create Agents | Microsoft Copilot Studio