As a new learner I followed the Einstein Bot Cookbook guide on dynamic menus. The problem is that I struggle with using the value chosen by the user (which is stored in 'Appointments' object) for next apex action. I'm aware that there should be an @invocableVariable which allows object as an input but don't know how to write it.

the apex class for dynamic menu is

public with sharing class CookbookBot_GetOpenAppointments {

  @InvocableMethod(label='Get Open Appointments')
  public static List<List<Bot_Appointment__c>> getOpenAppointments(List<String> sEmails) {

    String sEmail = sEmails[0];

    List<Bot_Appointment__c> appointments = [SELECT Id, Name, JobType__c, 
                                                    AppointmentDate__c, AppointmentSlot__c 
                                             FROM Bot_Appointment__c 
                                             WHERE Contact__r.Email =:sEmail 
                                             AND Status__c IN ('New','Scheduled')];

    List<List<Bot_Appointment__c>> appointmentList = new List<List<Bot_Appointment__c>>();


    return appointmentList;

So I'd like to use an option chosen by the user and stored in 'Appointments' object to use in another apex class and let's say change the appointment status. I could I achieve this?

  • 1
    welcome to SFSE Piotr!. the class as coded won't compile as the method definition isn't right; use edit to fix. InvocableVariables are covered in the Apex Developer Guide
    – cropredy
    Jul 13, 2019 at 21:51
  • hi copredy, thanks for the worm welcome, I fixed the class - it returns several appointments nicely. Now in the bot editor I stored these appointments in 'openAppointments' object. The thing is that I can't figure out how to write next apex class for the apex call in the bot editor to use open appointment chosen by the chat user.
    – Piotr
    Jul 14, 2019 at 8:02

1 Answer 1


Ok, so the apex class given in The Einstein Bot Cookbook as an example doesn't fit a scenario when you need to reuse the option chosen by a chat user. We need to generate list of strings as an output not list of object. Then we can easily store the output from the dynamic menu as a Variable(text) and use it in next apex class.

  • Could you perhaps share your solution?
    – Minz
    Sep 17, 2020 at 15:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.