This document includes some recommendations for developers, drawn from experience developing dynamic WhatsApp Flows in Botmaker.
This document includes some recommendations for developers, drawn from experience developing dynamic WhatsApp Flows in Botmaker. It's important to clarify that it doesn't seek to replace Meta's official documentation; rather, it's complementary information.
META, official documentation:
https://developers.facebook.com/docs/whatsapp/flows
TIPS:
Example: Here's an example where the first screen sends a text, sends it to the endpoint, and returns it in uppercase to the second screen:
FLOW JSON
```
{
"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()
}
```
Remember to visit our Help Center for further information.