Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
segment-sentiment-studio-flow.json
{
"description": "A New Flow",
"states": [
{
"name": "Trigger",
"type": "trigger",
"transitions": [
{
"event": "incomingMessage"
},
{
"next": "gather_reason_for_call",
"event": "incomingCall"
},
{
"event": "incomingRequest"
},
{
"event": "incomingParent"
}
],
"properties": {
"offset": {
"x": 0,
"y": 0
}
}
},
{
"name": "gather_reason_for_call",
"type": "gather-input-on-call",
"transitions": [
{
"event": "keypress"
},
{
"next": "function_analyze_sentiment",
"event": "speech"
},
{
"event": "timeout"
}
],
"properties": {
"speech_timeout": "auto",
"offset": {
"x": 120,
"y": 240
},
"loop": 1,
"finish_on_key": "#",
"say": "Hi thank you for calling the Owl hotline. In a few short sentences, can you tell us how we can help you?",
"language": "default",
"stop_gather": true,
"gather_language": "en",
"profanity_filter": "true",
"timeout": 5
}
},
{
"name": "function_analyze_sentiment",
"type": "run-function",
"transitions": [
{
"next": "http_post_segment_source",
"event": "success"
},
{
"event": "fail"
}
],
"properties": {
"service_sid": "ZS83ab4617620de54fc97d855fd5bc2a28",
"environment_sid": "ZE6a3e51be61c3a020ddb85d75da7d3965",
"offset": {
"x": 200,
"y": 510
},
"function_sid": "ZH99f22846b01e2e6328fe0b0558c0fb66",
"parameters": [
{
"value": "{{widgets.gather_reason_for_call.SpeechResult}}",
"key": "speech_result"
}
],
"url": "https://sentiment-analzyer-5463.twil.io/get_user_sentiment"
}
},
{
"name": "say_play_2",
"type": "say-play",
"transitions": [
{
"event": "audioComplete"
}
],
"properties": {
"offset": {
"x": 200,
"y": 1020
},
"loop": 1,
"say": "Thank you for sharing, we will give you a call back as soon as an agent is available."
}
},
{
"name": "http_post_segment_source",
"type": "make-http-request",
"transitions": [
{
"next": "say_play_2",
"event": "success"
},
{
"event": "failed"
}
],
"properties": {
"offset": {
"x": 160,
"y": 750
},
"method": "POST",
"content_type": "application/json;charset=utf-8",
"body": "{\n\"event_name\": \"Contacted support line\",\n\"phoneNumber\": \"{{trigger.call.From}}\", \n\"userid\": \" {{trigger.call.CallSid}} \",\n\"sentiment\": \"{{widgets.function_analyze_sentiment.body}} \"\n}",
"url": ""
}
}
],
"initial_state": "Trigger",
"flags": {
"allow_concurrent_calls": true
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment