Use Case - Creating and Opening a Salesforce Task as Agent Accepts a Call

Create a task item in Salesforce when a call comes in, create a new account for the contact if it doesn't exist yet, and open the task/new account page for the agent for note taking.

➕ This use case is an extension to Use Case - Creating a callback task for missed calls in Salesforce. When a call comes in, we want to achieve the following results:

  • Create a Task Item in Salesforce immediately. When the agent takes the call, we open the URL to the task via a conversation context so that the agent can take notes.
  • If we can't find the contact in Salesforce, then we want to create a new account. When the agent takes the call, we open the URL to the New Account Page via a conversation context so that the agent can create it.
  • If we find the contact but no account in Salesforce, then we want to create a new account. When the agent takes the call, we open the URL to the New Account Page via a conversation context so that the agent can create it.
  • If there is a problem creating the task, we don't want to confuse the agent and open a fallback URL instead.

Show a preview of the flow...

 
 

PRECONDITIONS

At this point we assume you have a Salesforce account with admin privileges.

To connect to Power Automate to your Salesforce instance, perform the steps below.

  1. Log into your Power Automate account. Within the main menu, go to Data > Connections. Click "New Connection" and select "Salesforce "
  2. When adding the connector, note that this requires a Premium Power Automate account. 💡 Cost of this connector is outside of Luware product scope.
  3. Select your URI, and the API Version and create the connection

☝ We highly recommend testing in a "Sandbox" or creating a new account in Salesforce to test the connection. You can delete the account permanently after testing your solution.

 

Show Icon Legend

💡 = A hint to signal learnings, improvements or useful information in context. 🔍 = Info points out essential notes or related page in context.
☝ = Notifies you about fallacies and tricky parts that help avoid problems. 🤔 = Asks and answers common questions and troubleshooting points.
❌ = Warns you of actions with irreversible / data-destructive consequence. ✅ = Intructs you to perform a certain (prerequired) action to complete a related step.
 
 

How-To Steps

Prepare Data in Nimbus

✅ In Nimbus, we need to create the conversation context and the parameters for the URLs to show.

  1. Create the parameter, go to Configuration > Parameters > "Create New"
  2. Create the conversation context: Go to Configuration > Conversation Context → "Create New".
  3. Assign a name and add the newly created parameter as the value:
  4. Assign the conversation context to your service: Go to the service settings and add a the conversation context from the previous step.
    💡 Please note, that Nimbus only opens the first URL in that list.
    💡 An active conversation contexts opens always, whether the URL is invalid or empty. There is no URL validation in Nimbus.

Create the flow - Add the trigger

  1. Start a new "Automated Cloud Flow" with the Nimbus "GetOnNewTasks" Trigger.
  2. Add four "Initialize Variable" elements to the flow and add the following data: 
Element to (re)name
Name
Type
Value
ContactId ContactId String empty
AccountId AccountId String empty
Initialize Fallback URL FallbackNewAccountURL String https://<your Salesforce instance>/r/Account/new
Initialize Main URL  SalesforceURL String https://<your Salesforce instance>

Find contacts

✅ Next is the Salesforce contact retrieval.

  1. Add a "Get records" element to the flow.
  2. Rename it to "Get records Contacts" and set the following filters:
    • Salesforce Object Type Contacts
    • Filter query (MobilePhone eq 'triggerOutputs()?['body/microsoftCallerId']') or (Phone eq 'triggerOutputs()?['body/microsoftCallerId']')
    • Top Count 0

First Condition Block 

  1. Now add a Condition element to the flow and check the results of the last step as follows:
    • expression=length(outputs('Get_records_Contacts')?['body/value'])
    • is greater than
    • 0

First Condition Block - Continue the "If no" branch

  1. Add a Nimbus UpdateTask element to the "IF no" branch of the condition.
  2. Set the values as follows:
    • RequestId = triggerOutputs()?['body/requestId']
    • CustomContextParameter.Name = SalesforceURL
    • CustomContextParameter.Value= variables('FallbackNewAccountURL')


💡 The flow ends here and the conversation context in Nimbus will point to the "Create New Account" Page in Salesforce.

First Condition Block - Continue the "If True" branch

Overview of the branch

 
 
  1. Add a Compose element to the flow and rename it to "Contact". We want to store the results of the Get Records Contact element into it. As this returns a collection and we filtered to only have one item, we take the first item.
    Inputs = outputs('Get_records_Contacts')?['body/value'][0]
  2. Then add two "Set Variable" elements to the flow:
    • The first one will hold the ContactId which is now stored in the Contact data element.
      • Name ContactId
      • Value outputs('Contact')?['Id']
    • Set the second one to:
      • Name AccountId
      • Value outputs('Contact')?['AccountId']
  3. Now add a "Condition" element to the flow:
    • expression=empty(variables('AccountId'))
    • is equal to
    • false

Second Condition Block - Continue the "If no" branch

✅ Repeat the same steps as in chapter IfNoCondition above.

Second Condition Block - Continue the "If True" branch

Overview

 

 
 

If we found an AccountId we want to get the records from Salesforce.

Add a "Get records" element to the flow.

Rename it to "Get records Accounts" and filter it as follows:

  •  Salesforce Object Type = Accounts
  • Filter Query = (Id eq 'variables('AccountId')')
  • Top Count = 1

Now add a third "Condition" element to the flow. Here we want to check if we got results.

Rename it to "Check if Account found" and check the following:

  • expression=length(outputs('Get_records_Accounts')?['body/value'])
  • is greater than
  • 0

Third Condition Block - Continue the "If no" branch

✅ Repeat the same steps as in chapter IfNoCondition above.

Third Condition Block - Continue the "If True" branch

✅ If we found an Account in Salesforce, we want to create a task on it.

Overview

 
 
  1. Add a "Compose" element to the flow and save the account data in it as follows:
  2. Inputs = outputs('Get_records_Accounts')?['body/value'][0]
  3. Add a "Create record" element to the flow and do the following:
    • NameId variables('ContactId')
    • Subject Received Nimbus call over Service triggerOutputs()?['body/teamName'] on formatDateTime(triggerOutputs()?['body/created'],' hh:mm tt')
    • Status Not Started
    • Call type = Inbound
    • Task Subtype = Call
  4. Add a "Set variable" element to the flow as follows:
    • Name SalesforceURL
    • Value concat('<your Salesforce URL>/r/Task/', outputs('Create_record')?['body/Id'] ,'/view')
  5. Click on the "..." > Configure run after > Create Record Succeeded set to “is successful”

    💡 We only want to point to the Task if Create record was successful:

Final UpdateTask

  1. Add the Nimbus UpdateTask element to the flow's "success" If-true branch and update the data with the compose elements:
  2. Map the elements as follows:
    • Customer.FirstName = outputs('Contact')?['FirstName']
    • Customer.LastName outputs('Contact')?['LastName'] 
    • Customer.DisplayName = outputs('Contact')?['Name']
    • Customer.Company outputs('Account')?['Name'] 
    • Customer.Department = outputs('Account')?['Department']
    • Customer.StreetAdress = outputs('Account')?['BillingStreet']}
    • Customer.PostCode = outputs('Account')?['BillingPostalCode']
    • Customer.City = outputs('Account')?['BillingCity']
    • Customer.BillingState = outputs('Account')?['BillingState']
    • Customer.Country outputs('Account')?['BillingCountry']
  3. Set the custom fields to:
    • Customer.CustomFields name = SFTaskID, value = outputs('Create_record')?['body/Id']
    • Customer.CustomFields name = SFAccountId, value = variables('AccountId')
    • Customer.CustomFields name = SFContactId, value = variables('ContactId')
    • Customer.CustomFields name = SalesforceURL, value = variables(' SalesforceURL')

Table of Contents