calling-prompt-templates-in-flows
Calling Prompt Templates Directly in Flows
What this skill is for
A prompt template (GenAiPromptTemplate) can be called directly from a Flow as a standard action — you do not need an Apex class that calls ConnectApi.EinsteinLLM.generateMessagesForPromptTemplate. The Flow action type is generatePromptResponse, it takes the template's declared inputs, and it returns the model's answer as a String named promptResponse.
This skill captures the exact, verified wiring (ground-truthed from a working Active RoutingFlow) plus the one place Apex is still genuinely useful: converting the template's text output into a Text collection so a flow can loop over it. Flow has no built-in "split string into collection" operation, so a ~15-line invocable fills that single gap.
Worked example ships in assets/
Real, deployed-and-Active files this skill was extracted from (copy and adapt them):
assets/example-routingflow-prompt-template-action.flow-meta.xml— the complete working RoutingFlow:Get_VoiceCall→generatePromptResponse(callsLead_to_Skill_Matching) →apextransformer → loop →routeWork. Every element referenced below is in this file verbatim.assets/PromptResponseToSkillIds.cls— the text→collection transformer invocable.assets/PromptResponseToSkillIdsTest.cls— its passing test (3 methods: happy path, stray-text tolerance, blank/null).