zammad / zammad

Zammad is a web based open source helpdesk/customer support system

Home Page:https://zammad.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to send WhatsApp automatic reminders after 23 hours

rvdv01 opened this issue · comments

2024-04-22 09_51_07-Van der Meulen Support - #912492 - Rowdy (+31628371737) via WhatApp - Vivaldi

Used Zammad Version

6.3

Environment

  • Installation method: [e.g. source, package]
    Package
  • Operating system (if you're unsure: cat /etc/os-release ): [e.g. debian 10.4, ubuntu 20.04]
    Debian 12
  • Database + version: [e.g. postgresql 9.3, mysql 5.7, mariadb 10.3]
    PostgreSQL

Actual behaviour

In WhatsApp conversations, after not communicating for 23 hours, Zammad should send a reminder to the customer.
Zammad tries to send this, but apparantly the body text is empty. Perhaps it has something to do with translations or something.
In the ticket itself you get this error message:

Aflevering mislukt: "Unable to send whatsapp message: Can't use Channel::Driver::Whatsapp: #<Whatsapp::Client::CloudAPIError: (#100) The parameter text['body'] is required.>"

(Aflevering mislukt means Delivery failed)

It seems it is trying to send a message without a body or with an empty body.

Expected behaviour

A reminder is sent

Steps to reproduce the behaviour

Inititiate a WhatsApp-conversation, wait 23 hours for Zammad to send to automatic reminder

Support Ticket

No response

I'm sure this is a bug and no feature request or a general question.

yes

Hi @rvdv01. Could you please check via the Rails Console the body of the article that could not be sent?

zammad run rails console to enter the console and then Ticket::Article.where(ticket_id: X).pluck(:body) might be interesting.

Thank you for your quick reply.

[11] pry(main)> Ticket::Article.where(ticket_id: 2492).pluck(:body)
=> ["",
 "Unable to send whatsapp message: Can't use Channel::Driver::Whatsapp: #<Whatsapp::Client::CloudAPIError: (#100) The parameter text['body'] is required.>",
 "Hoi",
 "Bedankt voor je berichtje! We komen er zo snel mogelijk bij je op terug!",
 "Wat een gek probleem zeg!",
 "Echt wel",
 "raar"

This seems correct, the first (bottom) messages are the messages that have been sent back and forth. This is only a test conversation, nothing confidential is in it.

If you look at the screen shot, you see Zammd tries to send "" to my phone number after 23 hours. Perhaps there should be a message there, but it hasn't been translated properly? Or the message is missing in English as well? I couldn't find where this message is set up. It seems this message is not user customisable (yet). The 'welcome message' is and can be set up in the WA-channel config. That message is sent properly.

The customer sent 'hoi' as the very first message and the auto-response from Zammad was 'Bedankt voor je berichtje! We komen er zo snel mogelijk bij je op terug!' (this means: thanks for your message, we'll get back to you asap).
Then, the agent said 'wat een gek probleem zeg!' and the customer said 'echt wel' followed by 'raar' from the agent.
Then, the 23-hour message is at the top of the output.
I unblurred the messages in the screen shot:
2024-04-22 09_51_07-Van der Meulen Support - #912492 - Rowdy (+31628371737) via WhatApp - Vivaldi-2

The most interesting part is the article with an empty body (you see "" in the previous command). Could you please re-do the command but change it to Ticket::Article.where(ticket_id: X).pluck(:id, :body)? The id for the empty body is needed. Please post the output of Ticket::Article.find(X) for us.

[12] pry(main)> Ticket::Article.where(ticket_id: 2492).pluck(:id, :body)
=> [[4794, ""],
 [4795, "Unable to send whatsapp message: Can't use Channel::Driver::Whatsapp: #<Whatsapp::Client::CloudAPIError: (#100) The parameter text['body'] is required.>"],
 [4662, "Hoi"],
 [4663, "Bedankt voor je berichtje! We komen er zo snel mogelijk bij je op terug!"],
 [4664, "Wat een gek probleem zeg!"],
 [4675, "Echt wel"],
 [4679, "raar"]]
[13] pry(main)> Ticket::Article.find(4794)
=> #<Ticket::Article:0x00007fd00d50dea0
 id: 4794,
 ticket_id: 2492,
 type_id: 14,
 sender_id: 3,
 from: "Van  (+3)",
 to: "Ro (+3)",
 cc: nil,
 subject: "",
 reply_to: nil,
 message_id: nil,
 message_id_md5: nil,
 in_reply_to: nil,
 content_type: "text/plain",
 references: nil,
 body: "",
 internal: false,
 preferences:
  {"delivery_retry"=>1,
   "delivery_status"=>"fail",
   "delivery_status_date"=>Fri, 19 Apr 2024 11:35:07.103093281 UTC +00:00,
   "delivery_status_message"=>"Can't use Channel::Driver::Whatsapp: #<Whatsapp::Client::CloudAPIError: (#100) The parameter text['body'] is required.>"},
 updated_by_id: 1,
 created_by_id: 1,
 origin_by_id: nil,
 created_at: Fri, 19 Apr 2024 11:35:06.710000000 UTC +00:00,
 updated_at: Fri, 19 Apr 2024 11:35:07.105000000 UTC +00:00>

Very interesting! Could you please do the following? User.find(Ticket.find(2492).customer_id).preferences[:locale] || Locale.default

Of course I can :-)

[15] pry(main)> User.find(Ticket.find(2492).customer_id).preferences[:locale] || Locale.default
=> "nl-nl"

Thanks. Next command :D

Translation.translate('nl-nl', 'Hello, the customer service window for this conversation is about to expire, please reply to keep it open.')

[17] pry(main)> Translation.translate('nl-nl', 'Hello, the customer service window for this conversation is about to expire, please reply to keep it open.')
=> ""

Could you please do Locale.sync as well as Translation.sync?

locale.sync returned 'true'.
translation.sync took a few minutes and then returned this:

#<Locale:0x00007f5b3f1c9ed0 id: 22, locale: "nl-nl", alias: "nl", name: "Nederlands", dir: "ltr", active: true, created_at: Fri, 08 Dec 2023 09:21:55.712000000 UTC +00:00, updated_at: Fri, 08 Dec 2023 09:21:55.712000000 UTC +00:00>,

This is fine. Could you please re-execute Translation.translate('nl-nl', 'Hello, the customer service window for this conversation is about to expire, please reply to keep it open.')?

Unfortunately the same :-(

[1] pry(main)> Translation.translate('nl-nl', 'Hello, the customer service window for this conversation is about to expire, please reply to keep it open.')
=> ""
[2] pry(main)>

Hmmm. What about Translation.where(source: 'Hello, the customer service window for this conversation is about to expire, please reply to keep it open.').pluck(:locale, :target)?

=> [["en-us", "Hello, the customer service window for this conversation is about to expire, please reply to keep it open."],
["bg", ""],
["cs", ""],
["da", ""],
["el", ""],
["et", ""],
["en-ca", "Hello, the customer service window for this conversation is about to expire, please reply to keep it open."],
["en-gb", "Hello, the customer service window for this conversation is about to expire, please reply to keep it open."],
["es-es", "Hola, la ventana de servicio al cliente de esta conversación está a punto de expirar. Por favor, responder para mantenerla abierta."],
["es-co", ""],
["es-mx", ""],
["fi", ""],
["fr-fr", "Bonjour, la fenêtre du service client pour cette conversation est sur le point d'expirer, veuillez répondre pour la garder ouverte."],
["fr-ca", ""],
["hr", "Pozdrav, rok za korisničku podršku ovog razgovora će isteći, odgovorite kako bi ostao otvoren."],
["hu", ""],
["it-it", ""],
["ja", ""],
["lt", ""],
["lv", ""],
["no-no", ""],
["nl-nl", ""],
["pl", "Witam, okno obsługi klienta dla tej rozmowy wkrótce wygaśnie, prosimy o odpowiedź, aby pozostało otwarte."],
["pt-pt", ""],
["pt-br", "Olá, a janela de atendimento ao cliente para esta conversa está prestes a expirar, por favor, responda para mantê-la aberta."],
["ru", ""],
["sk", ""],
["sl", ""],
["sv-se", "Hej, Denna konversation är på väg att stängas, ange ett svar för att behålla det öppet."],
["tr", ""],
["uk", ""],
["vi", ""],
["zh-cn", ""],
["hi-in", ""],
["de-de", "Hallo, das Kundenservice-Zeitfenster für diese Konversation läuft bald ab. Bitte antworten Sie, um die Konversation offen zu halten."],
["he-il", ""],
["fa-ir", ""],
["ms-my", ""],
["ro-ro", ""],
["ar", ""],
["sr-cyrl-rs", "Поздрав, време за разговор ускоро истиче, молимо одговорите да бисте га продужили."],
["sr-latn-rs", "Pozdrav, vreme za razgovor uskoro ističe, molimo odgovorite da biste ga produžili."],
["is", ""],
["rw", ""],
["ko-kr", ""],

I added the correct translation to Weblate and performed another sync in Zammad.
But that doesn't fix it :-)
It still comes back empty. I'm probably skipping (a few) step(s) here now. But I thought, perhaps it resolves it for me for now.
But if there's no translation available, it should still default to the English text I suppose so a fix for that must still be made, I suppose.

You're totally right. There is an issue in the codebase, we're trying to address this right now.

Hi @rvdv01. Fix is on the way, for stable we still need 1-2 hours.

Hi @rvdv01. The new package for Debian 12 should be available. Feel free to update and test again.

Okay, Vielen Dank @fliebe92 .
I will update this evening and test it again!

I had to wait 23 hours obviously, but it seems to work fine now!

I got the English message now. I did translate it into Dutch in Weblate, but I guess it will take a few more updates until the strings from Weblate get pushed to Zammad installs.

@fliebe92
I did notice one other thing though (or actually two).
In the overviews, the field 'updated by' is empty:

image

And 2)
When is a new ticket created?
Even if I let the service window expire, when I send a new message from WhatsApp, it is added to the same existing ticket. It seems Zammad never creates a new ticket for anything.

Do you want me to create seperate reports for these two 'issues' or....?

Can you please keep issue topics clean? It helps much more with their overview (especially if you post potential new issues on a closed issue).

No 2 smells like a technical question.

Hi @rvdv01. Could you please create two separate posts in our community for the points you've discovered? Sounds like technical questions to me. If needed, we can file issue reports later.

Feel free to ping me in the community posts then, otherwise I will maybe miss it. :D