How To Use Chabot To Generate Documents and E-Sign

One of the key powers of Microsoft Power Virtual Agents is that it ties into the rest of Microsoft Power Platforms like Microsoft Power Automate so that you can connect to over 300+ connectors. Some of the key connectors for this are Adobe PDF Services and Adobe Sign.

If you haven’t used Adobe PDF Services in Microsoft Power Automate, check out this article that helps you learn how to get started.

To create a new flow related to this Virtual Agent, click on +, select call an action, and select Create a flow.

This will bring you to the Microsoft Power Automate authoring screen and will already have a trigger to get your inputs and final action to return a response to Power Virtual Agents.

Now for the rest of the logic. What we are creating here is a flow which:

Screenshot of the final result

Set The Inputs (Step 1)

First, you need to set your inputs. You can click on + Add an input and add an input for every one of your questions as input in Power Virtual Agents. This will allow us to pass this information to use in our flow.

For our return values, we are going to want to return a text output called SigningURL. This will be used to pass the signing URL from Adobe Sign back to the bot.

Your input and output should look something like this:

Setting Inputs

Conditional Inclusion of Products (Steps 2–6)

Depending on whether the customer elected to have Home Cleaning Services or Carpet Cleaning Services, we want those to be included as line items in our resulting document.

The first thing in this flow is that we create a variable called products. This is an array so that we can collect the different products we want to include.

Next, we only want certain products to be included if the customer elected them, so we add a condition that checks the input value cleaningServices if the customer selected it.

If true, we have an append to array variable action, which allows us to add JSON data to the array. If you remember from the sample data, a referencesOrder object has objects for each item to list. We have the variables fixed for this example, but you could look up this information from a database, CRM, etc. We will then repeat this action for the carpet cleaning services in Steps 5 and 6.

Initialize Variable for Document Data (Step 7)

You do not have to do it this way, but it helps debug the data in a variable before passing it to actions like Adobe PDF Services. That way, if there are issues with your data, you can see it clearly rather than waiting for the API to tell you why the data is wrong (which isn’t always reliable).

Here is where we have pasted the sample JSON code and placed in the values ​​for address, email, name, and the variable products we created earlier.

Generate Document From a Template (Steps 7–8)

Now that we have all of our information and data structure, we will send the data to Adobe PDF Services.

First, we need to get the Word template from SharePoint to use the Get file content action.

Second, we need to generate the document, which we can do using the Generate document from Word template action in Adobe PDF Services.

For your Template File Name, set it to the name of the file or whatever you want as long as the file extension is .docx.

For Merge Data, we want to pass the variable we created earlier. Unfortunately, Power Automate makes it a little tricky because it is an object variable, so we have to write an expression.

  1. Click in the Merge Data field.
  2. In the Dynamic content menu, click Expression and type in variables(‘documentData’) or whatever the name of your variable is.
  3. Click OK.

This will now place the variable out into that field.

Placing the variable out into that field

Send a Document for Signature with Adobe Sign (Steps 9–10)

Now that we have a document generated, we need to send it for signature using Adobe Sign. We first need to take the generated document and upload it to Adobe Sign for it to be referenced. We can do this using the Upload a document and get a document ID action.

You will then need to set the filename, which can be anything as long as it corresponds to the output format of the generated document step (.pdf or .docx).

For File content, you can use the Dynamic content menu to add the PDF file content variable.

Dynamic content menu to add the PDF file content variable

Once you have the file uploaded, you need to send the document for signature. You can do this by using the Create an agreement from an uploaded document and send for signature action and provide the following inputs:

Providing input

  • Agreement Name: The name of the agreement as it will show in Adobe Sign.
  • Document ID: The Document ID variable is output from Upload a document and gets a document ID.
  • Participant Email: Use the email variable from the input.

This will give a lot of information about the agreement, but the primary thing we are interested in is the Agreement ID variable.

Get Signing URL from Adobe Sign (Steps 12–16)

Now we are going to learn how to present the signing URL back in Power Virtual Agent. The action to get the signing URL from Adobe Sign isn’t available instantly after you send the agreement, so you have to poll it until it is ready. To get the signing URL, you have a few steps you need to do:

  • Create a variable to track the statusCode from the request
  • Create a loop with a 2-second delay, request the signing URL, and set the URL statusCode variable to the result from the request. If the statusCode is equal to 200, the loop can end. If not, then it continues to loop until it is ready.

DISCLAIMER: While you can functionally do this, there are some caveats. When dealing with legally compliant electronic signatures, you need to have a unique identifier for the signer. In this case, it is the email address. If we deliver the signing URL back in the chat without authenticating the user, this could question the electronic signature.

For this reason, we recommend that you only provide back the signing URL if you have a means of authenticating the user like a login prompt or using the Authentication method built into Power Virtual Agents.

Alternatively, Adobe Sign will email the email address specified with a link to view and sign. Alternatively, you can provide the option that the virtual agent asks the customer to check their email to view and sign.

Using signingUrlCode variable to track the statusCode

The signingUrlCode variable is used to track the statusCode of the action that gets the signing URL. We will use this to loop until we have a 200 statusCode.

creating a Do Until loop

We then create a Do Until loop, checking the signingUrlCode and seeing if it equals 200. If not, then it will keep repeating until it has one.

The Delay action is a 2-second delay. Typically, Adobe Sign takes about 3–5 seconds to return a signing URL, so a delay throttles the unnecessary API calls.

The Signing URL uses the Retrieve Signing URL action from Adobe Sign. Its only input is Agreement ID from the Create an agreement from an uploaded document and send for signature action.

As the last step, as part of the loop, you need to set the signingUrlCode variable to update it with the status code. It might not show up in your Dynamic content panel to set the value, so you can get it using expression. An example of that expression would be:


Return Signing URL

As a final action in our flow, we need to return the Signing URL to Power Virtual Agent. To do this, first, add to the Return value(s) to Power Virtual Agents step an output called signingURL.

As the value, we need to write an expression:


This expression basically means that it is getting the first signer’s esignUrl from the body of the Retrieve the Signing URL action.

Now you have finished your flow. Save it and go back to Power Virtual Agent.

Create a prompt for the customer in Power Virtual Agent.

Our next step is to create the action that triggers our flow, get the result, and prompt the customer. Click on + and select call an action, and select your flow listed.

Creating action to trigger our flow

Use the dropdown to select which variable in Power Virtual Agents you want to pass to which value in Power Automate.

Using the dropdown to select variable

After that, if successful, you should have the signingUrl variable you can now use. Next, click on + and select Show a message. Put in a message something like “Please sign the following document to complete your order” or something like that.

The signingUrl variable

Save your Virtual Agent.

Final Thoughts

Chatbots have become a really cool and natural way to make customer and employee interactions much simpler. With low-code solutions like Microsoft Power Virtual Agent, you don’t have to be a developer to create a useful chatbot that reduces people’s needs to jump on a phone. Integrating with Adobe PDF Services and Adobe Sign allows you to automate a lot of the paperwork that may be required as part of customer interaction and make it entirely digital.

Join the conversation in the Adobe forums if you have questions and need answers.


Leave a Comment