Telegram Message

Send Telegram messages with Omnichannel API.


Before sending WhatsApp, Viber or Telegram messages, please contact our support team. These providers require some extra verification before you can start sending messages.

Development libraries for Telegram

We are in the process of upgrading our public libraries. Regular Omnichannel libraries do not include Telegram functionality.

Send Telegram Message

Use the following example to send a Telegram Message using Omnichannel API.

using System;
using System.Diagnostics;
using System.Collections.Generic;
using com.Messente.Api.Api;
using com.Messente.Api.Client;
using com.Messente.Api.Model;

namespace Example
{
    public class SendOmniMessageExample
    {
        public static void Main()
        {
            Configuration.Default.Username = "MESSENTE_API_USERNAME";
            Configuration.Default.Password = "MESSENTE_API_PASSWORD";

            List messages = new List();
            var telegram = new Telegram(
                sender: "YOUR_PHONE_NUMBER",
                text: "Hello Telegram!",
                image_url: 'https://media.voog.com/0000/0039/8460/photos/5842a8fba6515b1e0ad75b03.png'
            );
            messages.Add(telegram);

            var apiInstance = new OmnimessageApi();
            var omnimessage = new Omnimessage(to: "RECIPIENT_PHONE_NUMBER", messages: messages);

            try
            {
                OmniMessageCreateSuccessResponse result = apiInstance.SendOmnimessage(omnimessage);
                Debug.WriteLine(result);
            }
            catch (Exception e)
            {
                Debug.Print("Exception when calling SendOmnimessage: " + e.Message);
            }
        }
    }
}
    
curl https://api.messente.com/v1/omnimessage \
    -u MESSENTE_API_USERNAME:MESSENTE_API_PASSWORD \
    -H "Content-Type: application/json" \
    -H "Accept: application/json" \
    -d '{ "to": "RECIPIENT_PHONE_NUMBER", "messages": [{ "channel": "telegram", "sender": "YOUR_PHONE_NUMBER", "text": "Hello Telegram!", "image_url": "https://media.voog.com/0000/0039/8460/photos/5842a8fba6515b1e0ad75b03.png" }] }'
    
public class Main {
    public static void main(String[] args) {
        ApiClient apiClient = new ApiClient();

        HttpBasicAuth basicAuth = (HttpBasicAuth) apiClient.getAuthentication("basicAuth");
        basicAuth.setUsername("MESSENTE_API_USERNAME");
        basicAuth.setPassword("MESSENTE_API_PASSWORD");

        OmnimessageApi apiInstance = new OmnimessageApi(apiClient);
        Omnimessage omnimessage = new Omnimessage();
        Telegram telegram = new Telegram();
        telegram.text("Hello Telegram!");
        telegram.imageUrl("https://media.voog.com/0000/0039/8460/photos/5842a8fba6515b1e0ad75b03.png");
        telegram.sender("YOUR_PHONE_NUMBER");

        omnimessage.setMessages(Arrays.asList(telegram,));
        omnimessage.setTo("RECIPIENT_PHONE_NUMBER");

        try {
            OmniMessageCreateSuccessResponse result = apiInstance.sendOmnimessage(omnimessage);
            System.out.println(result);
        } catch (ApiException e) {
            System.err.println("Exception when calling sendOmnimessage");
            e.printStackTrace();
        }
    }
}
    
const MessenteApi = require('messente_api');

const defaultClient = MessenteApi.ApiClient.instance;

// Configure HTTP basic authorization: basicAuth
const basicAuth = defaultClient.authentications['basicAuth'];
basicAuth.username = 'YOUR_MESSENTE_API_USERNAME';
basicAuth.password = 'YOUR_MESSENTE_API_PASSWORD';

const api = new MessenteApi.OmnimessageApi();

const telegram = MessenteApi.Telegram.constructFromObject({
  sender: 'YOUR_PHONE_NUMBER',
  text: 'Hello Telegram!',
  image_url: 'https://media.voog.com/0000/0039/8460/photos/5842a8fba6515b1e0ad75b03.png'
});

const omnimessage = MessenteApi.Omnimessage.constructFromObject({
  messages: [telegram],
  to: 'RECIPIENT_PHONE_NUMBER'
});

api.sendOmnimessage(omnimessage, (error, data) => {
  if (error) {
    console.error(error);
  } else {
    console.log('API called successfully. Returned data: ', data);
  }
});
  
setUsername('MESSENTE_API_USERNAME')
    ->setPassword('MESSENTE_API_PASSWORD');

$apiInstance = new OmnimessageApi(
    new GuzzleHttp\Client(),
    $config
);

$omnimessage = new Omnimessage([
    "to" => "RECIPIENT_PHONE_NUMBER"
]);

$telegram = new Telegram([
    "text" => "Hello Telegram!",
    "image_url" => "https://media.voog.com/0000/0039/8460/photos/5842a8fba6515b1e0ad75b03.png"
    "sender" => "YOUR_PHONE_NUMBER"
]);

$omnimessage->setMessages([$telegram]);

try {
    $result = $apiInstance->sendOmnimessage($omnimessage);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling sendOmnimessage: ', $e->getMessage(), PHP_EOL;
}
    
from pprint import pprint
from messente_api import (
    OmnimessageApi,
    Telegram,
    Omnimessage,
    Configuration,
    ApiClient
)
from messente_api.rest import ApiException

# API information from https://dashboard.messente.com/api-settings
configuration = Configuration()
configuration.username = 'MESSENTE_API_USERNAME'
configuration.password = 'MESSENTE_API_PASSWORD'

# create an instance of the API class
api_instance = OmnimessageApi(ApiClient(configuration))

telegram = Telegram(
    sender='YOUR_PHONE_NUMBER',
    text='Hello Telegram!',
    image_url='https://media.voog.com/0000/0039/8460/photos/5842a8fba6515b1e0ad75b03.png'
)

omnimessage = Omnimessage(
    messages=(telegram,),
    to='RECIPIENT_PHONE_NUMBER',
)

try:
    response = api_instance.send_omnimessage(omnimessage)
    print(
        'Successfully sent Omnimessage with id: %s that consists of the following messages:' % response.omnimessage_id
    )
    for message in response.messages:
        pprint(message)
except ApiException as exception:
    print('Exception when sending an omnimessage: %s\n' % exception)
    
require 'messente_api'

MessenteApi.configure do |config|
    config.username = 'MESSENTE_API_USERNAME'
    config.password = 'MESSENTE_API_PASSWORD'
end

api_instance = MessenteApi::OmnimessageApi.new
omnimessage = MessenteApi::Omnimessage.new
omnimessage.to = 'RECIPIENT_PHONE_NUMBER'
omnimessage.messages = [
    MessenteApi::Telegram.new(
        {
            :sender => "YOUR_PHONE_NUMBER",
            :text => "Hello Telegram!"
            :image_url: "https://media.voog.com/0000/0039/8460/photos/5842a8fba6515b1e0ad75b03.png"
        }
    )
]

begin
    result = api_instance.send_omnimessage(omnimessage)
rescue MessenteApi::ApiError => e
    puts "Exception when calling send_omnimessage: #{e}"
    puts e.response_body
end
    

Response

{
  "messages": [
    {
      "channel": "telegram",
      "message_id": "fr593ce7-68de-5e44-bc50-044a3ad0a7fe",
      "sender": "SENDER_ID"
    }
  ],
  "omnimessage_id": "632c6f3d-49d0-4a8f-5k2n-74023d31e51f",
  "to": "RECIPIENT_PHONE_NUMBER"
}

Use the message_id to keep track of the message delivery status.


Features

Telegram messages are not limited to SMS restrictions. You can send text, images, documents or audio clips in your messages for the same price.

Images, documents and audio clips are mutually exclusive. You can send only one of these types in a single message.

Use the following parameters to compose the message with different elements:

text: Message to send to the device
image_url: Emebedded image URL (jpg, jpeg, png, gif files are supported)
document_url: Link to a document
audio_url: Link to an audio clip

Error example

{
  "errors": [
    {
      "code": "105",
      "detail": "Invalid or disallowed sender Messente",
      "source": "payload[telegram][sender]",
      "title": "Invalid data"
    }
  ]
}
Key Value
title Error message
detail Longer description of the error message
code Machine-readable error code

101 Not found
102 Forbidden
103 Unauthorized
104 Invalid data
105 Internal Server Error
106 Missing data
107 Method not allowed
source Location in the request body for this error message

Next steps

Now that you can send Telegram messages it's time to learn about delivery reports.