message = {
"messaging_product": "whatsapp",
"recipient_type": "individual",
"to": user_id,
"type": "interactive",
"interactive": {
"type": "flow",
"header": {
"type": "text",
"text": "Welcome"
},
"body": {
"text": "Click fill form"
},
"action": {
"name": "flow",
"parameters": {
"flow_message_version": "3",
"flow_cta": "Fill form",
"flow_name": "my_main_form_name"
}
}
}
}
< /code>
message = {
"messaging_product": "whatsapp",
"to": user_id,
"type": "template",
"template": {
"name": "main_flow_en",
"language": {"code": "en"},
"components": [
{
"type": "body",
"parameters": [
{
"type": "text",
"parameter_name": "profile_name",
"text": profile_name
}
]
},
{
"type": "button",
"sub_type": "flow",
"index": "0",
"parameters": [
{
"type": "payload",
"payload": json.dumps({
"action": "INIT",
"data": {
"to_number": str(user_id)
}
})
}
]
}
]
}
}
< /code>
And tried these parameters:
{
"type": "button",
"sub_type": "flow",
"index": "0",
"parameters": [
{
"type": "action",
"action": {
"flow_action_data": {
"user_id": user_id,
"user_name": profile_name
}
}
}
]
}
< /code>
Flow endpoint code:
def handle_form_submission(event, context):
body = json.loads(event.get('body', '{}'))
decrypted = decrypt_flow_data(body)
logger.info("
user_id = decrypted.get('to_number')
action = decrypted.get('action')
screen = decrypted.get('screen')
data = decrypted.get('data') or {}
flow_token = decrypted.get('flow_token')
if action == 'INIT':
logger.info("
profile = get_user_profile(user_id)
store_user_data(user_id, {
'SK': 'META',
'flow_token': flow_token,
'profile_name': profile,
'started_at': iso_now()
})
response = {'version': '3.0', 'screen': 'MYFIRSTSCREEN',
'data': {'greeting': 'Welcome'}}
elif action == "ping":
response = {"version": "3.0", "data": {"status": "active"}}
elif action == 'data_exchange' and screen == 'MYFIRSTSCREEN':
....
Подробнее здесь: https://stackoverflow.com/questions/795 ... ctive-flow