Coldfusion Twilio-在漫长的过程中播放音乐

Coldfusion Twilio-在漫长的过程中播放音乐,coldfusion,twilio,twilio-functions,Coldfusion,Twilio,Twilio Functions,我是Twilio新手 我有一个Twilio语音应用程序,它收集了大量的数据(国际补足销售)-购买补足的实际过程在某一点上进行 这个过程可以在任何地方持续10到30秒,其中大部分大约15秒。听起来好像我需要使用Twilio标记(),但它不起作用 我只是这样称呼它(恰巧是ColdFusion): processtoup 在processtoup.cfm文件中有标记(该标记不起作用,因为该页面需要15秒以上的时间) 抱歉-但我只是对这应该如何工作感到困惑。提前谢谢!这里有一个可能的解决方案。我已经测

我是Twilio新手

我有一个Twilio语音应用程序,它收集了大量的数据(国际补足销售)-购买补足的实际过程在某一点上进行

这个过程可以在任何地方持续10到30秒,其中大部分大约15秒。听起来好像我需要使用Twilio
标记(),但它不起作用

我只是这样称呼它(恰巧是ColdFusion):

processtoup
processtoup.cfm
文件中有
标记(该标记不起作用,因为该页面需要15秒以上的时间)


抱歉-但我只是对这应该如何工作感到困惑。提前谢谢!

这里有一个可能的解决方案。我已经测试过了,它可以工作了

其主要思想是在循环中播放一些消息/音乐,直到ColdFusion完成任务,然后在ColdFusion完成后,通过向Twilio的API调用资源发出POST请求,指示调用执行不同的Twilio XML

当一个调用进入,Twilio点击您的端点时,捕获调用id,它将用于将调用切换到不同的XML。调用id将作为
表单传递。CALLSID
URL.CALLSID
取决于Twilio上的webhook配置

调用id类似于
CAdecbfa7e8e2a9d09336abcd57044cf74

通过流传递调用id(url参数应该可以),使其到达
processtoup.cfm

将长时间运行的代码从
processtoup.cfm
移动到
processtoup action.cfm

<!--- // place your long running code here --->

<cfset accountSid = '{your account sid}' />
<cfset authToken = '{your auth token}' />

<cfhttp 
    url="https://api.twilio.com/2010-04-01/Accounts/#variables.accountSid#/Calls/#URL.CALLSID#.json" 
    method="POST" 
    username="#variables.accountSid#" 
    password="#variables.authToken#"
    result="http_result">

    <cfhttpparam 
        name="Url" 
        value="http://www.yourwebsite.com/finish.cfm" 
        type="formfield" />

</cfhttp>
<cfoutput><?xml version="1.0" encoding="UTF-8"?>

<Response>
    <Say>This is the data you're looking for.</Say>
    <Say>Thank you. Goodbye!</Say>
    <Hangup />
</Response>

</cfoutput>

processtopup.cfm中的代码现在应该立即返回XML以播放循环(或者您可以播放一些.mp3),我将显示一条消息:

<cfoutput><?xml version="1.0" encoding="UTF-8"?>

<Response>
    <Say loop="0">Please wait while we process your request...</Say>
</Response>

</cfoutput>

<cfhttp 
    url="http://www.yourwebsite.com/processtopup-action.cfm?callsid=#FORM.CALLSID#" 
    method="get" 
    timeout="1" />

用于finish.cfm的代码

<!--- // place your long running code here --->

<cfset accountSid = '{your account sid}' />
<cfset authToken = '{your auth token}' />

<cfhttp 
    url="https://api.twilio.com/2010-04-01/Accounts/#variables.accountSid#/Calls/#URL.CALLSID#.json" 
    method="POST" 
    username="#variables.accountSid#" 
    password="#variables.authToken#"
    result="http_result">

    <cfhttpparam 
        name="Url" 
        value="http://www.yourwebsite.com/finish.cfm" 
        type="formfield" />

</cfhttp>
<cfoutput><?xml version="1.0" encoding="UTF-8"?>

<Response>
    <Say>This is the data you're looking for.</Say>
    <Say>Thank you. Goodbye!</Say>
    <Hangup />
</Response>

</cfoutput>

这是您正在查找的数据。
谢谢,再见!
当然,您可以根据需要传递其他参数


同样,其主要思想是执行长时间运行的代码后,向Twilio的API发出POST请求,并指示调用switch以执行位于
http://www.yourwebsite.com/finish.cfm

<!--- // place your long running code here --->

<cfset accountSid = '{your account sid}' />
<cfset authToken = '{your auth token}' />

<cfhttp 
    url="https://api.twilio.com/2010-04-01/Accounts/#variables.accountSid#/Calls/#URL.CALLSID#.json" 
    method="POST" 
    username="#variables.accountSid#" 
    password="#variables.authToken#"
    result="http_result">

    <cfhttpparam 
        name="Url" 
        value="http://www.yourwebsite.com/finish.cfm" 
        type="formfield" />

</cfhttp>
<cfoutput><?xml version="1.0" encoding="UTF-8"?>

<Response>
    <Say>This is the data you're looking for.</Say>
    <Say>Thank you. Goodbye!</Say>
    <Hangup />
</Response>

</cfoutput>

文档:

  • 通过Twilio REST API调用重定向
    • ()
  • 修改实时通话
    • ()

它不在ColdFusion中,但在概念上听起来很相似,请查看这篇关于在IVR中执行长时间运行任务的Twilio博客文章:我目前正在使用CF9.01Alex-谢谢!!!经过一些曲折,我终于成功了!!!-再次感谢!-太棒了!!!