在MS Access中使用twimlet——扩展可用性



我正在尝试使用Twilio在MS Access中实现自动调用。有一个关于如何开始的Twilio示例,我能够让它为我们的设置工作。但是,它在http请求中使用twimlet来启动调用。据我所知,twimlet只接受打电话的号码和发短信的方式。是否有方法从MSA/VBA访问twilio调用的其他参数,例如语音、暂停、机器检测等?我可以想象一个接受TWIML的twimlet,或者一种无需返回URL即可直接发送TWIML的方式。思想

您可以使用Echo Twimlet。在Configurator中放置您希望twilio处理的所有信息(查看TwilioML-API参考中的正确动词)。

你的问题可能看起来像:

<Response>
    <Say voice="woman" language="fr">Bonjour Monsieur!</Say>
</Response>

Configurator会返回一个URL,如下所示:

http://twimlets.com/echo?Twiml=%3CResponse%3E%0A%3CSay%20voice%3D%22woman%22%20language%3D%22fr%22%3EBonjour%20Monsieur!%3C%2FSay%3E%0A%3C%2FResponse%3E%0A&

现在,您需要将Text Bonjour%20Monsieur!替换为自动生成的文本。

UPDATE:prepareWimletAdr创建与Configurator相同的字符串。所以现在您的VisualBasic发送例程可能看起来像这样:

Function VoiceCall(fromNumber As String, toNumber As String, twimletAdr As String)
Dim CallUrl As String
CallUrl = BASEURL & "/2010-04-01/Accounts/" & ACCOUNTSID & "/Calls"
  ' setup the request and authorization
  Dim http As MSXML2.XMLHTTP60
  Set http = New MSXML2.XMLHTTP60
  http.Open "POST", CallUrl, False, ACCOUNTSID, AUTHTOKEN
  http.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
  Dim postData As String
  postData = "From=" & fromNumber _
  & "&To=" & toNumber _
  & "&Url=" & twimletAdr
  ' send the POST data
  http.send postData
  .....
End Function
Function prepareTwimletAdr(msg as String, voice as String="woman", lang as String="en")
  dim adr as string
  adr="http://twimlets.com/echo?Twiml=%3CResponse%3E%0A%3CSay%20"
  adr=adr & "voice%3D%22" & voice & "%22%20"
  adr=adr & "language%3D%22" & lang & "%22"
  adr=adr & "%3E"
  adr=adr & Replace(msg," ","%20"
  adr=adr & "%3C%2FSay%3E%0A%3C%2FResponse%3E%0A&"
  prepareTwimletAdr=adr
End Function

你会称之为

 VoiceCall myNumber, callingTo, prepareTwimletAdr("Hello, this is my message","alice","en-gb")

另一种选择是,如果你有一个Twilio可以访问的带有PHP的公共Web服务器,你可以在那里处理消息。URL将是您的服务器,其中包含所需的参数(http://yourCompany.com/TwilioApp?say=hello&voice=woman),Web服务器上的PHP代码应返回适当的XML。有一个PHP TwiML库可以帮助您组合XML响应:

/* Put this in the response function of your /TwilioApp-route */
$response = new Services_Twilio_Twiml();
$message = $_GET['say'];
$voice =  $_GET['voice'];
$response->say($message);
$response->voice($voice);
echo $response;

如果采用这种方式,就可以自己生成XML,并充分利用TwiML库的潜力。

最新更新