Reputation: 325
I have a Twilio phone number which I have connected to Dialogflow(ES) using the integration section of the latter. The connection with the agent is perfect except for one issue: there is no welcome message. I know that to trigger the welcome message I need to specify an event for it, however, I haven't been able to find in the Twilio documentation how to specify this event (without getting rid of the virtual agent integration and creating one of my own). And from the Dialogflow side, it doesn't seem to have a TWILIO_WELCOME
event, it does have welcome events for other integrations (facebook, for example).
Is this a limitation of the Twilio-Dialogfow integration or am I missing something? Is there a way to set up a welcome message, that comes from dialogflow, with this configuration?
Thanks in advance for any help.
Upvotes: 2
Views: 403
Reputation: 325
So it appears that there is no way, using the Dialogflow ES one-click integration with twilio, to make the Dialogflow Agent say a welcome message.
If you want your Dialogflow Agent to say the welcome message, you'll probably want to do away with the Twilio One-click integration and deal yourself with the bidirectional stream.
Twilio has a very helpful repository where they do exactly that.
dialogflow-utils.js is what you want to focus on.
And there you can see that when the detect stream is first created a "welcome" event is sent to Dialogflow, so that it responds with the Welcome Intent.
function createDetectStream(isFirst, sessionId, sessionPath, sessionClient) {
let queryInput = intentQueryAudioInput;
// Here we can see the welcome event
if (isFirst) {
queryInput = {
event: {
name: process.env.DIALOGFLOW_STARTING_EVENT_NAME,
languageCode: "en-US",
},
};
}
const initialStreamRequest = {
queryInput,
session: sessionPath,
queryParams: {
session: sessionClient.sessionPath(projectId, sessionId),
},
outputAudioConfig: {
audioEncoding: "OUTPUT_AUDIO_ENCODING_LINEAR_16",
},
};
const detectStream = sessionClient.streamingDetectIntent();
detectStream.write(initialStreamRequest);
return detectStream;
}
Last time I checked, that repository only worked for Dialogflow ES, but you can adapt the code so that it also works in Dialogflow CX.
Upvotes: 1
Reputation: 73029
Twilio developer evangelist here.
I don't know why a Twilio voice call doesn't have a welcome event. However, you can trigger a welcome message using TwiML before connecting to the VirtualAgent.
You can do this by adding a <Say>
element before connecting to the VirtualAgent. For example:
<Response>
<Say>Hello! You will be now be connected to a virtual agent.</Say>
<Connect action="https://myactionurl.com/virtualagent_ended">
<VirtualAgent connectorName="project" statusCallback="https://mycallbackurl.com"/>
</Connect>
</Response>
Upvotes: 0