Skip to content

[DOC] - Update SWML transfer examples to avoid over billing #751

@Slamhaus

Description

@Slamhaus

Describe the requested update
We publish guides like this one that teach customers how to execute SWML with an AI Agent: https://developer.signalwire.com/swml/guides/ai/executing_swml/

However any guide that covers AI call transfers (transfer to SIP, PSTN, a conference, etc.) needs to updated to ensure the AI Agent properly leaves the call after the transfer or else customers will continue to be billed for the AI Agent after the transfer.

You can find more details on this behavior here: https://github.com/signalwire/cloud-product/issues/16882

Reason for the request
If customers use our current examples, they will continue to be billed for AI Agent minutes even after the calls are transferred.

Sections to be updated
The example here: https://developer.signalwire.com/swml/guides/ai/executing_swml/
The transfer example here: https://developer.signalwire.com/swml/guides/ai/toggle_functions

Additional context
If you read the github above you'll see all the notes about using transfer correctly, but here are the important details:

  • This is a limitation of YAML so in order to work correctly the SWML script must be written in JSON
  • You must have "transfer": true at the beginning of the transfer SWML. Here's a working example:
{
  "version": "1.0.0",
  "sections": {
    "main": [
      {
        "ai": {
          "prompt": {
            "text": "You are a friendly assistant. Greet the caller and ask if they would like to join the conference. If they say yes, use the 'join_conference' function to place them in the conference. If they say no, politely thank them and end the call."
          },
          "params": {
            "swaig_allow_swml": true
          },
          "SWAIG": {
            "functions": [
              {
                "function": "join_conference",
                "purpose": "Place the caller into a conference room when they confirm they want to join",
                "argument": {
                  "type": "object",
                  "properties": {
                    "confirmation": {
                      "type": "string",
                      "description": "The caller's confirmation that they want to join (e.g., \"yes\", \"sure\", \"okay\")"
                    }
                  }
                },
                "data_map": {
                  "expressions": [
                    {
                      "string": "${args.confirmation}",
                      "pattern": ".*",
                      "output": {
                        "response": "Great! Placing you in the conference now.",
                        "action": [
                          {
                            "transfer": true,
                            "SWML": {
                              "sections": {
                                "main": [
                                  {
                                    "join_conference": {
                                      "name": "main_conference"
                                    }
                                  }
                                ]
                              }
                            }
                          }
                        ]
                      }
                    }
                  ]
                }
              }
            ]
          },
          "hints": [
            "join conference",
            "yes",
            "no"
          ]
        }
      }
    ]
  }
}

Related Issues or PRs
https://github.com/signalwire/cloud-product/issues/16882

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions