Dify - Gatilho é acionado e ativa assistente mas perde primeira resposta e corta parte das seguintes
Bem-vido!
- [X] Sim, pesquisei problemas semelhantes no GitHub e não encontrei nenhum.
O que você fez?
Criei um agente no Dify, configurei corretamente com o gatilho palavra chave (testei vários operadores), ao receber a mensagem de gatilho a evolution consegue acionar o dify, que retorna a primeira mensagem, no entanto a evo apresenta erro ao tratar essa mensagem. Ao continuar a conversa a evolution passa a entregar as mensagens no entanto corta parte do início delas.
O que você esperava?
Que a evolution recebesse a primeira mensagem do bot e a entregasse com sucesso.
O que vc observou ao invés do que esperava?
Ao receber a primeira mensagem a evolution apresenta o seguinte erro:
Error parsing stream data: SyntaxError: Unexpected token 'd', "data: {"ev"... is not valid JSON
at JSON.parse (
As demais mensagens são entregues com sucesso, mas com um corte nas primeiras letras da mensagem.
Erro:
Error parsing stream data: SyntaxError: Unterminated string in JSON at position 256
at JSON.parse (
Capturas de Tela/Vídeos
Segue vídeo demonstrando a falha:
https://youtu.be/ZA6nEpScTB8
Qual versão da API você está usando?
2.10
Qual é o seu ambiente?
Docker
Outras expecificações do ambiente
portainer 2.20.1 traefik 2 docker swam 27.0.3
Se aplicável, cole a saída do log
Deploying migrations for postgresql Database URL:
[email protected] db:deploy node runWithProvider.js "rm -rf ./prisma/migrations && cp -r ./prisma/DATABASE_PROVIDER-migrations ./prisma/migrations && npx prisma migrate deploy --schema ./prisma/DATABASE_PROVIDER-schema.prisma" Environment variables loaded from .env Prisma schema loaded from prisma/postgresql-schema.prisma Datasource "db": PostgreSQL database "evolution210", schema "public" at "postgres:5432" 31 migrations found in prisma/migrations No pending migrations to apply. Migration succeeded [email protected] db:generate node runWithProvider.js "npx prisma generate --schema ./prisma/DATABASE_PROVIDER-schema.prisma" Environment variables loaded from .env Prisma schema loaded from prisma/postgresql-schema.prisma ✔ Generated Prisma Client (v5.18.0) to ./node_modules/@prisma/client in 939ms Start by importing your Prisma Client (See: http://pris.ly/d/importing-client) Tip: Want to react to database changes in your app as they happen? Discover how with Pulse: https://pris.ly/tip-1-pulse Prisma generate succeeded [email protected] start:prod node dist/main [Evolution API] v2.0.10 156 - Sat Aug 17 2024 19:36:42 VERBOSE [Prisma] [string] connecting [Evolution API] v2.0.10 156 - Sat Aug 17 2024 19:36:43 INFO [Redis] [string] RedisCache initialized for groups [Evolution API] v2.0.10 156 - Sat Aug 17 2024 19:36:43 INFO [CacheService] [string] cacheservice created using cache engine: $t [Evolution API] v2.0.10 156 - Sat Aug 17 2024 19:36:43 INFO [Redis] [string] RedisCache initialized for he [Evolution API] v2.0.10 156 - Sat Aug 17 2024 19:36:43 INFO [CacheService] [string] cacheservice created using cache engine: $t [Evolution API] v2.0.10 156 - Sat Aug 17 2024 19:36:43 INFO [Redis] [string] RedisCache initialized for instance [Evolution API] v2.0.10 156 - Sat Aug 17 2024 19:36:43 INFO [CacheService] [string] cacheservice created using cache engine: $t [Evolution API] v2.0.10 156 - Sat Aug 17 2024 19:36:43 INFO [Redis] [string] RedisCache initialized for baileys [Evolution API] v2.0.10 156 - Sat Aug 17 2024 19:36:43 INFO [CacheService] [string] cacheservice created using cache engine: $t [Evolution API] v2.0.10 156 - Sat Aug 17 2024 19:36:43 INFO [WA MODULE] [string] Module - ON [Evolution API] v2.0.10 156 - Sat Aug 17 2024 19:36:43 VERBOSE [Redis] [string] redis connecting [Evolution API] v2.0.10 156 - Sat Aug 17 2024 19:36:43 VERBOSE [Redis] [string] redis ready [Evolution API] v2.0.10 156 - Sat Aug 17 2024 19:36:43 INFO [PrismaRepository] [string] Repository:Prisma - ON [Evolution API] v2.0.10 156 - Sat Aug 17 2024 19:36:43 LOG [SERVER] [string] HTTP - ON: 8080 [Evolution API] v2.0.10 156 - Sat Aug 17 2024 19:36:43 INFO [AMQP] [string] AMQP initialized [Evolution API] [Michele] v2.0.10 156 - Sat Aug 17 2024 19:36:43 INFO [ChannelStartupService] [string] Browser: evolution210.oneleads,Chrome,6.8.0-40-generic [Evolution API] [Michele] v2.0.10 156 - Sat Aug 17 2024 19:36:44 INFO [ChannelStartupService] [string] Baileys version: 2,2413,1 [Evolution API] [Michele] v2.0.10 156 - Sat Aug 17 2024 19:36:44 INFO [ChannelStartupService] [string] Group Ignore: true [Evolution API] [Michele] v2.0.10 156 - Sat Aug 17 2024 19:36:44 INFO [ChannelStartupService] [string]
┌──────────────────────────────┐ │ CONNECTED TO WHATSAPP │ └──────────────────────────────┘ [Evolution API] [Michele] v2.0.10 156 - Sat Aug 17 2024 19:36:44 INFO [ChannelStartupService] [string]
wuid: 553192089999
name: Michele
[Evolution API] [Michele] v2.0.10 156 - Sat Aug 17 2024 19:36:58 LOG [ChannelStartupService] [object]
{
key: {
remoteJid: '[email protected]',
fromMe: false,
id: '3EB0D98489D96A1677AAD5',
participant: undefined
},
pushName: 'Rogério',
message: {
conversation: 'Oi',
messageContextInfo: MessageContextInfo {
deviceListMetadata: [DeviceListMetadata],
deviceListMetadataVersion: 2
}
},
contextInfo: undefined,
messageType: 'conversation',
messageTimestamp: 1723934217,
instanceId: '0f339b78-8c96-48b3-b861-fa4653e57ba0',
source: 'web',
chatwootMessageId: 19558,
chatwootInboxId: 17,
chatwootConversationId: 2112
}
[Evolution API] v2.0.10 156 - Sat Aug 17 2024 19:36:58 INFO [Redis] [string] RedisCache initialized for he
[Evolution API] v2.0.10 156 - Sat Aug 17 2024 19:36:58 INFO [CacheService] [string] cacheservice created using cache engine: $t
[Evolution API] v2.0.10 156 - Sat Aug 17 2024 19:36:58 INFO [Redis] [string] RedisCache initialized for he
[Evolution API] v2.0.10 156 - Sat Aug 17 2024 19:36:58 INFO [CacheService] [string] cacheservice created using cache engine: $t
[Evolution API] [Michele] v2.0.10 156 - Sat Aug 17 2024 19:37:59 LOG [ChannelStartupService] [object]
{
key: {
remoteJid: '[email protected]',
fromMe: false,
id: '3EB02139F32B57E611F588',
participant: undefined
},
pushName: 'Rogério',
message: {
conversation: 'Oi',
messageContextInfo: MessageContextInfo {
deviceListMetadata: [DeviceListMetadata],
deviceListMetadataVersion: 2
}
},
contextInfo: undefined,
messageType: 'conversation',
messageTimestamp: 1723934278,
instanceId: '0f339b78-8c96-48b3-b861-fa4653e57ba0',
source: 'web',
chatwootMessageId: 19559,
chatwootInboxId: 17,
chatwootConversationId: 2112
}
[Evolution API] v2.0.10 156 - Sat Aug 17 2024 19:37:59 INFO [Redis] [string] RedisCache initialized for he
[Evolution API] v2.0.10 156 - Sat Aug 17 2024 19:37:59 INFO [CacheService] [string] cacheservice created using cache engine: $t
[Evolution API] [Michele] v2.0.10 156 - Sat Aug 17 2024 19:38:20 LOG [ChannelStartupService] [object]
{
key: {
remoteJid: '[email protected]',
fromMe: false,
id: '3EB0C9F3D46639EE07BF74',
participant: undefined
},
pushName: 'Rogério',
message: {
conversation: 'Haven',
messageContextInfo: MessageContextInfo {
deviceListMetadata: [DeviceListMetadata],
deviceListMetadataVersion: 2
}
},
contextInfo: undefined,
messageType: 'conversation',
messageTimestamp: 1723934300,
instanceId: '0f339b78-8c96-48b3-b861-fa4653e57ba0',
source: 'web',
chatwootMessageId: 19560,
chatwootInboxId: 17,
chatwootConversationId: 2112
}
[Evolution API] v2.0.10 156 - Sat Aug 17 2024 19:38:20 INFO [Redis] [string] RedisCache initialized for he
[Evolution API] v2.0.10 156 - Sat Aug 17 2024 19:38:20 INFO [CacheService] [string] cacheservice created using cache engine: $t
Error parsing stream data: SyntaxError: Unexpected token 'd', "data: {"ev"... is not valid JSON
at JSON.parse (
{
origin: Promise {
stderr: 2,
error: TypeError: Cannot read properties of undefined (reading 'length')
at Readable.
{
key: {
remoteJid: '[email protected]',
fromMe: false,
id: '3EB0AAB4E665B8AD407561',
participant: undefined
},
pushName: 'Rogério',
message: {
conversation: 'Boa noite!',
messageContextInfo: MessageContextInfo {
deviceListMetadata: [DeviceListMetadata],
deviceListMetadataVersion: 2
}
},
contextInfo: undefined,
messageType: 'conversation',
messageTimestamp: 1723934344,
instanceId: '0f339b78-8c96-48b3-b861-fa4653e57ba0',
source: 'web',
chatwootMessageId: 19561,
chatwootInboxId: 17,
chatwootConversationId: 2112
}
[Evolution API] v2.0.10 156 - Sat Aug 17 2024 19:39:04 WARN [TypebotService] [string] Session is already opened in another integration
[Evolution API] v2.0.10 156 - Sat Aug 17 2024 19:39:05 INFO [Redis] [string] RedisCache initialized for he
[Evolution API] v2.0.10 156 - Sat Aug 17 2024 19:39:05 INFO [CacheService] [string] cacheservice created using cache engine: $t
Error parsing stream data: SyntaxError: Unterminated string in JSON at position 246
at JSON.parse (
{
key: MessageKey {
remoteJid: '[email protected]',
fromMe: true,
id: '3EB03961FCF1E84196B0C762C4F5FB5F44A695B9'
},
pushName: '',
message: {
extendedTextMessage: ExtendedTextMessage {
text: ' noite! Eu sou a Cloe, atendente da Lancheria Haven. Como posso ajudar você hoje? Qual é o seu nome?'
}
},
contextInfo: null,
messageType: 'extendedTextMessage',
messageTimestamp: 1723934346,
instanceId: '0f339b78-8c96-48b3-b861-fa4653e57ba0',
source: 'unknown'
}
[Evolution API] v2.0.10 156 - Sat Aug 17 2024 19:39:07 INFO [Redis] [string] RedisCache initialized for he
[Evolution API] v2.0.10 156 - Sat Aug 17 2024 19:39:07 INFO [CacheService] [string] cacheservice created using cache engine: $t
[Evolution API] v2.0.10 156 - Sat Aug 17 2024 19:39:07 INFO [Redis] [string] RedisCache initialized for he
[Evolution API] v2.0.10 156 - Sat Aug 17 2024 19:39:07 INFO [CacheService] [string] cacheservice created using cache engine: $t
[Evolution API] [Michele] v2.0.10 156 - Sat Aug 17 2024 19:40:01 LOG [ChannelStartupService] [object]
{
key: {
remoteJid: '[email protected]',
fromMe: false,
id: '3EB050D2067EC68BB9A729',
participant: undefined
},
pushName: 'Rogério',
message: {
conversation: 'Ii',
messageContextInfo: MessageContextInfo {
deviceListMetadata: [DeviceListMetadata],
deviceListMetadataVersion: 2
}
},
contextInfo: undefined,
messageType: 'conversation',
messageTimestamp: 1723934401,
instanceId: '0f339b78-8c96-48b3-b861-fa4653e57ba0',
source: 'web',
chatwootMessageId: 19563,
chatwootInboxId: 17,
chatwootConversationId: 2112
}
[Evolution API] v2.0.10 156 - Sat Aug 17 2024 19:40:01 WARN [TypebotService] [string] Session is already opened in another integration
[Evolution API] v2.0.10 156 - Sat Aug 17 2024 19:40:01 INFO [Redis] [string] RedisCache initialized for he
[Evolution API] v2.0.10 156 - Sat Aug 17 2024 19:40:01 INFO [CacheService] [string] cacheservice created using cache engine: $t
[Evolution API] v2.0.10 156 - Sat Aug 17 2024 19:40:01 INFO [Redis] [string] RedisCache initialized for he
[Evolution API] v2.0.10 156 - Sat Aug 17 2024 19:40:01 INFO [CacheService] [string] cacheservice created using cache engine: $t
Error parsing stream data: SyntaxError: Unterminated string in JSON at position 250
at JSON.parse (
{
key: MessageKey {
remoteJid: '[email protected]',
fromMe: true,
id: '3EB0098196B6FC595122A5DD0DF48A5C20A9EA4E'
},
pushName: '',
message: {
extendedTextMessage: ExtendedTextMessage {
text: 'zer em conhecer você, Ii! Como posso ajudar você hoje Está em busca de algo específico ou gostaria de explorar nosso cardápio?'
}
},
contextInfo: null,
messageType: 'extendedTextMessage',
messageTimestamp: 1723934403,
instanceId: '0f339b78-8c96-48b3-b861-fa4653e57ba0',
source: 'unknown'
}
[Evolution API] v2.0.10 156 - Sat Aug 17 2024 19:40:03 INFO [Redis] [string] RedisCache initialized for he
[Evolution API] v2.0.10 156 - Sat Aug 17 2024 19:40:03 INFO [CacheService] [string] cacheservice created using cache engine: $t
[Evolution API] v2.0.10 156 - Sat Aug 17 2024 19:40:03 INFO [Redis] [string] RedisCache initialized for he
[Evolution API] v2.0.10 156 - Sat Aug 17 2024 19:40:03 INFO [CacheService] [string] cacheservice created using cache engine: $t
[Evolution API] [Michele] v2.0.10 156 - Sat Aug 17 2024 19:40:13 LOG [ChannelStartupService] [object]
{
key: {
remoteJid: '[email protected]',
fromMe: false,
id: '3EB0A51629B308F30B1B35',
participant: undefined
},
pushName: 'Rogério',
message: {
conversation: 'Quero uma coca cola',
messageContextInfo: MessageContextInfo {
deviceListMetadata: [DeviceListMetadata],
deviceListMetadataVersion: 2
}
},
contextInfo: undefined,
messageType: 'conversation',
messageTimestamp: 1723934413,
instanceId: '0f339b78-8c96-48b3-b861-fa4653e57ba0',
source: 'web',
chatwootMessageId: 19565,
chatwootInboxId: 17,
chatwootConversationId: 2112
}
[Evolution API] v2.0.10 156 - Sat Aug 17 2024 19:40:13 WARN [TypebotService] [string] Session is already opened in another integration
[Evolution API] v2.0.10 156 - Sat Aug 17 2024 19:40:14 INFO [Redis] [string] RedisCache initialized for he
[Evolution API] v2.0.10 156 - Sat Aug 17 2024 19:40:14 INFO [CacheService] [string] cacheservice created using cache engine: $t
[Evolution API] v2.0.10 156 - Sat Aug 17 2024 19:40:14 INFO [Redis] [string] RedisCache initialized for he
[Evolution API] v2.0.10 156 - Sat Aug 17 2024 19:40:14 INFO [CacheService] [string] cacheservice created using cache engine: $t
Error parsing stream data: SyntaxError: Unterminated string in JSON at position 256
at JSON.parse (
{
key: MessageKey {
remoteJid: '[email protected]',
fromMe: true,
id: '3EB033E5FB9F379CFA3924E283B7C3DC211D4486'
},
pushName: '',
message: {
extendedTextMessage: ExtendedTextMessage {
text: 'tima escolha, Ii! Quantas Coca Colas você gostaria de pedir?'
}
},
contextInfo: null,
messageType: 'extendedTextMessage',
messageTimestamp: 1723934416,
instanceId: '0f339b78-8c96-48b3-b861-fa4653e57ba0',
source: 'unknown'
}
[Evolution API] v2.0.10 156 - Sat Aug 17 2024 19:40:16 INFO [Redis] [string] RedisCache initialized for he
[Evolution API] v2.0.10 156 - Sat Aug 17 2024 19:40:16 INFO [CacheService] [string] cacheservice created using cache engine: $t
[Evolution API] v2.0.10 156 - Sat Aug 17 2024 19:40:16 INFO [Redis] [string] RedisCache initialized for he
[Evolution API] v2.0.10 156 - Sat Aug 17 2024 19:40:16 INFO [CacheService] [string] cacheservice created using cache engine: $t
Notas Adicionais
No response
Comigo tem ocorrido o mesmo também.
mesma coisa aqui tb
mesma coisa aqui.
Estou tentando entender o motivo do erro? como esta configurado o seu fluxo no dify? se puder mandar o fluxo tambem, para poder simular a situação
Mesmo erro por aqui, mas em meu caso não tenho um fluxo no Dify, criei um agente e configurei a url na evo, a primeira mensagem se perde, tenho que enviar outra para ele iniciar o chat. Quando mando a primeira mensagem ele aparece digitando, mas não vem nada. Contudo, se mando novamente um oi a conversa se inicia normalmente.
ACredito que este bug é o mesmo que aconteceu na demo do Astra: https://youtu.be/bbqHRwMpsMk?si=G4b-D18xqiZX_mGX&t=1968
Tem acontecido o mesmo comigo e com a mesma mensagem de log.
Exatamente o erro que o astra apresenta no vídeo. O fluxo não tem nada demais. Só o prompt e retorno. Pelo que o pessoal do grupo disse, parece que se configurar como chatbot funciona e não apresenta erro, vou testar e retorno.
Única diferença do meu pro do astra é que o meu estou usando o cloud da propria dify.
mesma coisa aui no dify, o erro vem quando integrado no whats, o agente no dify funciona normal, pelo que entendi tem algo a ver com o agente retornar "answer" fragmentado, perde o primeiro pedaço e o agente retorna o texto como "thought"