2016-08-18 55 views
-1

我在Microsoft Azure中使用Twilio node.js API發送SMS。我想創建一些預定義的模板,如'尊敬的客戶您的帳戶餘額是55555盧比'。在Twilio中創建SMS模板

是否可以在Twilio帳戶中創建SMS模板? Twilio是否支持交易短信?

+0

歡迎所以。尋求代碼幫助的問題必須包含在問題本身中重現問題所需的最短代碼。請閱讀[怎麼問](http://stackoverflow.com/questions/how-to-ask) –

+0

到目前爲止,你有什麼嘗試?你有沒有簽出[Twilio教程](https://www.twilio.com/docs/tutorials/)?這個[Node.js中的短信通知](https://www.twilio.com/docs/tutorials/walkthrough/server-notifications/node/express)可能會有所幫助。 – philnash

+0

發送短信到手機對我來說工作正常。但我想使用動態內容而不是靜態主體。例如,「尊敬的客戶,您的賬戶餘額是Rs XXXXX」將成爲模板,這可以在Twilio賬戶中定義。然後我想在我的node.js代碼中使用這個模板,並將動態內容替換爲XXXXX。可能嗎 ? – Deepthi

回答

0

您需要定義從快速入門在你的名字(Python中所示),以一個回覆發件人類似於下面的示例的方式,動態內容:

https://www.twilio.com/docs/quickstart/python/sms/replying-to-sms-messages

from flask import Flask, request, redirect 
import twilio.twiml 

app = Flask(__name__) 

# Try adding your own number to this list! 
callers = { 
    "+14158675309": "Curious George", 
    "+14158675310": "Boots", 
    "+14158675311": "Virgil", 
} 

@app.route("/", methods=['GET', 'POST']) 
def hello_monkey(): 
    """Respond and greet the caller by name.""" 

    from_number = request.values.get('From', None) 
    if from_number in callers: 
     message = callers[from_number] + ", thanks for the message!" 
    else: 
     message = "Monkey, thanks for the message!" 

    resp = twilio.twiml.Response() 
    resp.message(message) 

    return str(resp) 

if __name__ == "__main__": 
    app.run(debug=True)