Botones
Puedes usar botones con cada uno de estos tipos: call, url y node.
{
"version": "v1",
"content": {
"messages": [
{
"type": "text",
"text": "simple text",
"buttons": [
{
"type": "url",
"caption": "External link",
"url": "https://nicochat.com.br",
},
{
...Another buttons
}
]
},
{
...Another messages
}
],
"actions": [ //optional
{
"action": "add_tag",
"tag_name": "example tag"
},
{
...Another actions
}
],
"quick_replies": [ //optional
{
"type": "node",
"caption": "Quick reply text",
"target": "My Content"
},
{
...Another quick replies
}
]
}
}
Botón de llamada
{
"version": "v1",
"content": {
"messages": [
{
"type": "text",
"text": "simple text with button",
"buttons": [
{
"type": "call",
"caption": "Call me",
"phone": "+1 (555) 555-55-55"
}
]
}
],
"actions": [],
"quick_replies": []
}
}
Botón URL
Existen 3 opciones de webview_size:
full — 100%,
medium — 75%,
compact — 50%
La propiedad "webview_size" es opcional.
{
"version": "v1",
"content": {
"messages": [
{
"type": "text",
"text": "simple text with button",
"buttons": [
{
"type": "url",
"caption": "External link",
"url": "https://nicochat.com.br",
"webview_size": "full"
}
]
}
],
"actions": [],
"quick_replies": []
}
}
Botón Ir al nodo
{
"version": "v1",
"content": {
"messages": [
{
"type": "text",
"text": "simple text with button",
"buttons": [
{
"type": "node",
"caption": "Show",
"target": "My Content"
}
]
}
],
"actions": [],
"quick_replies": []
}
}
La clave target debe estar vinculada a un nodo existente en el flujo en ejecución. El nombre del nodo aparece en su encabezado; usa un nombre único para el nodo conectado al enlace. Si hay varios nodos con nombres similares dentro del mismo flujo, la transición no se comportará como se espera. Los botones Ir al nodo no son compatibles con la API pública.
Botón de callback de bloque dinámico
Las propiedades "headers" y "payload" son opcionales.
{
"version": "v1",
"content": {
"messages": [
{
"type": "text",
"text": "simple text with button",
"buttons": [
{
"type": "dynamic_block_callback",
"caption": "Dynamic content",
"url": "https://your-service.com/dynamic",
"method": "post",
"headers": {
"x-header": "value"
},
"payload": {
"key": "value"
}
}
]
}
],
"actions": [],
"quick_replies": []
}
}
El dynamic_block_callback funciona de la misma forma que el bloque dinámico en un nodo de contenido: al hacer clic, envía una solicitud al servidor, y la respuesta del servidor se envía al contacto. La URL del servidor externo debe usar el protocolo HTTPS.