Overview
A DNIs Pool is a rotating pool of Dynamic Number Insertion (DNI) numbers that allows you to connect to your Virtual Agent hosted on PolyAI’s infrastructure. This integration enables you to:- Share structured JSON metadata with your Agent at the beginning of a call.
- Retrieve call state information at the end of the conversation.
- You’re using PSTN, which by definition does not support sharing metadata.
- You’re using SIP installations that do not support custom SIP headers.
Requirements
To set up the DNIs Pool integration, you’ll need the following from your PolyAI contact:- API token for the
Reserve DNI
endpoint - API token for the
Get Handoff
endpoint - Your
account_id
andproject_id
- Agree with your PolyAI contact on the attributes the Agent will need to extract
Integration Runtime
The integration involves two main API endpoints:
- Client sends project-specific attributes to the Reserve DNI endpoint. An example payload would look like this:
- PolyAI stores the attributes and returns a reserved DNI (e.g.,
+12345
). - Client initiates a call to the DNI.
- PolyAI looks up the attributes for that DNI.
- Attributes are forwarded to the Virtual Agent based on your API Key.
- The Virtual Agent handles the conversation and stores any agreed data (e.g., handoff status).
- The call ends, and PolyAI sends a SIP BYE message.
- Client queries the Get Handoff endpoint to retrieve the call outcome.
An example response will look like this - note that the
shared_id
is the same ID you would have sent above:
- If a handoff state is present, the Client can transfer the call to a human agent; otherwise, the call is considered complete.
Agent setup
As a first step, head over to your project. For the integration to work, we will need your Agent to:- Store the attributes you are sending through the
Reserve DNI
API. - Save the handoff info into state to have the
Get Handoff
API to show them when invoked.
Store attributes
Attributes received from the API can only be accessed in thestart_function
.
Not doing it here would mean losing them for all the conversations, making it impossible for the integration to work.
In your start_function
, attributes are stored in the integration_attributes
field as a dictionary.
Retrieve them like this (assuming the attributes sent are the ones in the example above):
Save handoff info
As we outlined above, the bot will always need to end the conversation with this integration. For this reason, we need to configure the handoff information in other ways, which is: prepare them to be exposed by the Handoff API. The Handoff API can be configured to expose all thestate
variables that you desire.
The most useful variables are often:
- the handoff reason, which is usually stored in
conv.state.handoff_reason
- the handoff destination, which is usually stored in
conv.state.handoff_to
But you can always expose more based on your use case.
state
variables, the Handoff API will expose them
(as long as it is configured to do so).
At the moment, configuration can only be done by your PolyAI contact. Send them all the
variables you want to expose, and they will be able to set up the Handoff API accordingly.