Home
RECOMMENDED FOR YOU:
SMS Gateway software
Ozeki brings you outstanding
SMS Gateway technology. Use our SMS Server products on Windows,Linux, or Android

C# SMS API
Developers can use our C# SMS API to send SMS from C#.Net. The C# SMS API comes with full source code

PHP SMS API
The ozeki PHP SMS gateway software can be used to send SMS from PHP and to receive SMS usig PHP on your website

SMPP SMS Gateway
SMS service providers use our SMPP gateway solution, that offers a high performance SMPP server and SMPP client gateway with amazing routing capabilities
Ozeki Phone System 10

Say Hello



Now, get to know how to say an automated greeting message when you have an incoming call. When your installed API Extension gets a call, it will be forwarded to the Incoming call URL to your application. For better understanding please select your programming language and check the following code example.


Now, get to know how to say an automated greeting message when you have an incoming call. First of all, please login and connect to the API Extension. Wait for an Incoming call, and when it is occured just attach a TextToSpeech engine into the call and add the "Hello" as Text.

Next: Greet Caller by Name

Example code coming soon...
[HttpPost]
public ActionResult SayHello(string notificationName, string callLegID, string caller, string apiExtension)
{
	return Content(
	"<Response>" +
		"<Speak>Hello!</Speak>" +
	"</Response>", "text/xml");
}
class SayHelloController < ApplicationController

  protect_from_forgery except: :index

  # In routes.rb you need to set the following routing rule
  # post '/say_hello' => 'say_hello#index'
  
  def index
    render :xml => '<?xml version="1.0" encoding="UTF-8"?>
    <Response>
      <Speak>Hello</Speak>
    </Response>'
  end

end
<?php
	print "<Response>";
		print "<Speak>Hello</Speak>";
	print "</Response>";
?>
#!c:/Perl64/bin/perl.exe   
print "Content-Type: text/plain\n\n";
#You have to add the directory route of perl.exe, and print the content type

#Send response by print
print 
'<?xml version="1.0" encoding="UTF-8"?>
<Response>
	<Speak>Hello</Speak>
</Response>'
Imports OPSSDK
Imports Ozeki.Media.MediaHandlers
Imports OPSSDKCommon.Model.Call
Imports Ozeki.VoIP

Module Module1
    Public Sub Main(args As String())
        Dim client = New OpsClient()
        AddHandler client.ErrorOccurred, Sub(sender, info)
                                             Console.WriteLine(info.Message)
                                         End Sub

        If Not client.Login("ozekixepbx.ip", "admin", "12345") Then
            Return
        End If

        Dim apiExtension = client.GetAPIExtension("9000")
        AddHandler apiExtension.IncomingCall, AddressOf IncomingCall
        Console.ReadLine()
    End Sub

    Private Sub IncomingCall(sender As Object, e As VoIPEventArgs(Of ICall))
        Dim [call] = e.Item
        Dim tts = New TextToSpeech()
        AddHandler tts.Stopped, Sub(s, ev)
                                    [call].HangUp()
                                End Sub
        [call].ConnectAudioSender(tts)

        AddHandler [call].CallStateChanged, Sub(s, ev)
                                                If ev.Item = CallState.Answered Then
                                                    tts.AddAndStartText("Hello")
                                                ElseIf ev.Item.IsCallEnded() Then
                                                    tts.Dispose()
                                                End If
                                            End Sub

        [call].Accept()
    End Sub
End Module
	 
def application(environ, start_response):
    
    SpeakText="Hello"
    
    result ="""
    <?xml version="1.0" encoding="UTF-8"?>
    <Response>
        <Speak>{0}</Speak>
    </Response>""".format(SpeakText)
        
    response_headers = [('Content-type', 'text/plain'), ('Content-Length', str(len(result)))]
    start_response('200 OK', response_headers)

    return [result]
	 
using System;
using OPSSDK;
using OPSSDKCommon.Model.Call;
using Ozeki.Media.MediaHandlers;
using Ozeki.VoIP;

namespace OPS_QuickStartExample_CSharp
{
    class Program
    {
        static void Main(string[] args)
        {
            var client = new OpsClient();
            client.ErrorOccurred += (sender, info) =>
                Console.WriteLine(info.Message);

            if (!client.Login("ozekixepbx.ip", "admin", "12345"))
                return;

            var apiExtension = client.GetAPIExtension("9000");
            apiExtension.IncomingCall += IncomingCall;
            Console.ReadLine();
        }

        private static void IncomingCall(object sender, VoIPEventArgs e)
        {
            var call = e.Item;
            var tts = new TextToSpeech();
            tts.Stopped += (s, ev) => call.HangUp();
            call.ConnectAudioSender(tts);

            call.CallStateChanged += (s, ev) =>
            {
                if (ev.Item == CallState.Answered)
                    tts.AddAndStartText("Hello");
                else if (ev.Item.IsCallEnded())
                    tts.Dispose();
            };

            call.Accept();
        }
    }
}
package pbxsampleapp;

import com.sun.net.httpserver.*;
import java.io.*;
import java.net.*;

public class SayHello 
{
     public static void main(String[] args)
    {
        try
        {
            System.out.println("Starting http server...");
            HttpServer server = HttpServer.create(new InetSocketAddress(InetAddress.getByAddress(new byte[]{ 0, 0, 0, 0 }), 12345), 0);
            server.createContext("/sendsmstocaller", new PbxSampleApp.PBXRequestHandler());
            server.start();
            System.out.println("http server running on " + server.getAddress().toString());
        }
        catch (IOException ex) { System.out.println("Error" + ex.toString()); }
    }

    static class PBXRequestHandler implements HttpHandler
    {
        @Override
        public void handle(HttpExchange httpExchange) throws IOException
        {
            httpExchange.getResponseHeaders().add("Content-type", "text/xml");
            String response = "<?xml version=\"1.0\"?>"
                    + "<Response>"
                    + "<Speak>Hello!</Speak>"
                    + "</Response>";
            httpExchange.sendResponseHeaders(200, response.length());
            OutputStream os = httpExchange.getResponseBody();
            os.write(response.getBytes());
            os.close();
        }
    }
}
Code example 1 - Say “Hello” to the caller

The program will send back the OzML response to the API Extension and the caller. As you can see, it is just a simple Speak command. So when the application (the subscribing API Extension) will be called, the caller will hear a simple “Hello” message.
IN DETAILS

Get the OPSSDK.dll

First you need to add the OPSSDK.dll reference to your project
(You can find OPSSDK.dll at C:\Program Files\Ozeki\Ozeki Phone System\Examples\.NET API\OPSSDK.dll).

Login and connect

Create a new instance of OpsClient, and subscribe to the ErrorOccurred event. Your program will communicate with the Ozeki Phone System through this client. Try to login with the client into the running Ozeki Phone System, with the address of the server(ozekixepbx.ip) and a valid username, password combination.
If you are ready, try to get an existing API Extension, with the GetApiExtension method of the OpsClient. Read more about installation of API Extension.

Further steps

When you are ready with the initial steps above, subscribe the IncomingCall event of the apiExtension. This event will be triggered every time when the selected API Extension is called. In the mentioned event handler you will see the e.Item parameter, this parameter will be the call object. This call object has a CallState property, when the CallState is Ringing subscribe the CallStateChanged event of the call object and Accept the call.

The CallStateChanged event will be triggered when the call is going to another state . When the CallState is Answered, you can connect the devices to the call. When the call has ended, please do not forget to disconnect all devices from the call.

When the CallState is Answered, start and connect a TextToSpeech object to the call, that will read the "Hello" text to the caller. When the TextToSpeech is finished the call will hung up.

With these steps, you learned how to receive an incoming call, and say "Hello" to the caller.

Recommended reading

More information