{ "description": "Appointment Reminder", "states": [ { "name": "Trigger", "type": "trigger", "transitions": [ { "next": "set_variables_firstName", "event": "incomingMessage" }, { "event": "incomingCall" }, { "event": "incomingRequest" } ], "properties": { "offset": { "x": 40, "y": -180 } } }, { "name": "send_survey", "type": "send-and-wait-for-reply", "transitions": [ { "next": "postMessageBody_webhook", "event": "incomingMessage" }, { "event": "timeout" }, { "event": "deliveryFailure" } ], "properties": { "offset": { "x": -80, "y": 270 }, "from": "{{flow.channel.address}}", "body": "Hola, {{flow.variables.firstName}}. En pocas palabras, cuéntanos si su pedido fue satisfactorio.", "timeout": "3600" } }, { "name": "split_confirmation", "type": "split-based-on", "transitions": [ { "next": "send_no_match", "event": "noMatch" }, { "next": "send_positive", "event": "match", "conditions": [ { "friendly_name": "Positive", "arguments": [ "{{flow.variables.sentiment}}" ], "type": "equal_to", "value": "joy" } ] }, { "next": "send_neagtive", "event": "match", "conditions": [ { "friendly_name": "Negative", "arguments": [ "{{flow.variables.sentiment}}" ], "type": "equal_to", "value": "sadness" } ] } ], "properties": { "input": "{{flow.variables.sentiment}}", "offset": { "x": -50, "y": 610 } } }, { "name": "send_no_match", "type": "send-message", "transitions": [ { "event": "sent" }, { "event": "failed" } ], "properties": { "offset": { "x": -470, "y": 860 }, "from": "{{flow.channel.address}}", "to": "{{contact.channel.address}}", "body": "Lo siento, yo no entendí su repuesta." } }, { "name": "postMessageBody_webhook", "type": "make-http-request", "transitions": [ { "next": "set_variables_IBMResponse", "event": "success" }, { "event": "failed" } ], "properties": { "offset": { "x": 270, "y": 270 }, "method": "GET", "parameters": [ { "value": "{{widgets.send_survey.inbound.Body}}", "key": "message" } ], "url": "https://suURLdengrok.ngrok.io/sentiment", "timeout": 3600 } }, { "name": "set_variables_firstName", "type": "set-variables", "transitions": [ { "next": "send_survey", "event": "next" } ], "properties": { "variables": [ { "value": "{{trigger.message.Body}}", "key": "firstName" } ], "offset": { "x": -40, "y": 30 } } }, { "name": "set_variables_IBMResponse", "type": "set-variables", "transitions": [ { "next": "split_confirmation", "event": "next" } ], "properties": { "variables": [ { "value": "{{widgets.postMessageBody_webhook.body}}", "key": "sentiment" } ], "offset": { "x": 610, "y": 270 } } }, { "name": "send_positive", "type": "send-message", "transitions": [ { "event": "sent" }, { "event": "failed" } ], "properties": { "offset": { "x": -90, "y": 860 }, "service": "{{trigger.message.InstanceSid}}", "channel": "{{trigger.message.ChannelSid}}", "from": "{{flow.channel.address}}", "to": "{{contact.channel.address}}", "body": "Muchas gracias por su respuesta. Nos alegra que tuvó un buen experiencia. Aquí es un cupón por un descuento de 10% para su póximo pedida: FRESH10" } }, { "name": "send_neagtive", "type": "send-message", "transitions": [ { "event": "sent" }, { "event": "failed" } ], "properties": { "offset": { "x": 290, "y": 860 }, "service": "{{trigger.message.InstanceSid}}", "channel": "{{trigger.message.ChannelSid}}", "from": "{{flow.channel.address}}", "to": "{{contact.channel.address}}", "body": "Lo siento mucho. Qué podemos hacer para mejorar su experiencia?" } } ], "initial_state": "Trigger", "flags": { "allow_concurrent_calls": true } }