-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
VoiceXmlDocumentAdapter usage #15
Comments
A package com.nuecho.rivr.cookbook.dialogue;
import org.w3c.dom.*;
import com.nuecho.rivr.core.channel.*;
import com.nuecho.rivr.core.dialogue.*;
import com.nuecho.rivr.voicexml.dialogue.*;
import com.nuecho.rivr.voicexml.rendering.voicexml.*;
import com.nuecho.rivr.voicexml.turn.*;
import com.nuecho.rivr.voicexml.turn.first.*;
import com.nuecho.rivr.voicexml.turn.last.*;
import com.nuecho.rivr.voicexml.turn.output.*;
import com.nuecho.rivr.voicexml.turn.output.audio.*;
public class Dialogue implements VoiceXmlDialogue {
@Override
public VoiceXmlLastTurn run(VoiceXmlFirstTurn firstTurn, VoiceXmlDialogueContext context) throws Timeout,
InterruptedException {
Message message = OutputTurns.message("message")
.addAudioItem(new SpeechSynthesis("Some message here..."))
.build();
VoiceXmlDocumentAdapter voiceXmlDocumentAdapter = new VoiceXmlDocumentAdapter() {
@Override
public void adaptVoiceXmlDocument(Document document) throws VoiceXmlDocumentRenderingException {
Comment commentNode = document.createComment("This is a custom comment at the end of the VoiceXML document!");
document.getDocumentElement().appendChild(commentNode);
}
};
message.addAdapter(voiceXmlDocumentAdapter);
DialogueUtils.doTurn(message, context);
return new Exit("exit");
}
} This will generate the following: <?xml version="1.0" encoding="UTF-8"?><vxml application="/rivr-test/dialogue/root/b7058749-27af-464f-9f2c-b0913c9a24ae" version="2.1" xmlns="http://www.w3.org/2001/vxml">
<script>application.rivr.localErrorHandling = false; application.rivr.inputTurn = {};</script>
<form id="form">
<block>
<prompt>Some message here...</prompt>
<goto next="#submitForm"/>
</block>
</form>
<catch>
<if cond="_event.substring(0, 5) == "error"">
<if cond="application.rivr.localErrorHandling">
<goto next="#fatalErrorForm"/>
<else/>
<script>application.rivr.localErrorHandling=true</script>
</if>
</if>
<script>application.rivr.addEventResult(_event, _message)</script>
<goto next="#submitForm"/>
</catch>
<form id="fatalErrorForm">
<block>
<exit/>
</block>
</form>
<form id="submitForm">
<block>
<var expr="application.rivr.toJson(application.rivr.inputTurn)" name="inputTurn"/>
<if cond="application.rivr.hasRecording(application.rivr.inputTurn)">
<var expr="application.rivr.inputTurn.recordingMetaData.data" name="recording"/>
<assign expr="undefined" name="application.rivr.inputTurn.recordingMetaData.data"/>
<submit enctype="multipart/form-data" method="post" namelist="inputTurn recording" next="/rivr-test/dialogue/b7058749-27af-464f-9f2c-b0913c9a24ae/0/message"/>
<else/>
<submit method="post" namelist="inputTurn" next="/rivr-test/dialogue/b7058749-27af-464f-9f2c-b0913c9a24ae/0/message"/>
</if>
</block>
</form>
<!--This is a custom comment at the end of the VoiceXML document!-->
</vxml> |
In what way we can use VoiceXmlDocumentAdapter and documentTurn, Is there any sample code ?
The text was updated successfully, but these errors were encountered: