Este documento inclui algumas recomendações para desenvolvedores, que surgem da experiência desenvolvendo WhatsApp Flows dinâmicos no Botmaker.
Este documento inclui algumas recomendações para desenvolvedores, que surgem da experiência desenvolvendo WhatsApp Flows dinâmicos no Botmaker. É importante esclarecer que ele não busca substituir a documentação publicada pela Meta, sendo, na verdade, informação complementar.
META, documentação oficial:
https://developers.facebook.com/docs/whatsapp/flows
DICAS:
Exemplo: Compartilhamos um exemplo em que a primeira screen envia um texto, esse texto é enviado ao endpoint e retornado em maiúsculas para a segunda screen:
JSON FLOW
```
{
"data_api_version": "3.0",
"data_channel_uri": "https://functions.botmaker.com/whatsapp-flows/TuBusinessID/WabaID/dinamic",
"routing_model": {
"SHARE": ["RESPONSE"],
"RESPONSE": []
},
"screens": [{
"layout": {
"children": [{
"children": [{
"text": "Aquí puedes escribir tu nombre:",
"type": "TextSubheading"
}, {
"name": "comment_text",
"label": "",
"type": "TextArea",
"required": true,
"helper-text": "Tus nombres y apellidos"
}, {
"label": "Continuar",
"on-click-action": {
"payload": {
"comment_text": "${form.comment_text}"
},
"name": "data_exchange"
},
"type": "Footer"
}],
"name": "form",
"type": "Form"
}],
"type": "SingleColumnLayout"
},
"data": {
"comment_text": {
"type": "string",
"__example__": "Example"
}
},
"id": "SHARE",
"terminal": false,
"title": "Share Name"
}, {
"layout": {
"children": [{
"children": [{
"text": "Antes de continuar revisa que tomamos correctamente tu nombre:",
"type": "TextCaption"
}, {
"text": "${data.comment_text}",
"type": "TextSubheading"
}, {
"label": "Finalizar",
"on-click-action": {
"payload": {
"comment_text": "${data.comment_text}"
},
"name": "complete"
},
"type": "Footer"
}],
"name": "form",
"type": "Form"
}],
"type": "SingleColumnLayout"
},
"data": {
"comment_text": {
"type": "string",
"__example__": "Example"
}
},
"id": "RESPONSE",
"terminal": true,
"title": "Confirmation"
}],
"version": "2.1"
}
```
CA de tipo FLOW ENDPOINT “dinamic”
```
const FIRST_SCREEN = screen === 'SHARE';
bmconsole.log(JSON.stringify(data));
if (FIRST_SCREEN) {
flow.data = {
comment_text: data.comment_text.toLocaleUpperCase(),
};
flow.nextScreen = 'RESPONSE';
flow.send(); // remember to always call flow.send()
}
```
Lembre-se de visitar nossa Central de Ajuda para obter mais informações.