Lindsay T Shelton

From Concept to Chatbot: ServiceNow with Copilot Studio - Part 2

Posted on September 10, 2024  •  4 minutes  • 726 words
Table of contents

Head back to the intro post to get the use case and architecture of the Copilot Studio bots I’ll be describing in these blog posts, and head to part 1 to get a general overview of Copilot Studio, Topics, how I figured out troubleshooting the bot (the best you can at this point in Copilot Studio), and an overview of the Power Automate flows used in the initial POC I built.

Today’s post is about starting a conversation, aka the Conversation Start system topic. This is the first topic that the user will encounter when they start a conversation with the chatbot. It’s a good idea to have a greeting and a prompt for the user to start the conversation.

Note that this behavior you see when testing will not behave the same way if and when the bot is deployed to Teams (at least at the time this blog was published). The user can ask it whatever trigger phrases they want, but they won’t get the menu to pick from upon first interaction for whatever reason.

We start out in this topic by inserting a sneaky flow as the very second node of our Conversation Start Topic - “Run a flow from Copilot - Get sys_id”. This flow is a premium flow that calls the ServiceNow API to get the user’s sys_id based on their email address, System.User.Email, an automatically generated variable. This is important because we will use this sys_id in our HTTP calls to ServiceNow to identify the user instead of having them log into ServiceNow, as that experience is not the most user-friendly at this point. This way, they are silently logged in and we get the information we need from them without them having to do anything but open the bot in Teams or a canvas app.

This sys_id is an important global variable because we will use it in almost all of our future HTTP calls to ServiceNow to identify the user. As soon as we get the user’s sys_id, we ask them what they would like help with today. They can also achieve this experience by entering phrases, which we will get to later.

Placeholder

This is what it looks like to the end user:

Placeholder

If they ask a question, it prompts them to ask the question before redirecting them to the “Conversational boosting” topic, and storing that question in a global variable (Global.UserQuestion). For each other type, they are immediately redirected to the appropriate topic.

The Power Automate Flow - Get sys_id

We add one trigger text input - Email. When you go back to Copilot Studio and actually add in the flow, the value you will enter for this is System.User.Email. This is the email address of the user that is interacting with the bot. This is the only input we need for this flow.

This flow just has two actions in it after the trigger - a premium HTTP call and the “Return value to Power Virtual Agents/Respond to Copilot” action.

Placeholder

This is the entire flow! The hardest parts are getting the HTTP call right, getting your authorization working, and the formula to return just the sys_id, but I’ve got you covered for all three.

Go back to Copilot Studio and refresh the flow action. You should now see your input and your output as options. Set your sysid output as a Global variable that I called Global.userSysId. Now we can use it in all of our topics.

I’ll see you in part 3, where we get into the really cool stuff - conversational boosting!

Want to contact me about your own Copilot Studio ServiceNow bot? Do so below!

Follow me

Follow along for Power Platform, M365, and cat goodness