Logo
Logo
CTRLK

共有コンポーネント

複数の CML アクションをパッケージ化する

コールバック Webhook によって提供される CML アクションは、アクション オブジェクトに 1 つのアクションが含まれているか複数のアクションが含まれているかに関係なく、アクション オブジェクトに含める必要があります。actions オブジェクトは、CML 命令の JSON 配列です。

次の CML アクション例では、テキスト読み上げコンテンツを再生し、音声ファイルを再生してから、通話を切断します。

json
1{
2 "actions": [
3 {
4 "action": "say",
5 "text": "Hello! This is Smile Dental calling to remind you of your appointment tomorrow at 10 AM.",
6 "language": "en",
7 "voicePreferences": { "voiceGender": "FEMALE", "voiceName": "Joanna" }
8 },
9 {
10 "action": "play",
11 "content": {
12 "type": "URL",
13 "fileUrl": "https://example.com/content/generic.mp3"
14 }
15 },
16 { "action": "hangup" }
17 ]
18}

実行フローと制御転送

CML アクションは順番に実行されますが、一部のアクション (fetchcaptureDtmfdial) は、新しい CML アクションのセットに制御を転送できます。これにより、初期セットで定義された後続のアクションはスキップされます。

次の例では、2 番目の say アクションは、fetch アクションが新しいアクション セットに制御を移すため、実行されません。

json
1{
2 "actions": [
3 {
4 "action": "say",
5 "text": "Hello! This is Smile Dental calling to remind you of your appointment tomorrow at 10 AM.",
6 "language": "en",
7 "voicePreferences": {
8 "voiceGender": "FEMALE",
9 "voiceName": "Joanna"
10 }
11 },
12 {
13 "action": "fetch",
14 "url": "https://example.com/cml/next",
15 "method": "POST"
16 },
17 {
18 "action": "say",
19 "text": "Thank you for your call.",
20 "language": "en",
21 "voicePreferences": {
22 "voiceGender": "FEMALE",
23 "voiceName": "Joanna"
24 }
25 }
26 ]
27}

「フェッチ」アクションが失敗した場合(Webhook が使用できないか、不正な形式の CML アクションが返された場合)、NTT CPaaS プラットフォームはエラーを errorUrl に送信します(CML 設定上またはアクションで定義されているとおり)。errorUrl が正しい CML アクションを返さない場合、呼び出しは切断されます。

DTMF キャプチャ例外

captureDtmf アクションは、制御転送動作の例外です。次のアクションを検討してください。

json
1{
2 "actions": [
3 {
4 "action": "say",
5 "text": "Hello! This is Smile Dental calling to remind you of your appointment tomorrow at 10 AM.",
6 "language": "en",
7 "voicePreferences": {
8 "voiceGender": "FEMALE",
9 "voiceName": "Joanna"
10 }
11 },
12 {
13 "action": "captureDtmf",
14 "maxLength": 1,
15 "timeout": 6,
16 "terminator": "#",
17 "callback": {
18 "url": "https://example.com/cml/dtmf",
19 "method": "POST"
20 },
21 "say": {
22 "action": "say",
23 "text": "Press 1 to confirm, 2 to reschedule, or 9 to talk to a receptionist.",
24 "language": "en"
25 }
26 },
27 {
28 "action": "hangup"
29 }
30 ]
31}

定義されたタイムアウト期間中にエンド ユーザーが DTMF プロンプトに応答せず、captureDtmf アクションが callOnEmpty フラグを使用しない場合、次のアクションが実行されます (この場合は hangup)。