TwiML bin 是否可以同时使用 Voice &短信功能?

编程入门 行业动态 更新时间:2024-10-21 03:19:57
本文介绍了TwiML bin 是否可以同时使用 Voice &短信功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

仅使用一个 TwiML bin,是否可以混合使用语音和 SMS 动词?我尝试时出错.

Using only a single TwiML bin, is it possible to mix voice and SMS verbs? I get errors when I try.

例如,一个电话打到 Twilio 号码上,TwiML 会首先发送一个 SMS {{From}}:<Body>Hello World!</Body>+18005551212 然后转接呼叫.另一个例子:当拨号未连接时,使用混合语音/短信发送短信进行处理.

For example, a call comes into a Twilio number, TwiML would first send an SMS <Message to="+18005551212"> {{From}}: <Body>Hello World!</Body> </Message> then forward the call <Dial>+18005551212</Dial>. Another example: use mixed Voice/SMS to send an SMS for handling when Dial doesn't connect.

如果目前无法实现,TwiML voice & 是否存在技术原因?TwiML SMS 无法进一步开发以实现互操作?

If it's not possible currently, is there a technical reason why TwiML voice & TwiML SMS couldn't be further developed to be interoperable?

推荐答案

Twilio 开发人员布道者在这里.

Twilio developer evangelist here.

想在这里跟进其他评论.如果您只是使用 TwiML Bin 来响应来电并且想要发送 SMS 消息,那么 动词就是你想要的.

Wanted to follow up with the other comments here. If you are just using a TwiML Bin to respond to an incoming call and you want to send SMS messages then the <Sms> verb is what you want.

但是,它已被弃用. 也不像消息 TwiML 中的 动词那样最新.它不能发送超过 160 个字符的消息或媒体消息或使用消息服务.

However, it is deprecated. <Sms> is also not as up to date as the <Message> verb in messaging TwiML. It can't send messages over 160 characters or media messages or use messaging services.

建议从 TwiML Bin 继续使用 REST API 发送消息,同时返回 TwiML 以控制调用.您可以使用 Twilio Function 来完成此操作,因此您仍然不需要托管任何内容.这是一个简单的例子:

The recommendation is to move on from a TwiML Bin and send the message using the REST API while returning TwiML to control the call. You could do this with a Twilio Function so you still wouldn't need to host anything. Here's a quick example:

exports.handler = function(context, event, callback) {
    const twilioClient = context.getTwilioClient();

    twilioClient.messages.create({
        to: TO_NUMBER,
        from: FROM_NUMBER
        body: "Hello world"
    }).then(function() {
        const twiml = new Twilio.twiml.VoiceResponse();
        twiml.dial(TO_NUMBER);

        callback(null, twiml);
    });
}

让我知道这是否有帮助.

Let me know if that helps at all.

这篇关于TwiML bin 是否可以同时使用 Voice &amp;短信功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-04-29 16:30:14,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1192125.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:短信功能   bin   TwiML   amp   Voice

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!