Skip to content

Instantly share code, notes, and snippets.

@geea-develop
Last active January 16, 2020 09:24
Show Gist options
  • Save geea-develop/3241cf72e9bafd162a5502387b61e423 to your computer and use it in GitHub Desktop.
Save geea-develop/3241cf72e9bafd162a5502387b61e423 to your computer and use it in GitHub Desktop.
CLAIMS 15.2
<dml>
<waterfall-dialog id='main'>
<step>
<!-- TODO: Provide as entry -->
<assign to='cars' value='[ { model: "Audi", plate: "EVR-7733" }, { model: "Mercedes", plate: "CAS-921" } ]' />
<assign to='drivers' value='[ { name: "Bill Gates", id: "422279296" }, { name: "Melinda Gates", id: "422279296" } ]' />
<assign to='profile' value='{ name: "Bill Gates", firstName: "Bill" }' />
<message>I’m Ava, your friendly auto insurance claims bot. I can help you file a claim, check claim status or contact your claim manager.</message>
<!-- <go to='get-profile' /> -->
</step>
<step memo='type'>
<!-- <if value='!profile'>
<go to='contact' break $code='profile' />
</if> -->
<go to='get-type' />
</step>
<step memo='details'>
<go to='get-details' />
</step>
<step memo='date'>
<go to='get-date' />
</step>
<step memo='car'>
<if value='!date'>
<go to='contact' break $code='date' />
</if>
<go to='get-car' $cars='@cars' />
</step>
<step memo='driver'>
<go to='get-driver' $profile='@profile' $drivers='@drivers' />
</step>
<step memo='injuries'>
<go to='get-injuries' />
</step>
<step memo='involved'>
<go to='get-involved' />
</step>
<step memo='recap'>
<go to='recap'
$profile='@profile'
$type='@type'
$date='@date'
$car='@car'
$driver='@driver'
$details='@details'
$injuries='@injuries'
$involved='@involved'
/>
</step>
<step>
<go to='send'
$profile='@profile'
$type='@type'
$date='@date'
$car='@car'
$driver='@driver'
$details='@details'
$injuries='@injuries'
$involved='@involved'
/>
</step>
</waterfall-dialog>
<step-dialog id='get-profile'>
<assign to='attempts' value='0' />
<waterfall-dialog return='profile'>
<step memo='profile'>
<if value='attempts == 2'>
<assign to='profile' value='null' />
<break />
</if>
<form-card message='Please fill-out your details' submit-text='Submit'>
<assign to='name'
$label='Name'
$val='@$data.name'
$pattern='^[\w ]{2,50}$'
$error='Given name is invalid'
/>
<assign to='id'
$label='ID'
$val='@$data.id'
$pattern='^\d{8,12}$'
$error='Given ID is invalid'
/>
</form-card>
</step>
<step>
<assign to='attempts' value='attempts + 1' />
<if value='$result.succeeded'>
<assign to='profile' value='$result.value' />
</if>
<else>
<message>{{$result.error.message}}.</message>
<assign to='name' value='$result.value.name' />
<assign to='id' value='$result.value.id' />
<go to='$self' break />
</else>
</step>
</waterfall-dialog>
</step-dialog>
<step-dialog id='get-type'>
<choices-card message='What would you like to do?'>
<assign to='file' $text='File a calim' />
<assign to='status' $text='Get claim status' />
<assign to='contact' $text='Contact my claim manager' />
</choices-card>
</step-dialog>
<step-dialog id='get-date'>
<assign to='attempts' value='0' />
<waterfall-dialog return='{ description: description, nlp: nlp }'>
<step memo='description'>
<if value='attempts == 2'>
<assign to='date' value='null' />
<break />
</if>
<text-prompt>Can you tell me when did it happen?</text-prompt>
</step>
<step memo='nlp'>
<next result='description | nlp | date' />
</step>
<step>
<assign to='attempts' value='attempts + 1' />
<if value='!nlp'>
<message>I didn't get that.</message>
<go to='$self' break />
</if>
</step>
</waterfall-dialog>
</step-dialog>
<waterfall-dialog id='get-car' return='{ model: model, plate: plate }'>
<step memo='which-car'>
<choices-prompt text='Which car was it?'>
<choice value='0'>{{cars[0].model}} ({{cars[0].plate}})</choice>
<choice value='1'>{{cars[1].model}} ({{cars[1].plate}})</choice>
</choices-prompt>
</step>
<step>
<assign to='model' value='cars[$result].model' />
<assign to='plate' value='cars[$result].plate' />
</step>
</waterfall-dialog>
<waterfall-dialog id='get-driver' return='{ name: name, id: id, be: be }'>
<step memo='which-driver'>
<choices-prompt text='Who was driving when the accident took place?'>
<choice value='0'>{{drivers[0].name}}</choice>
<choice value='1'>{{drivers[1].name}}</choice>
</choices-prompt>
</step>
<step>
<assign to='name' value='drivers[$result].name' />
<assign to='id' value='drivers[$result].id' />
</step>
</waterfall-dialog>
<waterfall-dialog id='get-details' return='{ nlp: nlp, description: description, attachments: attachments }'>
<step memo='description'>
<text-prompt>Okay, can you please tell me what happened?</text-prompt>
</step>
<step memo='nlp'>
<next result='description | nlp | details' />
</step>
<step>
<!-- ELINOR -->
<message>I'm sorry to hear that you were in an accident.</message>
<choices-prompt text='Please upload photos of the damage to your car. If you want to upload a photo just choose "upload".'>
<choice value='1'>Upload</choice>
<choice value='0'>don't have any</choice>
</choices-prompt>
</step>
<step memo='attachments'>
<assign to='attachments' value='[]' />
<if value='$result.value == "0"'>
<next result='[]' />
</if>
<waterfall-dialog return='attachments'>
<step>
<attachment-prompt>Waiting for photos...</attachment-prompt>
</step>
<step>
<assign to='attachments' value='attachments | concat($result)' />
<if value='$result.value == "1"'>
<go to='$self' />
</if>
</step>
</waterfall-dialog>
</step>
</waterfall-dialog>
<waterfall-dialog id='get-injuries' return='{ description: description, nlp: nlp }'>
<step memo='description'>
<text-prompt>Did anyone get hurt?</text-prompt>
</step>
<step memo='nlp'>
<assign to='nlp' value='description | nlp | injuries' />
<if value='!nlp'>
<!-- ELINOR -->
<message>Glad to hear that nobody was hurt. Your safety’s our top priority.</message>
</if>
<next result='nlp || "no one"' />
</step>
</waterfall-dialog>
<waterfall-dialog id='get-involved' return='{ description: description, nlp: nlp, attachments: attachments }'>
<step memo='description'>
<text-prompt>It sounds like another car was involved.
Please give any info that you have about the other drivers car, their brand, license plate number and etc.</text-prompt>
</step>
<step>
<assign to='nlp' value='description | nlp({ intent: "car" }) | involved' />
<message>Got it. It will help us file the claim more accurately.</message>
<if value='!nlp'>
<assign to='nlp' value='"seemingly no other vehicles"' />
<break />
</if>
<choices-prompt text='Now, you can upload photos of the damage, the other person’s insurance card, driver’s license, or a police report from the incident.'>
<choice value='1'>Upload</choice>
<choice value='0'>Continue</choice>
</choices-prompt>
</step>
<step memo='attachments'>
<assign to='attachments' value='[]' />
<if value='$result.value == "0"'>
<next result='[]' />
</if>
<waterfall-dialog return='attachments'>
<step>
<attachment-prompt>Waiting for photos...</attachment-prompt>
</step>
<step>
<choices-prompt text='Do you have more photos you would like to upload?'>
<choice value='1'>Upload</choice>
<choice value='0'>Continue</choice>
</choices-prompt>
</step>
<step>
<assign to='attachments' value='attachments | concat($result)' />
<if value='$result.value == "1"'>
<go to='$self' />
</if>
</step>
</waterfall-dialog>
</step>
</waterfall-dialog>
<step-dialog id='recap'>
<message>OK {{profile.firstName}}, here’s your claim summary: {{driver.name}} (ID {{driver.id}}) was driving on a {{car.model}} ({{car.plate}}) on {{date.nlp}}.
There were no injuries at the scene of the accident, and the incident involved {{involved.nlp}}.</message>
<waterfall-dialog>
<step>
<choices-prompt text='Would you like me to submit your claim ,or would you like to edit it?'>
<choice value='1'>Yes, submit claim</choice>
<choice value='0'>Edit claim</choice>
</choices-prompt>
</step>
<step>
<if value='$result.value == "0"'>
<!-- TODO: Implement -->
</if>
</step>
</waterfall-dialog>
</step-dialog>
<waterfall-dialog id='send'>
<step>
<call fn='send'
$profile='@profile'
$type='@type'
$date='@date'
$car='@car'
$driver='@driver'
$details='@details'
$injuries='@injuries'
$involved='@involved'
/>
</step>
<step>
<message>Your claim {{$result.value}} has been submitted! Additional details about your claim have been sent to your email.</message>
<text-prompt>We’ll be in touch if we need more info. If we have all the necessary details, we’ll have an update for you within 3 business days.
Can I help you with anything else today?</text-prompt>
</step>
<step>
<message>Ok, {{profile.firstName}}. We’ll have an update for you soon.</message>
<message>Psst, and don’t forget... you can check your claim status or contact your claim manager right here, anytime</message>
</step>
</waterfall-dialog>
<step-dialog id='contact'>
<message>An agent will contact you shortly.</message>
<event name='contact' $code='@code' />
</step-dialog>
</dml>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment