【发布时间】:2019-07-29 03:41:05
【问题描述】:
我已经集成了 DialogFlow 和 Telegram。
我在 fullfilment 发送 webhook。
如何获取用户 Telegram 电话号码并将其发送到 webhook?
谢谢。
【问题讨论】:
我已经集成了 DialogFlow 和 Telegram。
我在 fullfilment 发送 webhook。
如何获取用户 Telegram 电话号码并将其发送到 webhook?
谢谢。
【问题讨论】:
您不会从 Telegram Bot API 获得电话号码,但您可以提取用户 ID。这是您将在 webhook 中收到的示例负载(在 request['originalDetectIntentRequest']['payload'] 节点中):
{
'source':'telegram',
'data':{
'update_id':123456789.0,
'message':{
'from':{
'is_bot':False,
'username':'user_name',
'id':123456789.0,
'language_code':'pl',
'last_name':'Last Name',
'first_name':'First Name'
},
'chat':{
'type':'private',
'last_name':'Last Name',
'id':123456789.0,
'first_name':'First Name',
'username':'user_name'
},
'message_id':258.0,
'text':'user message',
'date':1564341923.0
}
}
}
获取用户电话号码的唯一方法是询问他。你可以在这里找到更多信息:https://core.telegram.org/bots/2-0-intro#locations-and-numbers
【讨论】: