0

Below is configuration screenshot - enter image description here

enter image description here

public with sharing class ChatBotTime {

public class ChatBotTimeAndTempOutput {
    @InvocableVariable(required=true)
    public String city;
    @InvocableVariable(required=true)
    public Decimal temperature;
    @InvocableVariable(required=true)
    public String dateStamp;
}

public class ChatBotTimeAndTempInput {
    @InvocableVariable(required=true)
    public String city;
}

@InvocableMethod(label='Get System Time' description='Returns the current system time and temperature for the given cities')
public static List<ChatBotTimeAndTempOutput> getSystemTimeAndTemp(List<ChatBotTimeAndTempInput> inputs) {
    List<ChatBotTimeAndTempOutput> results = new List<ChatBotTimeAndTempOutput>();
    for(ChatBotTimeAndTempInput i:inputs){
        ChatBotTimeAndTempOutput item = new ChatBotTimeAndTempOutput();
        item.city = i.city;
        item.temperature = Math.floor(Math.random() * (1000 - 100) + 100) / 100;
        item.dateStamp = String.valueOf(dateTime.now());
        results.add(item);
    }
    return results;
}

}

Your Answer

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

Browse other questions tagged or ask your own question.