Jump to content

Need to extend a JSON callflow


Recommended Posts

Hi!

We have this script which is run when a customer dials a Spree code to configure a wakeup call:

<?php
//$From = $_GET['From'];
header('content-type:application/json');
?>
{
    "module":"play",
    "data":{
        "id": "/56d9ba1fb0250f40eda173e93a0cba0d/47080efccc7f31b828ddf75dd94d1d7f"
    },
    "children": {
        "_": {
            "module": "collect_dtmf",
            "data": {
                "max_digits": 5,
                "collection_name": "custom_name"
            },
            "children": {
                "_": {
                    "module": "pivot",
                    "data": {
                        "voice_url": "http://pivot.server.com/pivot/{ACCOUNT}/setWakeup.php"
                    },
                    "children": {}
                }
            }
        }
    }
}

Step 1: The person dials the *xx code.

Step 2: A message is played via TTS, using the "play" module. This message asks them to input the wakeup time in 24-hr format, followed by a "0" for a wakeup today or a "1" for a wakeup tomorrow.

Step 3: The customer enters the numbers

Step 4: The pivot script is called. The phone number, wakeup time, today/tomorrow info is saved in the database.

Step5: Kazoo hangs up the call by making "children":{} the last child of the callflow.

 

Now this is good and it works fine. But - we'd like to insert another action to play a message letting the customer know that their wakeup call info has been accepted and saved - and hang up after playing that message instead of right after the 5 digits are entered.

Can someone show me how to insert another "child" similar to:   {"module":"play", "data":{"id": "/56d9ba1fb0250f40eda173e93a0cba0d/47080efccc7f31b828ddf75dd94d1d7f"}} and move the last child

 "children":{}

to the end of the callflow sequence in this script? I've tried several times to modify the script but haven't gotten the desired result so far. 

Thanks in advance!

 

 
 

 

Link to comment
Share on other sites

Struggled with this myself when I created a module that allows people to dial in from the outside to update their forward. Had to have it password protected and provide success and error responses on the fly. What I did was to break down the callflows into methods where a controlling method was able to provide the logic and route to the next pivot. I'd suggest using Lumen or Silex to allow for the routes as you will need to create RESTapi routes for each pivot. There might be a more simple way but that worked for me and I ended up with a library of reusable callflows and logic that I can draw from for any Pivot project.    

Link to comment
Share on other sites

24 minutes ago, Andres Gomez said:

I think I found an easy way to do it. I'll post my results after I test it in case someone else needs it. This appraoch wasn't goping to work. What did work was to add a bit of JSON to the script that enters the wakeup call info into the database. 

In setWakeup.php ...

<?php

.

.

.header('content-type:application/json');
?>
{
    "module":"play",
    "data":{
        "id": "/56d9ba1fb0250f40eda173e93a0cba0d/e4b7fec7b3bfa1231098def68b049036"
    },
    "children": {}
}

6
15 hours ago, Andres Gomez said:

Hi!

We have this script which is run when a customer dials a Spree code to configure a wakeup call:

<?php

?>
{
    "module":"play",
    "data":{
        "id": "/56d9ba1fb0250f40eda173e93a0cba0d/47080efccc7f31b828ddf75dd94d1d7f"
    },
    "children": {
        "_": {
            "module": "collect_dtmf",
            "data": {
                "max_digits": 5,
                "collection_name": "custom_name"
            },
            "children": {
                "_": {
                    "module": "pivot",
                    "data": {
                        "voice_url": "http://pivot.server.com/pivot/{ACCOUNT}/setWakeup.php"
                    },
                    "children": {}
                }
            }
        }
    }
}

 

 

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...