Contact Us

September 30, 2024

May 13, 2026 2:22 pm

Implementing a survey after an Agentforce Service attendance

Share with

Understanding the Challenge

When using Agentforce Service with a Marketing Cloud campaign, it can be difficult to determine when to send a survey to the customer. The agent may not know when the conversation is complete, and there may not be a clear trigger to send the survey.

Technical Background

Agentforce Service uses a combination of APIs and webhooks to interact with the customer and the agent. However, there is no built-in trigger to send a survey after the session ends. To overcome this, we can use a custom API to trigger the survey.

Solution Overview

To implement a survey after an Agentforce Service attendance, we need to create a custom API that listens for the session end event and triggers the survey. We can use Apex to create the custom API and integrate it with the Agentforce Service.

SurveyTrigger.cls

public class SurveyTrigger {
    public static void triggerSurvey(String sessionId) {
        // Get the session details
        AgentforceServiceSession session = [SELECT Id, Status FROM AgentforceServiceSession WHERE Id = :sessionId];
        
        // Check if the session is complete
        if (session.Status == 'Completed') {
            // Trigger the survey
            Survey survey = new Survey();
            survey.SessionId = sessionId;
            insert survey;
        }
    }
}

The root cause of this issue is the lack of a built-in trigger to send a survey after the Agentforce Service session ends. This requires a custom solution to listen for the session end event and trigger the survey.

Implementation Steps

To implement this solution, follow these steps:

Checklist

  • Create a custom API using Apex to listen for the session end event
  • Integrate the custom API with the Agentforce Service
  • Configure the survey to be triggered after the session ends
  • Test the solution to ensure it works as expected
  • Deploy the solution to production
  • Monitor the solution for any issues or errors

Frequently Asked Questions

What is the best way to trigger the survey?

The best way to trigger the survey is to use a custom API that listens for the session end event.

Can I use a built-in trigger to send the survey?

No, there is no built-in trigger to send a survey after the Agentforce Service session ends. A custom solution is required.

How do I integrate the custom API with the Agentforce Service?

You can integrate the custom API with the Agentforce Service using Apex and the Agentforce Service APIs.

What are the benefits of using a custom API to trigger the survey?

The benefits of using a custom API to trigger the survey include increased flexibility and control over the survey trigger, as well as the ability to customize the survey trigger to meet specific business requirements.

Genetrix Technology · Salesforce Marketing Cloud Partner

Need help shipping this in production?

Genetrix builds and untangles Salesforce Marketing Cloud and Agentforce setups for teams that want it done right the first time. If anything in this post sounds familiar, talk to us before it ships.

Get in Touch with Genetrix →

Blogs for the

Business-Savvy!​

Let’s Connect

A 30 min no cost strategy session
with cloud support expert

Let’s Connect

A 30 min no cost strategy session
with cloud support expert