Usecase : System makes outgoing call via twilio sstudo and gathet user response Steps:
Outgoing call via twilio sdk v2 API to twilio studio.
Twilio flow Trigger REST API is configured to receive as incoming call
Make out going call widget[name = "call_user_1"] makes outgoing call
Gather Input on call widget [name ="gather_input"] capture ressponse
If I debug below java code , I see : ExcecutionStep name = "incomingRequest" ,transitionedFrom="Trigger",transitionedTo="call_user_1
So the code exists and it does not even gathet input.
Please see attached twilio flow and code
import com.twilio.Twilio;
import com.twilio.base.ResourceSet;
import com.twilio.rest.studio.v2.flow.Execution;
import com.twilio.rest.studio.v2.flow.execution.ExecutionContext;
import com.twilio.rest.studio.v2.flow.execution.ExecutionStep;
public class Example {
public static final String ACCOUNT_SID = "<sid>";
public static final String AUTH_TOKEN = "<token>";
public static void main(String[] args) {
Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
String to = "<to>";
String from = "<from>";
String flowSid = "FW2c6c4c24e585c618803722e7ec6e10e5";
com.twilio.rest.lookups.v2.PhoneNumber targetLookupPhoneNumber = com.twilio.rest.lookups.v2.PhoneNumber.fetcher(to).fetch();
com.twilio.type.PhoneNumber toPhoneNumberTwilioType = targetLookupPhoneNumber.getPhoneNumber();
com.twilio.rest.lookups.v2.PhoneNumber fromLookupPhoneNumber = com.twilio.rest.lookups.v2.PhoneNumber.fetcher(from).fetch();
com.twilio.type.PhoneNumber fromPhoneNumberTwilioType = fromLookupPhoneNumber.getPhoneNumber();
Execution execution = Execution.creator(
flowSid,
toPhoneNumberTwilioType,
fromPhoneNumberTwilioType)
.create();
String executionSid = execution.getSid();
// Fetch the execution context for the latest execution
ExecutionContext executionContext = ExecutionContext.fetcher(flowSid, executionSid).fetch();
// Get the execution step for the "gather_input" widget
ExecutionStep executionStep = null;
ResourceSet<ExecutionStep> steps = ExecutionStep.reader(
flowSid,
executionSid)
.limit(20).read();
for (ExecutionStep step : steps) {
if (step.getTransitionedFrom().equals("call_user_1") && step.getName().equals("gather_input")) {
executionStep = step;
break;
}
}
System.out.println("executionStep=" + executionStep);
/* if (executionStep != null) {
// Get the user input for the "gather_input" widget
Map<String, Object> inputValues = executionStep.getInputValues();
String userInput = (String) inputValues.get("answers");
System.out.println("User input: " + userInput);
} else {
System.out.println("Could not find execution step for widget gather_input");
}*/
}
}