Académique Documents
Professionnel Documents
Culture Documents
3 Implementing a Bot 23
Guidelines for Implementing Bots 23
Example Bots 24
RoShamBot 25
TriviaBot 25
BJStrategy Bot 26
TrafficBot 27
Bot Java Classes 29
This book provides information for developers tasked with developing applications
that will work with Openwave’s Instant Messaging and Presence Server (IMPS)
system. It provides two primary sets of information:
• Conformance statement indicating which Wireless Village primitives are
supported and information on extensions to the Wireless Village specification.
• APIs and guidelines for defining bots.
To use this book, you should have knowledge of the Wireless Village protocol and
experience with Java and writing Java scripts.
For more information about the IMPS product, refer to the other books in the
IMPS documentation set:
• For a list of known issues, new features, and the most up-to-date information
on the version of IMPS you are installing, see the Release Notes.
• For a general introduction to the IMPS system, its architecture and supported
features and functions, see the Overview.
• For information about planning, installing, and configuring IMPS installations,
see the Installation Guide.
• For administration, operations, provisioning, and maintenance information, see
the Working with the IMPS System.
• For conceptual information on agents, clients, and logging as well as
descriptions for each IMPS utility, configuration property, object, attribute,
and log event, see the Reference.
Openwave’s IMPS provides a full Service Access Point that conforms with the
Wireless Village Version 1.1 initiative. IMPS supports all mandatory requirements
of the initiative, as well as some conditional requirements that are applicable to
implementations supporting WAP and SMS client interfaces via HTTP, Wireless
Session Protocol (WSP) and SMS transport bindings. This chapter provides details
regarding the optional requirements that are supported.
Openwave’s IMPS Wireless Village implementation includes support for:
• Client Server Protocol (CSP)
Supports SMS and HTTP bindings for Wireless Village embedded clients.
• Applications Interface
Enables games, buddy bots, and content services to be deployed, which help
stimulate increased usage
Presence includes client device availability, user status, location, client device
capabilities, and searchable personal statuses such as mood. Access control features
put the control of the user presence information in the users’ hands. Wireless
Village enhances the familiar concept of Instant Messaging by enabling
interoperative mobile IM. Wireless Village allows both operators and end-users to
create and manage groups. Users can invite their friends and family to chat in
group discussions. Operators can build common interest groups where end-users
can meet each other online. The final feature, Shared Content, allows users and
operators to set up their own storage area where they can post pictures, music, and
other multimedia content while enabling the sharing with other individuals and
groups in an IM or chat session.
These features, taken in part or as a whole, provide the basis for new services that
build upon a common interoperable framework—Wireless Village.
The Wireless Village specification defines how the IMPS system should interface
with existing wireless network infrastructures. It also provides an open interface to
existing IM communities on the Internet. To the greatest extent possible, the
protocol uses XML to represent the protocol data being exchanged during an IMPS
session. The architecture and open protocol supports multiple server deployments
such that the operator can host their own service, in addition to enabling the
enterprise with their own IMPS servers.
General Conformance
Openwave’s IMPS system conforms to the Wireless Village initiative as follows:
• Service Requirements IMPS supports Service Access Point, Instant Messaging,
Presence, and Group Service Element functions. IMPS does not support
Content Service Element functions.
• XML Encoding Requirements IMPS supports both HTTP transport bindings
and conforms to all XML encoding requirements
• Address Requirements IMPS does not support client addressing. Local and
external user addressing are supported.
• Session Requirements IMPS supports all session requirements.
• Transaction Requirements IMPS supports all transaction requirements.
Requirement Supported?
Service requirements
Requirement Supported?
Function Supported?
Status primitive Y
Communication Initiation Request primitive N (TCP/IP only)
2-way login Y
4-way login Y
Logout originating from client Y
Server originated disconnect Y
Keep-Alive transaction (all) Y
Get Service Provider Info Y
Service negotiation Y
Client Capability negotiation Y
Search based on user properties (all) Y
Search based on group properties (all) Y
Stop search Y
Invitation (all) Y
Cancel invitation (all) Y
Function Supported?
Function Supported?
Setting delivery method Y
Send message (all) Y
Push message (all) Y
Pull message Y
Either pushing or pulling messages Y
Get list of messages Y
Reject message N
New message Y
Message notification Y
Get message Y
Delivery status report (all) Y
Forward message (all) Y
Get list of blocked entities (all) Y
Block entity (all) Y
Function Supported?
Group creation (all) Y
Group deletion (all) Y
Get group properties (all) Y
Set group properties (all) Y
Get group members (all) Y
Add group members (all) Y
Remove group members (all) Y
Member access rights (all) Y
Subscribe group notice (all) Y
Group change notification (all) Y
Join group (all) Y
Leave group (all) Y
Reject user(s) from group (all) Y
This chapter provides information on the extensions made to the Wireless Village
standard that are implemented in Openwave’s IMPS. There are two types of
extensions made:
• Typing Indicator Primitives
• Extensions to the Wireless Village DTD
Subscriber Typing
A user may get/set/unset typing change subscription status. The client sends the
SubscribeTypingRequest message to the server. The message contains the type of the
requested operation. The answer from the server for the operation is the
SubscribeTypingResponse message or Status if an error occurs. While the
subscription is active, the user will receive TypingUserRequest messages. See
Figure 2-1.
Figure 2-1. Subscriber typing status client-server communication
Client 1 Server
SubscribeTypingRequest
SubscribeTypingResponse
Primitive Direction
TypingRequest
Status TypingUserRequest
Status
Primitive Direction
Typing Request
Information elements used to support the TypingRequest extension are (an ‘M’
indicates it is a mandatory element):
55 Typing-Request
56 TypingUser-Request
57 SubscribeTyping-Request
58 IsTyping
59 SubscribeTyping-Response
Typing-Request:
<WV-CSP-Message xmlns="http://www.wireless-village.org/CSP1.1">
<Session>
<SessionDescriptor>
<SessionType>Inband</SessionType>
<SessionID>SESSIONID</SessionID>
</SessionDescriptor>
<Transaction>
<TransactionDescriptor>
<TransactionMode>Request</TransactionMode>
<TransactionID>TRANSACTIONID</TransactionID>
</TransactionDescriptor>
<TransactionContent xmlns="http://www.wireless
-village.org/TRC1.1">
<Typing-Request>
<Recipient>
<User><UserID>wv:recipient@software.com</UserID></User>
</Recipient>
<IsTyping>T</IsTyping>
</Typing-Request>
</TransactionContent>
</Transaction>
</Session>
</WV-CSP-Message>
TypingUser-Request:
<WV-CSP-Message xmlns="http://www.wireless-village.org/CSP1.1">
<Session>
<SessionDescriptor>
<SessionType>Inband</SessionType>
<SessionID>SESSIONID</SessionID>
</SessionDescriptor>
<Transaction>
<TransactionDescriptor>
<TransactionMode>Request</TransactionMode>
<TransactionID>TRANSACTIONID</TransactionID>
</TransactionDescriptor>
<TransactionContent xmlns="http://www.wireless
-village.org/TRC1.1">
<TypingUser-Request>
<Sender>
<User><UserID>wv:sender@software.com</UserID></User>
</Sender>
<IsTyping>T</IsTyping>
</TypingUser-Request>
</TransactionContent>
</Transaction>
</Session>
</WV-CSP-Message>
SubscribeTyping-Request (get):
<WV-CSP-Message xmlns="http://www.wireless-village.org/CSP1.1">
<Session>
<SessionDescriptor>
<SessionType>Inband</SessionType>
<SessionID>SESSIONID</SessionID>
</SessionDescriptor>
<Transaction>
<TransactionDescriptor>
<TransactionMode>Request</TransactionMode>
<TransactionID>TRANSACTIONID</TransactionID>
</TransactionDescriptor>
<TransactionContent xmlns="http://www.wireless-village.org/TRC1.1">
<SubscribeTyping-Request>
<SubscribeType>G</SubscribeType>
</SubscribeTyping-Request>
</TransactionContent>
</Transaction>
</Session>
</WV-CSP-Message>
SMS Encoding
Information elements used to support the DTD extensions are:
Element Code
TypingRequest TR
TypingUserRequest TU
SubscribeTypingRequest SY
SMS Examples
TypingRequest:
WV11TR761 SI=SESSIONID UI=wv:recipient@software.com IY=T
TypingUserRequest:
WV11TU761 SI=SESSIONID UI=wv:sender@software.com IY=T
SubscribeTypingRequest (get):
WV11SY761 SI=SESSIONID SU=G
SubscribeTypingResponse:
WV11YS761 SI=SESSIONID SS=T
Bot, short for robot, is an artificial IMPS user containing logic that dictates
responses to a chat invitation. Bots are defined using Java and including one or
more java classes provided by the IMPS system.
This chapter defines the basic information for implementing a bot, describes the
example bots provided with the current release, and defines the three base java
classes implemented to support the definition of bots.
IMPORTANT The example bots are provided for illustrative purposes only. They
are not expected to be used in a production deployment. No quality assurance
testing on these bots has been performed. Copyright issues may apply in the
case of the TriviaBot.
Example Bots
Four example bots are provided for illustrative purposes. Bots are able to maintain
the state of the chat and the number of users interacting with it.
IMPORTANT The example bots provided are not launched by default. You must
create your own script or initialize them for the system you are running. Refer
to the usage statement at the bottom of bot example for the initialization
command syntax.
All the example bots provided are initiated by initiating a chat session with the bot.
The convention used is for the user to enter:
?
to activate each of these example bots.
You can view the java code for each of these bots by accessing the following
directory on the Application Server:
$IM_HOME/appserver/apps/bots
The three Java base classes or files called by these bots can be obtained here:
$IM_HOME/appserver/src.zip
Unzip this file. The contents include:
ChatResponder.java
ChatState.java
ChatUser.java
./examples/BJStrategy.java
./examples/RoShamBot.java
./examples/TrafficBot.java
./examples/TrafficParser.java
./examples/TriviaBot.java
Additional files called by these bots can be obtained here:
$IM_HOME/appserver/apps/bots/lib
TriviaBot
The TriviaBot example implements a game of trivia. This bot:
• Initiates a game by prompting the user to select from one to nine categories of
questions:
Choose set of questions: { #1 | #2 | #3 | #4 | #5 | #6 | #7 | #8 | #9 }
• Loads in a text file (trivia.txt) that contains both questions and answers
• Compares the user response with the correct answer
• Replies with the game result, indicating if the user was correct or incorrect, and
the running score
The TriviaBot continues to play the game for a series of ten questions in the
category chosen. To continue play, the player must enter a ? to start a new game.
A sample listing (from a PC client) showing the interaction between a player and
the trivia bot is shown below:
Player: 4/1/2003 at 5:46 PM
?
trivia: 4/1/2003 at 5:46 PM
Choose set of questions: { #1 | #2 | #3 | #4 | #5 | #6 | #7 | #8 | #9 }
Player: 4/1/2003 at 5:46 PM
#2
trivia: 4/1/2003 at 5:46 PM
Q: How tall is the Statue of Liberty from her heel to the top of her head
(in feet)? { 111 | 183 | 251 | 384 }
Player: 4/1/2003 at 5:46 PM
384
trivia: 4/1/2003 at 5:46 PM
The answer was 111. 0 out of 1
trivia: 4/1/2003 at 5:46 PM
Q: In what year did the American Civil War end? { 1776 | 1812 | 1865 |
1914 }
Player: 4/1/2003 at 5:46 PM
1865
trivia: 4/1/2003 at 5:46 PM
RIGHT! Player got 1865. 1 out of 2
BJStrategy Bot
The BJStrategy bot implements a game that teaches the strategy behind the black
jack card game. This bot:
• Initiates a game by prompting the user on the four choices available to them:
type: s for stand, p split, d for double, or h for hit
• It then “deals” a black jack hand, for example:
dealer: 3
player: pair of 4's
move: {s | p | d | h}
• It uses a random generator to determine the deal.
Player: 12:27 PM
p
bjstrategy: 12:28 PM
wrong! you should have hit (0 / 1 - 0%)
bjstrategy: 12:28 PM
dealer: 2
player: pair of 6's
move: {s | p | d | h}
Player: 12:27 PM
p
bjstrategy: 12:28 PM
wrong! you should have hit (0 / 2 - 0%)
bjstrategy: 12:28 PM
dealer: 9
player: pair of 9's
move: {s | p | d | h}
Player: 12:27 PM
p
bjstrategy: 12:28 PM
correct (1 / 3 - 33%)
bjstrategy: 12:28 PM
dealer: 3
player: soft 15
move: {s | p | d | h}
TrafficBot
The TrafficBot implements an information bot that can be queried for the speed or
incident report on a particular highway. It also updates the status periodically. One
of two highways are used in this example: I90 and HW 405 in the Puget Sound area
of Washington state. This bot:
• Is initiated by opening a chat and querying with a “?.”
• Prompts the user to enter:
Type 'a' to see speed at all stations
Type 'm' to see incident report
A sample listing (from a PC client) showing the interaction between a user and the
TrafficBot is shown below:
90W: 2:27 PM
Type 'a' to see speed at all stations
Type 'm' to see incident report
User: 2:27 PM
a
90W: 2:27 PM
90W station speeds
68 - 23rd Ave S
63 - 35th Ave S
96 - West Highrise WB
71 - Midspan WB
80 - East Highrise WB
70 - Isl Crest Way-EB
62 - Shorewood Dr
64 - E Mercer Way-EB
50 - E Channel Bridge
45 - 118th Ave SE
58 - 118th Ave SE
50 - Richards Rd
50 - 136th Ave SE
61 - 136th Ave SE
60 - 136th Ave SE
68 - 161st Ave SE
60 - 164th Ave SE
55 - 169th Ave SE
59 - 182nd Ave SE
56 - 188th Ave SE
66 - 200th Ave SE
62 - 12th Ave NW
ChatResponder
Represents the bot and contains the logic for how the bot responds to an invitation
to chat.
Discussion The chatResponder class extends the Contract class. It is the only required element
used to define a bot. It represents a connection to a persona and handles all the
message between users and the bot.
When launching a bot, the ChatResponder requires specification of an agent
descriptor. For all bots, this is in the form:
/cloudname/persona/username
For example:
/imps.telco.com/persona/trivia@telco.com
ChatState
Maintains the chat session for a bot.
Discussion The chatState class is optional. It is used when the bot requires maintaining state
information for multiple users, such as when a bot maintains a game score.
ChatUser
Maintains information on a user in a particular chat. A user may have one of these
pr chat.
Discussion Bots can chat with a number of users. The chatUser class tracks the user
information, such as their display name, if they are connected, and so on.