Fully Working - but have a few questions...

Events happening in the community are now at Drupal community events on www.drupal.org.
jeffvanh's picture

First, I must say, WOW! I have put together a pretty powerful system using this technology - and it is, for the most part, working really well. I have managed to get the full integration working - including retrieval of nodes by telephone (which is totally cool). That said, I have run into a few "how to" questions that I just can't seem to find a good answer to:

  1. When you are having the user record something (i.e. $script->addRecord), how do you detect if the user doesn't, well, actually record anything? I know that you can do a timeout (which doesn't really solve the issue) - but, for example, if the user is supposed to say something - and doesn't - how can I find out?

  2. I have run into a couple of issues with the VOIP Number - I just can't seem to figure out how to programatically populate it. For some reason. Probably something simple - but an example would be super great.

  3. Is there anyway to detect that the user has hung up the phone during the process (i.e. a callback to indicate that the script has been terminated)? I would love to be able to do some housekeeping during this time. I have worked around this to some extent, but knowing it would be highly useful.

  4. Is there a way to return an array from a callback? For example, if I do something like this (code fragment):

$script->addSet('somevalue','^%_function(%blah,%blah2)');

I can make the function return a string (and yes, I have worked around it by using the json_encode and json_decode functionality), but it would be really cool to be able to return multiple values in an array. Is there a way to make this happen?

Other than that, this is working out really good. At some point (when I get a minute), I will post some of the "lessons learned" in figuring this out - but these are really my only stumbling blocks at the moment.

Thanks,

Jeff :-)

PS Running the latest release (I think beta 6, or whatever was just released). Platform is drupal 6.

Comments

might need to be a

ben.bunk's picture
  1. might need to be a voice-to-text method from an external service...otherwise I can't imagine how anyone would really known unless you figured out a baseline for the size of white noise in bytes and compared it to the user input.

  2. When you say VOIP number do you mean $call->setDestNumber('1234567890');

  3. $call->getCallStatus() should give you the current status. You can run a loop

    <?php
    while($call->getCallStatus() !== (COMPLETED, NO_ANSWER, BUSY, INVALID, CANCELED)) { print $call-getcallStatus(); }
    ?>

Gave the matter some more thought

jeffvanh's picture
  1. Hmmm - that seems to be an issue. I was reading a bit on the Twilio site, and they are saying that a "fully silent" file should be 0 seconds - I will have to try and test that out (supposedly, they trim off anything silent). If that works, this would be good.

  2. No - I was referring to the CCK field type VOIP Number. I just haven't found a way to set the number from PHP. I finally just gave up and went to a standard text field.

  3. I was aware of this - but the issue is that this only happens when it is called. What I was looking for was something which was more "interactive" - i.e. onHangUp (or whatever). I worked around the issue today by just doing the standard "press 1 if you really mean it" - so that I can make sure that the user made it to the end of the process (without abandoning things).

Another attempt to answer your questions...

leoburd's picture

Hi jeffvanh,

Here go my contributions...

1. How to identify empty recordings? As you figured out by yourself, each VoIP Server might have a different response to that. In the case of Twilio, the duration of the recorded file should be 0. You can check that by accessing the "recording_duration" variable from inside your script with something like $script->addSay("Recorded file was %recording_duration seconds long.").

2. How to set the value of a VoipNumber field programatically?. Currently it is not possible to create a VoIP Number through the API. The workaround would be to set your VoipNumber manually, the way you'd do with other CCK fields. I hope this code snippet can help you:

$node = new stdClass();
// set the node type to your content type
$node->type = 'mycontenttype';
// set the desired VoipNumber field (in this case, "field_myvoipnumberfield") to the appropriate value
$node->field_myvoipnumberfield[0]['number_prefix'] = 'United States of America'; // name of the country
$node->field_myvoipnumberfield[0]['phone'] = '123456778'; // your number here, without country prefix
node_save($node);

3. How to handle hang ups in the middle of the process? VoipCall objects have a special script that is called whenever the call is hang up. You can set that script by calling
$mycallobject->setHangupScriptName($script_name); Would that address your issue?

4. Is there a way to return an array from a callback?. Sorry, that's currently not possible. The only way of doing that is via the json_decode/_encode functions as you've already figured out.

Let us know if the above suggestions work for you, ok? If you have any ideas to improve VoIP Drupal, please send them to us!

All the best,

Leo

Ok, that answers those

jeffvanh's picture
  1. This looks like it will work - I am going to test it out.

  2. Ok, that code fragment answers my question.

  3. The callback is exactly what I was looking for. That will do things splendidly.

  4. Fine. json_encode works - not elegant, but working.

Thanks,

Jeff :-)

VoIP Drupal

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: