feat: Add i18n on whatsapp list button (#10852)
Fixes #10862 --------- Co-authored-by: Pranav <pranav@chatwoot.com>
This commit is contained in:
committed by
GitHub
parent
0d05a07aa7
commit
d52f4267ba
@@ -100,7 +100,7 @@ class Whatsapp::Providers::BaseService
|
|||||||
rows = create_rows(message.content_attributes['items'])
|
rows = create_rows(message.content_attributes['items'])
|
||||||
section1 = { 'rows' => rows }
|
section1 = { 'rows' => rows }
|
||||||
sections = [section1]
|
sections = [section1]
|
||||||
json_hash = { :button => 'Choose an item', 'sections' => sections }
|
json_hash = { :button => I18n.t('conversations.messages.whatsapp.list_button_label'), 'sections' => sections }
|
||||||
create_payload('list', message.outgoing_content, JSON.generate(json_hash))
|
create_payload('list', message.outgoing_content, JSON.generate(json_hash))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -152,6 +152,8 @@ en:
|
|||||||
instagram_story_content: '%{story_sender} mentioned you in the story: '
|
instagram_story_content: '%{story_sender} mentioned you in the story: '
|
||||||
instagram_deleted_story_content: This story is no longer available.
|
instagram_deleted_story_content: This story is no longer available.
|
||||||
deleted: This message was deleted
|
deleted: This message was deleted
|
||||||
|
whatsapp:
|
||||||
|
list_button_label: 'Choose an item'
|
||||||
delivery_status:
|
delivery_status:
|
||||||
error_code: 'Error code: %{error_code}'
|
error_code: 'Error code: %{error_code}'
|
||||||
activity:
|
activity:
|
||||||
|
|||||||
@@ -138,6 +138,8 @@ pt_BR:
|
|||||||
instagram_story_content: '%{story_sender} mencionou você na conversa: '
|
instagram_story_content: '%{story_sender} mencionou você na conversa: '
|
||||||
instagram_deleted_story_content: Este Story não está mais disponível.
|
instagram_deleted_story_content: Este Story não está mais disponível.
|
||||||
deleted: Esta mensagem foi excluída
|
deleted: Esta mensagem foi excluída
|
||||||
|
whatsapp:
|
||||||
|
list_button_label: 'Escolha um item'
|
||||||
delivery_status:
|
delivery_status:
|
||||||
error_code: 'Código de erro: %{error_code}'
|
error_code: 'Código de erro: %{error_code}'
|
||||||
activity:
|
activity:
|
||||||
@@ -213,7 +215,7 @@ pt_BR:
|
|||||||
slack:
|
slack:
|
||||||
name: 'Slack'
|
name: 'Slack'
|
||||||
short_description: 'Receba notificações e responda as conversas diretamente no Slack.'
|
short_description: 'Receba notificações e responda as conversas diretamente no Slack.'
|
||||||
description: "Integre Chatwoot com Slack para manter seu time em sincronia. Essa integração permite que você receba notificações de novas conversas e as responda diretamente na interface do Slack."
|
description: 'Integre Chatwoot com Slack para manter seu time em sincronia. Essa integração permite que você receba notificações de novas conversas e as responda diretamente na interface do Slack.'
|
||||||
webhooks:
|
webhooks:
|
||||||
name: 'Webhooks'
|
name: 'Webhooks'
|
||||||
description: 'Eventos webhook fornecem atualizações sobre atividades em tempo real na sua conta Chatwoot. Você pode se inscrever em seus eventos preferidos, e o Chatwoot enviará as chamadas HTTP com as atualizações.'
|
description: 'Eventos webhook fornecem atualizações sobre atividades em tempo real na sua conta Chatwoot. Você pode se inscrever em seus eventos preferidos, e o Chatwoot enviará as chamadas HTTP com as atualizações.'
|
||||||
@@ -224,7 +226,7 @@ pt_BR:
|
|||||||
google_translate:
|
google_translate:
|
||||||
name: 'Tradutor do Google'
|
name: 'Tradutor do Google'
|
||||||
short_description: 'Traduzir automaticamente mensagens de clientes para agentes.'
|
short_description: 'Traduzir automaticamente mensagens de clientes para agentes.'
|
||||||
description: "Integre o Google Tradutor para ajudar os agentes a traduzir facilmente as mensagens dos clientes. Esta integração detecta automaticamente o idioma e o converte para o idioma preferido do agente ou do administrador."
|
description: 'Integre o Google Tradutor para ajudar os agentes a traduzir facilmente as mensagens dos clientes. Esta integração detecta automaticamente o idioma e o converte para o idioma preferido do agente ou do administrador.'
|
||||||
openai:
|
openai:
|
||||||
name: 'OpenAI'
|
name: 'OpenAI'
|
||||||
short_description: 'Sugestões, resumos e aprimoramento de mensagem e resposta com IA.'
|
short_description: 'Sugestões, resumos e aprimoramento de mensagem e resposta com IA.'
|
||||||
|
|||||||
@@ -51,16 +51,15 @@ describe Whatsapp::Providers::Whatsapp360DialogService do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it 'calls message endpoints with list payload when number of items is greater than 3' do
|
it 'calls message endpoints with list payload when number of items is greater than 3' do
|
||||||
|
items = %w[Burito Pasta Sushi Salad].map { |i| { title: i, value: i } }
|
||||||
message = create(:message, message_type: :outgoing, content: 'test', inbox: whatsapp_channel.inbox,
|
message = create(:message, message_type: :outgoing, content: 'test', inbox: whatsapp_channel.inbox,
|
||||||
content_type: 'input_select',
|
content_type: 'input_select', content_attributes: { items: items })
|
||||||
content_attributes: {
|
|
||||||
items: [
|
expected_action = {
|
||||||
{ title: 'Burito', value: 'Burito' },
|
button: I18n.t('conversations.messages.whatsapp.list_button_label'),
|
||||||
{ title: 'Pasta', value: 'Pasta' },
|
sections: [{ rows: %w[Burito Pasta Sushi Salad].map { |i| { id: i, title: i } } }]
|
||||||
{ title: 'Sushi', value: 'Sushi' },
|
}.to_json
|
||||||
{ title: 'Salad', value: 'Salad' }
|
|
||||||
]
|
|
||||||
})
|
|
||||||
stub_request(:post, 'https://waba.360dialog.io/v1/messages')
|
stub_request(:post, 'https://waba.360dialog.io/v1/messages')
|
||||||
.with(
|
.with(
|
||||||
body: {
|
body: {
|
||||||
@@ -70,9 +69,9 @@ describe Whatsapp::Providers::Whatsapp360DialogService do
|
|||||||
body: {
|
body: {
|
||||||
text: 'test'
|
text: 'test'
|
||||||
},
|
},
|
||||||
action: '{"button":"Choose an item","sections":[{"rows":[{"id":"Burito","title":"Burito"},' \
|
action: expected_action
|
||||||
'{"id":"Pasta","title":"Pasta"},{"id":"Sushi","title":"Sushi"},{"id":"Salad","title":"Salad"}]}]}'
|
},
|
||||||
}, type: 'interactive'
|
type: 'interactive'
|
||||||
}.to_json
|
}.to_json
|
||||||
).to_return(status: 200, body: whatsapp_response.to_json, headers: response_headers)
|
).to_return(status: 200, body: whatsapp_response.to_json, headers: response_headers)
|
||||||
expect(service.send_message('+123456789', message)).to eq 'message_id'
|
expect(service.send_message('+123456789', message)).to eq 'message_id'
|
||||||
|
|||||||
@@ -124,16 +124,15 @@ describe Whatsapp::Providers::WhatsappCloudService do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it 'calls message endpoints with list payload when number of items is greater than 3' do
|
it 'calls message endpoints with list payload when number of items is greater than 3' do
|
||||||
|
items = %w[Burito Pasta Sushi Salad].map { |i| { title: i, value: i } }
|
||||||
message = create(:message, message_type: :outgoing, content: 'test', inbox: whatsapp_channel.inbox,
|
message = create(:message, message_type: :outgoing, content: 'test', inbox: whatsapp_channel.inbox,
|
||||||
content_type: 'input_select',
|
content_type: 'input_select', content_attributes: { items: items })
|
||||||
content_attributes: {
|
|
||||||
items: [
|
expected_action = {
|
||||||
{ title: 'Burito', value: 'Burito' },
|
button: I18n.t('conversations.messages.whatsapp.list_button_label'),
|
||||||
{ title: 'Pasta', value: 'Pasta' },
|
sections: [{ rows: %w[Burito Pasta Sushi Salad].map { |i| { id: i, title: i } } }]
|
||||||
{ title: 'Sushi', value: 'Sushi' },
|
}.to_json
|
||||||
{ title: 'Salad', value: 'Salad' }
|
|
||||||
]
|
|
||||||
})
|
|
||||||
stub_request(:post, 'https://graph.facebook.com/v13.0/123456789/messages')
|
stub_request(:post, 'https://graph.facebook.com/v13.0/123456789/messages')
|
||||||
.with(
|
.with(
|
||||||
body: {
|
body: {
|
||||||
@@ -143,9 +142,9 @@ describe Whatsapp::Providers::WhatsappCloudService do
|
|||||||
body: {
|
body: {
|
||||||
text: 'test'
|
text: 'test'
|
||||||
},
|
},
|
||||||
action: '{"button":"Choose an item","sections":[{"rows":[{"id":"Burito","title":"Burito"},' \
|
action: expected_action
|
||||||
'{"id":"Pasta","title":"Pasta"},{"id":"Sushi","title":"Sushi"},{"id":"Salad","title":"Salad"}]}]}'
|
},
|
||||||
}, type: 'interactive'
|
type: 'interactive'
|
||||||
}.to_json
|
}.to_json
|
||||||
).to_return(status: 200, body: whatsapp_response.to_json, headers: response_headers)
|
).to_return(status: 200, body: whatsapp_response.to_json, headers: response_headers)
|
||||||
expect(service.send_message('+123456789', message)).to eq 'message_id'
|
expect(service.send_message('+123456789', message)).to eq 'message_id'
|
||||||
|
|||||||
Reference in New Issue
Block a user