1.安装twilio

pip install twilio

2.官方注册账号token之类的

twiliophp发送短信Langchain应用Tools集成twilio发送短信 Angular

申请得到twilio的API Credentials,打开twilio网站:https://www.twilio.com/注册申请等操作,获取环境变量诸如TWILIO_ACCOUNT_SID, TWILIO_AUTH_TOKEN, TWILIO_FROM_NUMBER,

或者account_sid, auth_token,from_number

3.写代码

#引入TwilioAPIWrapper

from langchain.utilities.twilio import TwilioAPIWrapper

#API账号密钥手机号

twilio = TwilioAPIWrapper(

account_sid="ACxxx",

auth_token="xxx",

from_number="+10123456789"

)

#给发送号码发短信

twilio.run('hello world', '+12484345508')