logo

Emulate messages & calls

When integrating your system with Telgorithm, you will be using the Staging environment. This environment allows you to mock messages without actually sending them to real numbers, providing a full experience of working with Telgorithm, including creating messages, purchasing phone numbers, and setting up campaigns. However, you will not have control over inbound messages and calls.

To address this limitation, there is a feature to emulate these missing pieces, which can be accessed at testkit. Authorization is achieved using a company token.

Emulate Inbound Messages

To emulate an Inbound Message, you will need to use the

https://api.staging.telgorithm.com/testkit/v1/Emulate/inbound-message
endpoint. This endpoint allows you to simulate an incoming message to Telgorithm by specifying only a few fields.

Body for the request contains:

  • "from" - The origination phone number of the message
  • "to" - The destination phone numbers of the message, that should contain at least one company number
  • "text" - The text of the message
  • "mediaUrls" - The URLs for the media, to emulate MMS message
{
"from": "+19876543210",
"to": [
"+11234567890",
"+11234567891"
],
"text": "Text of the message",
"mediaUrls": [
"http://some.site/image.png"
]
}

Once the request is processed, the emulation will create the Inbound Message and send a webhook if it is set up.

Emulate Outbound Delivery Status

To emulate whether an Outbound Message has been delivered or failed, you will need to use the

https://api.staging.telgorithm.com/testkit/v1/Emulate/outbound-message-status
endpoint. This endpoint allows you to set up the delivery status of an outbound message by providing its SID.

Body for the request contains

  • "sid" - Sid of Outbound Message
  • "to" - The boolean flag, that indicates if delivery should succeed or not
{
"sid": "OM08d9704f044a2fa13d3faa216fcf4574b64b19be32626243",
"deliveredSuccessfully": true
}

Once the request is processed, the emulation will change the status of the Outbound Message and send a webhook if it is set up.

Emulate Inbound Call

To emulate an Inbound Call, you will need to use the

https://api.staging.telgorithm.com/testkit/v1/Emulate/inbound-call
endpoint. This endpoint allows you to create a call to your number and check the forwarding rules.

Body for the request contains:

  • "from" - The origination phone number of the call
  • "to" - The destination phone number of the call, that should be a company number
  • "durationInMinutes" - Desired duration (in minutes) of emulated call. Value should be in range of
    [0; 5]
    .
{
"from": "+19876543210",
"to": "+11234567890",
"durationInMinutes": 1
}

If you specify a

durationInMinutes
of
0
, the call will hang up immediately, and no outbound call leg will be created, and no forwarding will be used or requested via webhook.

Otherwise, the call will be handled as follows:

  1. With static forwarding setup, the call ends when the request ends. Inbound and outbound call legs are created, and the call is completed. The duration is set to the value passed in the request.
  2. With routing webhook configuration, the request ends before the call ends, as forwarding data is retrieved via webhook. You will need to await a little for the call to be completed. The duration is set to the value passed in the request.