Skip to content

Commit

Permalink
adding new feature for recording a greeting for language selection #1228
Browse files Browse the repository at this point in the history
  • Loading branch information
dgershman authored Nov 9, 2024
1 parent c04213b commit bd1f784
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 1 deletion.
3 changes: 3 additions & 0 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Release Notes

### 4.5.0 (UNRELEASED)
* Added new feature that allow for creating a custom prompt for language selection feature. [#1228]

### 4.4.1 (November 4, 2024)
* Added new feature that allows for tagging languages to volunteers prior to enabling language routing with `language_selections_tagging`. [#1178]
* Fix for editing groups, configuration and call handling. [#1194] [#1222]
Expand Down
10 changes: 10 additions & 0 deletions src/app/Http/Controllers/CallFlowController.php
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,16 @@ public function languageSelector(Request $request)
if (!$this->settings->has('language_selections')) {
$twiml->say("language gateway options are not set, please refer to the documentation to utilize this feature.");
$twiml->hangup();
} else if ($this->settings->has('language_selections_greeting')) {
$gather = $twiml->gather()
->setInput("dtmf")
->setNumDigits(1)
->setTimeout(60)
->setSpeechTimeout("auto")
->setAction("index.php")
->setMethod("GET");
$gather->pause()->setLength("2");
$gather->play($this->settings->get('language_selections_greeting'));
} else {
$language_selection_options = explode(",", $this->settings->get('language_selections'));
$twiml->pause()->setLength($this->settings->get('initial_pause'));
Expand Down
3 changes: 2 additions & 1 deletion src/app/Services/SettingsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

class SettingsService
{
private string $version = "4.4.1";
private string $version = "4.5.0";
private array $allowlist = [
'announce_servicebody_volunteer_routing' => ['description' => '/helpline/announce_servicebody_volunteer_routing' , 'default' => false, 'overridable' => true, 'hidden' => false],
'blocklist' => ['description' => '/general/blocklist' , 'default' => '', 'overridable' => true, 'hidden' => false],
Expand Down Expand Up @@ -46,6 +46,7 @@ class SettingsService
'jft_option' => ['description' => '/miscellaneous/playback-for-readings' , 'default' => false, 'overridable' => true, 'hidden' => false],
'language' => ['description' => '/general/language-options' , 'default' => 'en-US', 'overridable' => true, 'hidden' => false],
'language_selections' => ['description' => '/general/language-options', 'default' => null, 'overridable' => true, 'hidden' => false],
'language_selections_greeting' => ['description' => '/general/language-options', 'default' => null, 'overridable' => true, 'hidden' => false],
'language_selections_tagging' => ['description' => '/general/language-options', 'default' => null, 'overridable' => true, 'hidden' => false],
'location_lookup_bias' => ['description' => '/general/location-lookup-bias' , 'default' => 'country:us', 'overridable' => true, 'hidden' => false],
'meeting_result_sort' => ['description' => '/meeting-search/sorting-results' , 'default' => MeetingResultSort::TODAY, 'overridable' => true, 'hidden' => false],
Expand Down
6 changes: 6 additions & 0 deletions src/docs/docs/general/language-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ You can also tag volunteers ahead of time before enabling the option by using th
static $language_selections_tagging = "en-US,pig-latin";
```

It may also make sense if you want to indicate the name of the service body or helpline they are calling to record a new prompt. Keep in mind to indicate all the menu options for each language as there will be no automated menu once this setting is enabled.

```php
static $language_selections_greeting = "https://example.org/test.mp3";
```

### Mixing languages and voices

Voices can be configured for every language option. For example for Spanish:
Expand Down
20 changes: 20 additions & 0 deletions src/tests/Feature/LanguageSelectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,23 @@
'</Response>'
], false);
})->with(['GET', 'POST']);

test('language selector with languages set and custom prompts', function ($method) {
$settingsService = new SettingsService();
$settingsService->set("language_selections", "en-US,es-US");
$settingsService->set("language_selections_greeting", "https://example.org/languageSelectionsGreeting.mp3");
app()->instance(SettingsService::class, $settingsService);
$response = $this->call($method, '/lng-selector.php');
$response
->assertStatus(200)
->assertHeader("Content-Type", "text/xml; charset=utf-8")
->assertSeeInOrderExact([
'<?xml version="1.0" encoding="UTF-8"?>',
'<Response>',
'<Gather input="dtmf" numDigits="1" timeout="60" speechTimeout="auto" action="index.php" method="GET">',
'<Pause length="2"/>',
'<Play>https://example.org/languageSelectionsGreeting.mp3</Play>',
'</Gather>',
'</Response>'
], false);
})->with(['GET', 'POST']);

0 comments on commit bd1f784

Please sign in to comment.