💡  Beta product

This product is a Beta product. This means that it and the information is subject for change, updates or removal.
If you test this product, please let us know your feedback, so that we can make it the best possible product for you. Please share your feedback with us here.

Send a question

Making a request to Conversations is a bit different from making a regular Send SMS request. The from parameter will not be used with Conversations, as the sender number will be added automatically.

Limitations

For each country where you have conversations activated, you have a limit on the maximum number of active conversations(default is 3) at the same time with any one recipient. Contact our support if you need to increase this.

Request

POST https://api.46elks.com/a1/conversations

Request parameters

Parameter Example Description
to +46700000000 The phone number of the recipient in E.164 format.
message Can you work on Saturday?
Answer with yes or no.
The message sent out as a SMS
reply_url http://example.com/new-reply The URL to the webhook which will be handling incoming replies.

Sample code

curl https://api.46elks.com/a1/conversations \
          -u api_username:api_password \
          -d to=+46700000000 \
          -d message="Who do you want to see in the final?" \
          -d reply_url='https://example.com/reply_url'
import requests

response = requests.post(
  'https://api.46elks.com/a1/conversations',
  auth = (API_USERNAME, API_PASSWORD),
  data = {
    'to': '+46766861000',
    'message': 'What is the capital of Sweden?',
    'reply_url': 'https://example.com/reply_url',
  }
)
print(response.text)

Optional request parameters

Parameter Example Description
token abc123 Optional user-specified ID that is delivered in the webhook for responses to this conversation.
lifetime lifetime=2h Default is that a conversation is closed within 16 hours. That time window is adjustable down to 1h or up to 72h with lifetime parameter.
delay delay=allowed Delay is used in order to be able to "queue" questions if you have too many active conversations with the recipient. Ensures that once one conversation is closed the next question will be sent out.

Response

Example JSON response
{
  "status": "started", 
  "created": "2024-05-17T10:46:33.548909", 
  "items": ["sb0b8bbf30470619255531e77d81ae48e"], 
  "expires": "2024-05-18T02:46:33.548909", 
  "reply_url": "https://example.com/receive_reply", 
  "to": "+46700000000", 
  "message": "Attending the conference? Answer yes or no.", 
  "id": "s70df59406a1b4643b96f3f91e0bfb7b0",
  "token": "abc123"
}
Attribute Type Description
status string Current delivery status of the question.

Possible values are "created", "sent", "failed" and "delivered".
from string The sender of the question as seen by the recipient.

Here it is an automatically allocated phone number in E.164 format via Conversations.
created string Time in UTC when the question was created.
items string Unique reference for the question ID.
expires string Time in UTC when the conversation expires.
reply_url string URL for the webhook handling the answers.
to string The phone number of the recipient in E.164 format.
id string Unique identifier for this question.
message string The question text sent.
token string User-specified id. This is not processesed by 46elks and is included as-is in the response webhook for replies.