Yes! Now OpenHab can make a Telegram phone calls (with Voice) thanks to the CallMeBot API. You just need OpenHab to execute the following command to get a Telegram Voice call and "read" your message with different voices:

http://api.callmebot.com/start.php?source=openHAB&user=@username&text=This is openHAB calling to you to inform you about something that is happening at your house&lang=en-GB-Standard-B

Parameters:
user is your Telegram Username/Alias (i.e. @myusername) or you can also use your phone number including the international code. Important!: You need to authorize CallMeBot to contact you here. This is required to avoid spam.
text is the message that you want the bot to speak.
lang is the language/voice that you want the bot to speak. You can get the list of languages here. Use the "Voice Name" (4th column) as parameter to use. Please note that only the Standard languages are supported. (Wavenet premium languages/voices  won't work with this API).

For example, calling to @myusername and speak the message in English with a Male voice:

wget 'http://api.callmebot.com/start.php?source=openHAB&user=@myusername&text=This is openHAB calling to you to inform you about something that is happening at your house&lang=en-GB-Standard-B'

For example, calling to +34 123 123 1123 and speak the message in Spanish:

wget 'http://api.callmebot.com/start.php?source=openHAB&user=+33 123 123 1123&text=Este es openHAB llamando para informar sobre algo que esta sucediendo en tu casa&lang=es-ES-Standard-A'

To do that in OpenHab is pretty easy! You have different ways to do it.

Instructions (OPTION 1): Using ECMAScript in OH3

You can create an ECMAScript in the new OpenHab v3 using the HttpUtil.executeUrl command.

Code:

var HttpUtil = Java.type("org.openhab.core.io.net.http.HttpUtil")
var urlmessage = encodeURI("This is a test from openHAB calling you becaue something is happening in your house")
HttpUtil.executeUrl("GET", "http://api.callmebot.com/start.php?source=openHAB&user=+34123123123&text=" + urlmessage , 2000)

 

INSTRUCTIONS (OPTION 2): Using the OpenHab HTTP Actions:

Use the sendHttpGetRequest action like this:

import java.net.URLEncoder
rule "Test Telegram Call"
when     
Item TestCall changed to ON
then
val urlmessage = URLEncoder::encode("This is a test from openHAB calling to you becaue something is happening in your house", 'UTF-8')
SendHttpGetRequest("http://api.callmebot.com/start.php?source=openHAB&user=+34123123123&text=" + urlmessage)
end
In this example, we are using the URLEncoder function to format properly the message passed in the URL. If no lang (language) parameter is set, then english is used by default.
 

 INSTRUCTIONS (OPTION 3): Using the OpenHab Exec Actions:

rule "Another Telegram Call Test"
when
    Item TestCall2 changed to ON
then
    var MessageTelegram = ("La alarma esta sonando en la cocina. Mirar las camaras por favor")

    MessageTelegram = MessageTelegram.replace(" ", "%20")
executeCommandLine ("wget http://api.callmebot.com/start.php?source=openHAB&user=@myusername&text="+MessageTelegram+"&lang=es-ES-Standard-A") // ES=Spanish check the list in the link above
 

In this example, I replaced the " " (spaces) by "%20" to encode the URL. And I used the wget shell command to execute the GET command needed by the API.

Dedicated Telegram Bot for you and your Business

You can have your own dedicated bot to make the phone calls. 

These are the benefits of having your own bot:

  • Your own Telegram Username, Bio and Picture (Logo).
  • No delays. You will have your own queue.
  • Calls can be longer than 30 seconds
  • You can call to anybody without having the recipient to go through the authentication process. (Spam is not allowed)
  • Unlimited number of calls to unlimited recipients.

The cost of a dedicated instance is $15 per month. No setup fee if paid annually.

If you are interested, please contact me at [email protected]

Thank you!

Problems?

If you have problems, like not receiving the Call on Telegram, or not receiving the WhatsApp messages,  try to test the CallMeBot API using your Web Browser:

  • Telegram Phone Calls using Web Browser: here
  • Telegram Text Messages using Web Browsers: here
  • WhatsApp Text Messages using Web Browser: here

You might get some errors on the screen that will help you to identify the problem. (Ex: Calls disabled in the Telegram Security Settings, WhatsApp not activated, etc.)

If you still have problems using the API, don’t hesitate to contact me in Telegram @callmebot_com or by email at [email protected]. Remember to Follow me on Twitter to get news about coming features, changes, invitations, etc.