Antes de começarmos...
Para que você consiga executar as configurações a seguir, é sugerido dominar os conceitos de variáveis na Zenvia Bots (artigo) e principalmente o tratamento do Ponto de Decisão (artigo) durante as jornadas.
A dinâmica dos exemplos que serão mostrados estão atreladas a estrutura de fluxo onde uma variável X (independente do nome) possui seu tratamento e validação a partir de um ponto de decisão.
Importante
Acompanhado das validações, estão as estruturas em Json para que sejam coladas em fluxos novos com o objetivo de ajudar na criação.
Lembrando que, as regras podem ser realizadas de diferentes formas e em diferentes momentos: após uma resposta, após uma chamada de API, após Webhook, como primeira validação, como segunda, entre outros!
Validação de palavra
Utilizado para que a variável receba apenas o valor determinado entre as aspas simples dos parênteses.
Título (sugestão): Digitou corretamente os países?
Nome: Sim!!
Tipo: Expression
Condição*: #text.keyword(paises,'Brasil','EUA','Mexico') != null
*Para editar o leque de palavras, basta incluir os dados entre as aspas simples, não havendo limitação em quantidade.
No exemplo acima, caso a variavel paises seja populada com os conteúdos Brasil, EUA ou México, iremos tomar como válido.
Tudo que for diferente disso, será direcionado para o inválido e tratado no fluxo.
Json de exemplo:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130{ "alias": "Exemplo Regex", "description": "", "steps": [ { "id": "step03", "type": "branch", "label": "Digitou corretamente os países" }, { "id": "step05", "type": "sendChatActivity", "properties": { "from": "#{session['chatFrom']}" }, "contents": [ { "type": "text/plain", "payload": { "text": "[Entrar conteúdo da mensagem de acordo com a seguinte condição: Inválido]" } } ] }, { "id": "step04", "type": "sendChatActivity", "properties": { "from": "#{session['chatFrom']}" }, "contents": [ { "type": "text/plain", "payload": { "text": "[Entrar conteúdo da mensagem de acordo com a seguinte condição: Sim!!!]" } } ] }, { "id": "step02", "type": "chatEvent", "variables": { "paises": "payload" } }, { "id": "step0", "type": "sendChatActivity", "properties": { "from": "#{session['chatFrom']}" }, "contents": [ { "type": "text/plain", "payload": { "text": "Digite o país" } } ] }, { "id": "idEventoFinal", "type": "endEvent", "label": "label 3", "properties": { "endEvent": "true" } }, { "id": "idEventoInicial", "type": "chatEvent", "label": "Evento inicial", "properties": { "startEvent": "true" }, "variables": { "chatFrom": "'INTEGRACAO_CANAL_AQUI_PUBLICAR'" }, "conditions": [ { "type": "channelSourceCondition", "values": [ "INTEGRACAO_CANAL_AQUI_PUBLICAR" ] } ] } ], "connections": [ { "from": "step03", "to": "step05", "label": "Inválido", "isDefault": true }, { "from": "step05", "to": "step02" }, { "from": "step0", "to": "step02" }, { "from": "step04", "to": "idEventoFinal" }, { "from": "step02", "to": "step03" }, { "from": "idEventoInicial", "to": "step0" }, { "from": "step03", "to": "step04", "label": "Sim!!!", "conditions": [ { "type": "elCondition", "expression": "#text.keyword(paises,'Brasil','EUA','Mexico') != null" } ] } ], "defaultConversationalChannel": "CHAT" }
Validação de chamada de API com sucesso
Importante validador depois de qualquer chamada de API mitigando possíveis erros ou falhas de retorno. No exemplo de regra, caso o retorno da API obtiver sucesso (200), iremos seguir para uma etapa do fluxo. Tratando o inválido como tudo que for diferente de 200, o fluxo poderá seguir outro caminho como por exemplo de transbordar ao atendimento humano ou tentar novamente a chamada.
Título (sugestão): Decisão API Válida?
Nome (sugestão): Sim!
Tipo: Expression
Condição: httpStatus == 200
No exemplo acima, tudo que for diferente de "Validação API" será direcionado para o inválido e tratado no fluxo.
Json de exemplo:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128{ "alias": "Exemplo Regex", "description": "", "steps": [ { "id": "step03", "type": "branch", "label": "Chama API Sucesso?" }, { "id": "step05", "type": "sendChatActivity", "properties": { "from": "#{session['chatFrom']}" }, "contents": [ { "type": "text/plain", "payload": { "text": "Chamada de API com erro. Resultou diferente de 200." } } ] }, { "id": "step04", "type": "sendChatActivity", "properties": { "from": "#{session['chatFrom']}" }, "contents": [ { "type": "text/plain", "payload": { "text": "[Entrar conteúdo da mensagem de acordo com a seguinte condição: Sim!!!]" } } ] }, { "id": "idEventoFinal", "type": "endEvent", "label": "label 3", "properties": { "endEvent": "true" } }, { "id": "idEventoInicial", "type": "chatEvent", "label": "Evento inicial", "properties": { "startEvent": "true" }, "variables": { "chatFrom": "'INTEGRACAO_CANAL_AQUI_PUBLICAR'" }, "conditions": [ { "type": "channelSourceCondition", "values": [ "INTEGRACAO_CANAL_AQUI_PUBLICAR" ] } ] }, { "id": "step0", "type": "apiActivity", "properties": { "from": "#{#random.randomAlphanumeric(12)}", "timeUnit": "minute", "expirationInMinutes": "" }, "contents": [ { "type": "application/json", "payload": { "json": { "httpMethod": "GET", "url": "endpoint.api", "httpHeaders": { "Content-Type": "application/json" } } } } ], "label": "Chamada de API" } ], "connections": [ { "from": "step04", "to": "idEventoFinal" }, { "from": "idEventoInicial", "to": "step0" }, { "from": "step0", "to": "step03" }, { "conditions": [ { "type": "elCondition", "expression": "httpStatus == 200" } ], "from": "step03", "to": "step04", "label": "Sim!!!" }, { "from": "step03", "to": "step05", "label": "Inválido", "isDefault": true }, { "from": "step05", "to": "idEventoFinal" } ], "defaultConversationalChannel": "CHAT" }
Array vazio
É possível inserir na Expression da decisão a possibilidade de validar caso o array da chamada de API for vazio e o fluxo ser direcionado para outro local.
Título (sugestão): Array Vazio?
Nome (sugestão): Sim, vazio!!
Tipo: Expression
Condição: response.isEmpty()
No exemplo acima, tudo que for diferente de "Array Vazio" será direcionado para o inválido e tratado no fluxo.
Json de exemplo:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128{ "alias": "Exemplo Regex", "description": "", "steps": [ { "id": "step03", "type": "branch", "label": "Array Vazio?" }, { "id": "step05", "type": "sendChatActivity", "properties": { "from": "#{session['chatFrom']}" }, "contents": [ { "type": "text/plain", "payload": { "text": "Array com conteúdo." } } ] }, { "id": "step04", "type": "sendChatActivity", "properties": { "from": "#{session['chatFrom']}" }, "contents": [ { "type": "text/plain", "payload": { "text": "Array Vazio!" } } ] }, { "id": "idEventoFinal", "type": "endEvent", "label": "label 3", "properties": { "endEvent": "true" } }, { "id": "idEventoInicial", "type": "chatEvent", "label": "Evento inicial", "properties": { "startEvent": "true" }, "variables": { "chatFrom": "'INTEGRACAO_CANAL_AQUI_PUBLICAR'" }, "conditions": [ { "type": "channelSourceCondition", "values": [ "INTEGRACAO_CANAL_AQUI_PUBLICAR" ] } ] }, { "id": "step0", "type": "apiActivity", "label": "Chamada de API", "properties": { "from": "#{#random.randomAlphanumeric(12)}", "timeUnit": "minute", "expirationInMinutes": "" }, "contents": [ { "type": "application/json", "payload": { "json": { "httpMethod": "GET", "url": "endpoint.api", "httpHeaders": { "Content-Type": "application/json" } } } } ] } ], "connections": [ { "from": "step04", "to": "idEventoFinal" }, { "from": "idEventoInicial", "to": "step0" }, { "from": "step0", "to": "step03" }, { "from": "step05", "to": "idEventoFinal" }, { "conditions": [ { "type": "elCondition", "expression": "response.isEmpty()" } ], "from": "step03", "to": "step04", "label": "Sim, vazio!" }, { "from": "step03", "to": "step05", "label": "Inválido", "isDefault": true } ], "defaultConversationalChannel": "CHAT" }
Permitir X quantidades de caracteres apenas
É possível realizar qualquer restrição de letras e caracteres, inseridos dentro dos colchetes, no exemplo abaixo:
variavel matches '^[a-z]{2}$'
Ou
variavel matches '^[a-z]{2}|[A-Z]{2}$'
No exemplo acima, se o valor da variável respondida for diferente de letras maiúsculas ou minúsculas, será direcionado para o inválido e tratado no fluxo.
Json de exemplo:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130{ "alias": "Exemplo Regex", "description": "", "steps": [ { "id": "step03", "type": "branch", "label": "Digitou corretamente?" }, { "id": "step05", "type": "sendChatActivity", "properties": { "from": "#{session['chatFrom']}" }, "contents": [ { "type": "text/plain", "payload": { "text": "Algo deu errado." } } ] }, { "id": "step04", "type": "sendChatActivity", "properties": { "from": "#{session['chatFrom']}" }, "contents": [ { "type": "text/plain", "payload": { "text": "Digitou conforme a validação. Ok!" } } ] }, { "id": "idEventoFinal", "type": "endEvent", "label": "label 3", "properties": { "endEvent": "true" } }, { "id": "idEventoInicial", "type": "chatEvent", "label": "Evento inicial", "properties": { "startEvent": "true" }, "variables": { "chatFrom": "'INTEGRACAO_CANAL_AQUI_PUBLICAR'" }, "conditions": [ { "type": "channelSourceCondition", "values": [ "INTEGRACAO_CANAL_AQUI_PUBLICAR" ] } ] }, { "id": "step0", "type": "sendChatActivity", "properties": { "from": "#{session['chatFrom']}" }, "contents": [ { "type": "text/plain", "payload": { "text": "Validação de caracteres. Digite algo." } } ] }, { "id": "step02", "type": "chatEvent", "variables": { "variavel": "payload" } } ], "connections": [ { "from": "step04", "to": "idEventoFinal" }, { "from": "step05", "to": "idEventoFinal" }, { "from": "idEventoInicial", "to": "step0" }, { "from": "step0", "to": "step02" }, { "from": "step02", "to": "step03" }, { "conditions": [ { "type": "elCondition", "expression": "variavel matches '^[a-z]{2}|[A-Z]{2}$'" } ], "from": "step03", "to": "step04", "label": "Sim!" }, { "from": "step03", "to": "step05", "label": "Inválido", "isDefault": true } ], "defaultConversationalChannel": "CHAT" }
Validação se usuário digitou a quantidade do intervalo de números
Caso seja digitado uma quantidade diferente do intervalo (regra) dentro das chaves, deverá ser tratado no inválio.
variavel matches '^\d{1,9}$'
No exemplo acima, se o valor da variável respondida for por exemplo 12345678910, a validação já irá ser direcionada para o inválido e tratado no fluxo.
Pois irá ser válido apenas se digitar uma quantidade de números de 1 a 9. Ex válido: 847503859
Json de exemplo:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130{ "alias": "Exemplo Regex", "description": "", "steps": [ { "id": "step03", "type": "branch", "label": "Digitou corretamente?" }, { "id": "step05", "type": "sendChatActivity", "properties": { "from": "#{session['chatFrom']}" }, "contents": [ { "type": "text/plain", "payload": { "text": "Algo deu errado." } } ] }, { "id": "step04", "type": "sendChatActivity", "properties": { "from": "#{session['chatFrom']}" }, "contents": [ { "type": "text/plain", "payload": { "text": "Digitou conforme a validação. Ok!" } } ] }, { "id": "idEventoFinal", "type": "endEvent", "label": "label 3", "properties": { "endEvent": "true" } }, { "id": "idEventoInicial", "type": "chatEvent", "label": "Evento inicial", "properties": { "startEvent": "true" }, "variables": { "chatFrom": "'INTEGRACAO_CANAL_AQUI_PUBLICAR'" }, "conditions": [ { "type": "channelSourceCondition", "values": [ "INTEGRACAO_CANAL_AQUI_PUBLICAR" ] } ] }, { "id": "step0", "type": "sendChatActivity", "properties": { "from": "#{session['chatFrom']}" }, "contents": [ { "type": "text/plain", "payload": { "text": "Validação de quantidade de números." } } ] }, { "id": "step02", "type": "chatEvent", "variables": { "variavel": "payload" } } ], "connections": [ { "from": "step04", "to": "idEventoFinal" }, { "from": "step05", "to": "idEventoFinal" }, { "from": "idEventoInicial", "to": "step0" }, { "from": "step0", "to": "step02" }, { "from": "step02", "to": "step03" }, { "conditions": [ { "type": "elCondition", "expression": "variavel matches '^\\d{1,9}$'" } ], "from": "step03", "to": "step04", "label": "Sim!" }, { "from": "step03", "to": "step05", "label": "Inválido", "isDefault": true } ], "defaultConversationalChannel": "CHAT" }
Validação se usuário digitou a quantidade exata de números
Diferente do exemplo acima, nesse cenário é validado a quantidade exata de caracteres de dentro das chaves. Um exemplo é a validação de CPF que possui 11 caracteres:
variavel matches '^\d{11}$'
No exemplo acima, se o valor da variável respondida for diferente de exatas 11 posições, será direcionado para o inválido e tratado no fluxo. Ex válido: 12345678912 (11 caracteres).
Json de exemplo:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130{ "alias": "Exemplo Regex", "description": "", "steps": [ { "id": "step03", "type": "branch", "label": "Digitou corretamente?" }, { "id": "step05", "type": "sendChatActivity", "properties": { "from": "#{session['chatFrom']}" }, "contents": [ { "type": "text/plain", "payload": { "text": "Algo deu errado." } } ] }, { "id": "step04", "type": "sendChatActivity", "properties": { "from": "#{session['chatFrom']}" }, "contents": [ { "type": "text/plain", "payload": { "text": "Digitou conforme a validação. Ok!" } } ] }, { "id": "idEventoFinal", "type": "endEvent", "label": "label 3", "properties": { "endEvent": "true" } }, { "id": "idEventoInicial", "type": "chatEvent", "label": "Evento inicial", "properties": { "startEvent": "true" }, "variables": { "chatFrom": "'INTEGRACAO_CANAL_AQUI_PUBLICAR'" }, "conditions": [ { "type": "channelSourceCondition", "values": [ "INTEGRACAO_CANAL_AQUI_PUBLICAR" ] } ] }, { "id": "step0", "type": "sendChatActivity", "properties": { "from": "#{session['chatFrom']}" }, "contents": [ { "type": "text/plain", "payload": { "text": "Validação de quantidade exata de números." } } ] }, { "id": "step02", "type": "chatEvent", "variables": { "variavel": "payload" } } ], "connections": [ { "from": "step04", "to": "idEventoFinal" }, { "from": "step05", "to": "idEventoFinal" }, { "from": "idEventoInicial", "to": "step0" }, { "from": "step0", "to": "step02" }, { "from": "step02", "to": "step03" }, { "conditions": [ { "type": "elCondition", "expression": "variavel matches '^\\d{11}$'" } ], "from": "step03", "to": "step04", "label": "Sim!" }, { "from": "step03", "to": "step05", "label": "Inválido", "isDefault": true } ], "defaultConversationalChannel": "CHAT" }
Validação de imagem com as suas extensões
Permite que você valide na decisão e a imagem inserida pelo cliente está de acordo com as extensões que você configurou, como: jpeg, pdf, jpg ou png.
(fileUrl != null AND fileMimeType == 'image/jpeg') OR (fileUrl != null AND fileMimeType == 'application/pdf') OR (fileUrl != null AND fileMimeType == 'application/jpg') OR (fileUrl != null AND fileMimeType == 'application/png')
No exemplo acima, se a imagem carregada for diferente das extensões, será direcionado para o inválido e tratado no fluxo. Ex: se o usuário digitar alguma palavra ao invés de importar um arquivo, é necessário configurar uma mensagem no tratamento de inválido solicitando que o mesmo insira uma imagem.
Json de exemplo:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130{ "alias": "Exemplo Regex", "description": "", "steps": [ { "id": "step03", "type": "branch", "label": "Extensão correta?" }, { "id": "step05", "type": "sendChatActivity", "properties": { "from": "#{session['chatFrom']}" }, "contents": [ { "type": "text/plain", "payload": { "text": "Algo deu errado." } } ] }, { "id": "step04", "type": "sendChatActivity", "properties": { "from": "#{session['chatFrom']}" }, "contents": [ { "type": "text/plain", "payload": { "text": "Arquivo com extensão correta!" } } ] }, { "id": "idEventoFinal", "type": "endEvent", "label": "label 3", "properties": { "endEvent": "true" } }, { "id": "idEventoInicial", "type": "chatEvent", "label": "Evento inicial", "properties": { "startEvent": "true" }, "variables": { "chatFrom": "'INTEGRACAO_CANAL_AQUI_PUBLICAR'" }, "conditions": [ { "type": "channelSourceCondition", "values": [ "INTEGRACAO_CANAL_AQUI_PUBLICAR" ] } ] }, { "id": "step0", "type": "sendChatActivity", "properties": { "from": "#{session['chatFrom']}" }, "contents": [ { "type": "text/plain", "payload": { "text": "Envie um arquivo no formato jpeg, pdf, jpg ou png." } } ] }, { "id": "step02", "type": "chatEvent", "variables": { "variavel": "payload" } } ], "connections": [ { "from": "step04", "to": "idEventoFinal" }, { "from": "step05", "to": "idEventoFinal" }, { "from": "idEventoInicial", "to": "step0" }, { "from": "step0", "to": "step02" }, { "from": "step02", "to": "step03" }, { "conditions": [ { "type": "elCondition", "expression": "(fileUrl != null AND fileMimeType == 'image/jpeg') OR (fileUrl != null AND fileMimeType == 'application/pdf') OR (fileUrl != null AND fileMimeType == 'application/jpg') OR (fileUrl != null AND fileMimeType == 'application/png')" } ], "from": "step03", "to": "step04", "label": "Sim!" }, { "from": "step03", "to": "step05", "label": "Inválido", "isDefault": true } ], "defaultConversationalChannel": "CHAT" }
Validação do formato hora
Permite editar o formato da hora que o usuário digitou ou que retornou da API.
variavel_hora matches '([01]?[0-9]|2[0-3]):[0-5][0-9]'
Json de exemplo:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134{ "alias": "Exemplo Regex", "description": "", "steps": [ { "id": "step03", "type": "branch", "label": "Digitou certo?" }, { "id": "step05", "type": "sendChatActivity", "properties": { "from": "#{session['chatFrom']}" }, "contents": [ { "type": "text/plain", "payload": { "text": "Algo deu errado." } } ] }, { "id": "step04", "type": "sendChatActivity", "properties": { "from": "#{session['chatFrom']}" }, "contents": [ { "type": "text/plain", "payload": { "text": "Correto!" } } ] }, { "id": "idEventoFinal", "type": "endEvent", "label": "label 3", "properties": { "endEvent": "true" } }, { "id": "idEventoInicial", "type": "chatEvent", "label": "Evento inicial", "properties": { "startEvent": "true" }, "variables": { "chatFrom": "'INTEGRACAO_CANAL_AQUI_PUBLICAR'" }, "conditions": [ { "type": "channelSourceCondition", "values": [ "INTEGRACAO_CANAL_AQUI_PUBLICAR" ] } ] }, { "id": "step0", "type": "sendChatActivity", "properties": { "from": "#{session['chatFrom']}" }, "contents": [ { "type": "text/plain", "payload": { "text": "Digite a hora no formado HH:mm" } } ] }, { "id": "step02", "type": "chatEvent", "variables": { "variavel_hora": "payload" }, "properties": { "timeUnit": "minute", "expirationInMinutes": "" } } ], "connections": [ { "from": "step04", "to": "idEventoFinal" }, { "from": "step05", "to": "idEventoFinal" }, { "from": "idEventoInicial", "to": "step0" }, { "from": "step0", "to": "step02" }, { "from": "step02", "to": "step03" }, { "conditions": [ { "type": "elCondition", "expression": "variavel_hora matches '([01]?[0-9]|2[0-3]):[0-5][0-9]'" } ], "from": "step03", "to": "step04", "label": "Sim!" }, { "from": "step03", "to": "step05", "label": "Inválido", "isDefault": true } ], "defaultConversationalChannel": "CHAT" }
Validação do formato e-mail
Validar o formato do e-mail a partir do conteúdo, antes e após o arroba(@).
email_respondido matches '(?i)^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,6}$'
No exemplo acima, se o usuário digitar algo fora do padrão "email@email.com", será direcionado para o inválido.
Json de exemplo:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134{ "alias": "Exemplo Regex", "description": "", "steps": [ { "id": "step03", "type": "branch", "label": "Digitou certo?" }, { "id": "step05", "type": "sendChatActivity", "properties": { "from": "#{session['chatFrom']}" }, "contents": [ { "type": "text/plain", "payload": { "text": "Algo deu errado." } } ] }, { "id": "step04", "type": "sendChatActivity", "properties": { "from": "#{session['chatFrom']}" }, "contents": [ { "type": "text/plain", "payload": { "text": "Correto!" } } ] }, { "id": "idEventoFinal", "type": "endEvent", "label": "label 3", "properties": { "endEvent": "true" } }, { "id": "idEventoInicial", "type": "chatEvent", "label": "Evento inicial", "properties": { "startEvent": "true" }, "variables": { "chatFrom": "'INTEGRACAO_CANAL_AQUI_PUBLICAR'" }, "conditions": [ { "type": "channelSourceCondition", "values": [ "INTEGRACAO_CANAL_AQUI_PUBLICAR" ] } ] }, { "id": "step0", "type": "sendChatActivity", "properties": { "from": "#{session['chatFrom']}" }, "contents": [ { "type": "text/plain", "payload": { "text": "Validação do formato de e-mail." } } ] }, { "id": "step02", "type": "chatEvent", "properties": { "timeUnit": "minute", "expirationInMinutes": "" }, "variables": { "email_respondido": "payload" } } ], "connections": [ { "from": "step04", "to": "idEventoFinal" }, { "from": "step05", "to": "idEventoFinal" }, { "from": "idEventoInicial", "to": "step0" }, { "from": "step0", "to": "step02" }, { "from": "step02", "to": "step03" }, { "conditions": [ { "type": "elCondition", "expression": "'(?i)^[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,6}$'" } ], "from": "step03", "to": "step04", "label": "Sim!" }, { "from": "step03", "to": "step05", "label": "Inválido", "isDefault": true } ], "defaultConversationalChannel": "CHAT" }
REGEX que valida apenas números de 0 a 10
variavel matches ^(?:[0-9]|0[0-9]|10)$
Json de exemplo:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134{ "alias": "Exemplo Regex", "description": "", "steps": [ { "id": "step03", "type": "branch", "label": "Digitou certo?" }, { "id": "step05", "type": "sendChatActivity", "properties": { "from": "#{session['chatFrom']}" }, "contents": [ { "type": "text/plain", "payload": { "text": "Algo deu errado." } } ] }, { "id": "step04", "type": "sendChatActivity", "properties": { "from": "#{session['chatFrom']}" }, "contents": [ { "type": "text/plain", "payload": { "text": "Correto!" } } ] }, { "id": "idEventoFinal", "type": "endEvent", "label": "label 3", "properties": { "endEvent": "true" } }, { "id": "idEventoInicial", "type": "chatEvent", "label": "Evento inicial", "properties": { "startEvent": "true" }, "variables": { "chatFrom": "'INTEGRACAO_CANAL_AQUI_PUBLICAR'" }, "conditions": [ { "type": "channelSourceCondition", "values": [ "INTEGRACAO_CANAL_AQUI_PUBLICAR" ] } ] }, { "id": "step0", "type": "sendChatActivity", "properties": { "from": "#{session['chatFrom']}" }, "contents": [ { "type": "text/plain", "payload": { "text": "Digite apenas números de 0 a 10." } } ] }, { "id": "step02", "type": "chatEvent", "properties": { "timeUnit": "minute", "expirationInMinutes": "" }, "variables": { "variavel": "payload" } } ], "connections": [ { "from": "step04", "to": "idEventoFinal" }, { "from": "step05", "to": "idEventoFinal" }, { "from": "idEventoInicial", "to": "step0" }, { "from": "step0", "to": "step02" }, { "from": "step02", "to": "step03" }, { "conditions": [ { "type": "elCondition", "expression": "variavel matches ^(?:[0-9]|0[0-9]|10)$" } ], "from": "step03", "to": "step04", "label": "Sim!" }, { "from": "step03", "to": "step05", "label": "Inválido", "isDefault": true } ], "defaultConversationalChannel": "CHAT" }