Last updated on Jun 27

4 min read

Playbook API

Improve connect rates by leveraging Open API for configuring personalised playbooks.

GraphQL Endpoint & Header Details

Endpoint https://clusterid.samespace.com/crm/api
x-api-key XoaFDQ34c@NIs!AvGgCYe2jmCppr43FR

Note: For the Playbook API to work, an API key with type “Voice” is required. Only users with "Admin" access can create the same in the settings section.

Get Playbooks

This API enables users to get a list of playbooks created in their Samespace account.

Query

query GetPlaybooks {
  getPlaybooks {
    _id
    name
    settings {
      general {
        timesetId
        contactTimezone
      }
      call {
        dialMode
        onlyOwner
        teamId
        ... on PreviewCallSetting {
          dialMode
          teamId
          onlyOwner
          dropVoicemail
          fileUuid
          fileName
          dialDelay
          allowSkip
        }
        ... on ProgressiveCallSetting {
          dialMode
          teamId
          onlyOwner
          dropVoicemail
          fileUuid
          fileName
        }
        ... on PredictiveCallSetting {
          dialMode
          teamId
          onlyOwner
          abandonedThreshold
          voicemailDetection
          dropVoicemail
          fileUuid
          fileName
        }
        ... on FlowCallSetting {
          dialMode
          teamId
          onlyOwner
          flow
          callControl
          abandonedRate
          channels
        }
      }
    }
    status
    createdBy
    modifiedBy
    createdAt
    modifiedAt
  }
}

Start and Stop Playbook

This Open API enables you to update the playbook status. Status can be “Active” or “Inactive

Mutation for Start Playbook

mutation StartPlaybook($id: ID!) {
 startPlaybook(_id:$id)
}

Payload

{
 "id": "61d5551a64d245afe702f3ae",
}

Mutation for Stop Playbook

mutation StopPlaybook($id: ID!) {
 stopPlaybook(_id:$id)
}

Payload

{
 "id": "61d5551a64d245afe702f3ae",
}

Get Individual playbook’s details

The API uses the Playbook ID to return a single playbook's details like name, dialing mode, status and columns.

Query

query GetPlaybook($id: ID!) {
  getPlaybook(_id: $id) {
    _id
    name
    settings {
      general {
        timesetId
        contactTimezone
      }
      call {
        dialMode
        onlyOwner
        teamId
        ... on PreviewCallSetting {
          dialMode
          teamId
          onlyOwner
          dropVoicemail
          fileUuid
          fileName
          dialDelay
          allowSkip
        }
        ... on ProgressiveCallSetting {
          dialMode
          teamId
          onlyOwner
          dropVoicemail
          fileUuid
          fileName
        }
        ... on PredictiveCallSetting {
          dialMode
          teamId
          onlyOwner
          abandonedThreshold
          voicemailDetection
          dropVoicemail
          fileUuid
          fileName
        }
        ... on FlowCallSetting {
          dialMode
          teamId
          onlyOwner
          flow
          callControl
          abandonedRate
          channels
        }
      }
    }
    status
    createdBy
    modifiedBy
    createdAt
    modifiedAt
  }
}

Response

{
    "data": {
        "getPlaybook": {
            "_id": "646f07ea3c37774e476bf998",
            "name": "AI Flow",
            "settings": {
                "general": {
                    "timesetId": "63ca40c5e23a02e6b320ba5c",
                    "contactTimezone": false
                },
                "email": null,
                "sms": null,
                "call": {
                    "dialMode": "FLOW",
                    "onlyOwner": false,
                    "teamId": "63a032ea9fcc0cfec1301cd4",
                    "flow": "646f0a95b6d34994c969136d",
                    "callControl": null,
                    "abandonedRate": null,
                    "channels": 1
                }
            },
            "status": "INACTIVE",
            "createdBy": "62a1a7d21b1efd23136a8e29",
            "modifiedBy": "62a1a7d21b1efd23136a8e29",
            "createdAt": "1684998979067",
            "modifiedAt": "1684998979076"
        }
    }
}

Create a Playbook

This API is used to create a playbook.

Mutation

mutation CreatePlaybook($payload: PlaybookInput!) {
  createPlaybook(payload: $payload) {
    _id
    name
    settings {
      general {
        timesetId
        contactTimezone
      }
      
      call {
        dialMode
        onlyOwner
        teamId
        ... on PreviewCallSetting {
          dialMode
          teamId
          onlyOwner
          dropVoicemail
          fileUuid
          fileName
          dialDelay
          allowSkip
        }
        ... on ProgressiveCallSetting {
          dialMode
          teamId
          onlyOwner
          dropVoicemail
          fileUuid
          fileName
        }
        ... on PredictiveCallSetting {
          dialMode
          teamId
          onlyOwner
          abandonedThreshold
          voicemailDetection
          dropVoicemail
          fileUuid
          fileName
        }
        ... on FlowCallSetting {
          dialMode
          teamId
          onlyOwner
          flow
          callControl
          abandonedRate
          channels
        }
      }
    }
    status
    createdBy
    modifiedBy
    createdAt
    modifiedAt
  }
}

Payload

{
  "payload": {
    "steps": [
      {
        "bcc": null,
        "callScript": "Calling to {{firstName}} ",
        "cc": null,
        "filters": null,
        "name": null,
        "runAfter": null,
        "to": "phoneNumber",
        "type": "CALL",
        "status": "ENABLED"
      }
    ],
    "name": "Playbook",
    "rules": {
      "filters": null,
      "sorts": null,
      "type": "Native",
    },
    "settings": {
      "general": {
        "timesetId": "642183089e3b4f948f9ccdac",
        "contactTimezone": false
      },
      "call": {
        "dialMode": "PREVIEW",
        "teamId": "6454d486e15440b61c87f231",
        "dialDelay": 0,
        "abandonedThreshold": 3,
        "voicemailDetection": false,
        "flow": null,
        "channels": 0,
      }
    }
  }
}

Update Playbook

This Open API enables you to update the settings and rules in your playbook.

Mutation

mutation UpdatePlaybook($id: ID!, $payload: PlaybookInput!) {
  updatePlaybook(_id: $id, payload: $payload) {
    _id
    name
    settings {
      general {
        timesetId
        contactTimezone
      }
      call {
        dialMode
        onlyOwner
        teamId
        ... on PreviewCallSetting {
          dialMode
          teamId
          onlyOwner
          dropVoicemail
          fileUuid
          fileName
          dialDelay
          allowSkip
        }
        ... on ProgressiveCallSetting {
          dialMode
          teamId
          onlyOwner
          dropVoicemail
          fileUuid
          fileName
        }
        ... on PredictiveCallSetting {
          dialMode
          teamId
          onlyOwner
          abandonedThreshold
          voicemailDetection
          dropVoicemail
          fileUuid
          fileName
        }
        ... on FlowCallSetting {
          dialMode
          teamId
          onlyOwner
          flow
          callControl
          abandonedRate
          channels
        }
      }
    }
    steps {
      _id
      created
      failed
      filters {
        key
        condition
        value
      }
      ... on CallStep {
        _id
        playbookId
        type
        name
        to
        callScript
        runAfter {
          interval {
            type
            value
          }
          time
        }
    }
    status
    createdBy
    modifiedBy
    createdAt
    modifiedAt
  }
}

Payload to update the name of a Playbook

{
  "id": "646f5c463c37774e476bf9c5",
  "payload": {
    "name": "Playbook test"
  }
}

Delete a Playbook

This Open API enables you to delete a playbook.

Mutation

This mutation takes a filter which finds playbook and deletes it.

mutation DeletePlaybook($id: ID!) {
  deletePlaybook(_id: $id)
}

Payload

{
  "id": "646f0d7b3c37774e476bf9ad"
}

Response

{
    "data": {
        "deletePlaybook": true
    }
}