Instant Messaging Adapter Suite
The Instant Messaging Adapter Suite enables uses an open standard instant messaging protocol, such as XMPP (which works with Jabber® instant messaging), to interact with Sterling B2B Integrator.
With the Instant Messaging Adapter Suite, Sterling B2B Integrator can initiate instant messages to alert you of issues needing prompt attention. You can then act on the information, including initiating commands in Sterling B2B Integrator and receiving the results of those commands within the context of the instant message (IM) session.
- IM user – User receiving the IM notification initiated by the Instant Messaging Adapter Suite
- Sterling B2B Integrator IM user – IM user account representing Sterling B2B Integrator
The following table provides an overview of the Instant Messaging (IM) adapter suite:
System name | IM Adapter Suite |
---|---|
System names | The IM Adapter Suite includes services having the
following system names:
|
Graphical Process Modeler (GPM) categories | All Services, Messaging > Instant Messaging Note: The
IMGrammarLoader service is in the All Services category only.
|
Description | The IM Adapter Suite enables you to carry on an IM session with Sterling B2B Integrator as if the system were another IM user. You can configure multiple Sterling B2B Integrator IM users. Using the IM Adapter Suite, you can send commands to Sterling B2B Integrator, and receive the results of those commands in your IM display. You can pass files to and from Sterling B2B Integrator using IM. To facilitate this, you define all of the commands you will use in a grammar file. The commands in the grammar file correlate to business processes that you create. You can configure the business process running the IM session to loop back after a command executes so that another command can be run. Recommended strategy is to define a command to end the session and make the command part of the IM business process. Sterling B2B Integrator includes a default IM business process, grammar file, and business processes representing the commands in the grammar file. You can edit or copy any of these according to your needs. |
Business usage | Enables Sterling B2B Integrator to alert a specified user of a certain event using instant messaging, and enables the alerted user to perform simple queries as to the health and status of the Sterling B2B Integrator system through the IM session. |
Usage example | You configure the IM Adapter Suite services so that when Sterling B2B Integrator receives an order from a top priority customer, the IM adapter suite will notify the appropriate user by initiating an instant message. The system receives such an order. The IM Adapter Suite notifies the user of the order. |
Preconfigured? | IM Adapter Suite services have the following service
configurations provided with Sterling B2B Integrator, however,
some require further configuration to meet your needs, as indicated:
|
Requires third-party files? | Two .jar files are required:
|
Platform availability | All supported Sterling B2B Integrator platforms |
Related services | The IM Adapter Suite includes the following services:
Note: An IMReceiveMessage is not required to handle incoming
attachments. Any time a user sends an attachment during an IM session,
the IM adapter launches the IM_RECEIVE_FILE business process to handle
the attachment.
|
Related services (continued) | Note: Looping capability and business process launching
and monitoring take place in the business process. The IM Command
Processor only interprets the supplied command. The IMCommandProcessorLoop
Business Process handles the looping mechanism and business process
execution.
|
Application requirements |
|
Initiates business processes? | No |
Invocation | To enable command initiation using IM with the
IM CommandProcessor, you must:
|
Business process context considerations | IM Adapter Suite services rely upon session state stored in the business process. For that reason, the services must be used in conjunction with each other. IMBeginSession must always precede calls to IMBeginChat, and IMBeginChat must precede IMSendMessage and IMReceiveMessage. For an illustration, see Business Process Example 1 – Simple and Business Process Example 2 – Complex. |
Returned status values | When errors occur, the business processes halt. The status report will specify, with as much detail as available, the failure point. This is vital because there are many process level state variables passed between services that are not manipulated by the user. |
Restrictions | The system always initiates the IM session. Under no circumstances will Sterling B2B Integrator respond to a session initiated by the IM user. |
Persistence level | Recommended persistence level is None. |
Testing considerations | You can create a business process similar to the first example to use for testing. See Business Process Example 1 – Simple. |
Implementing the IM Adapter Suite
- With your IM provider, create a user ID representing Sterling B2B Integrator.
- Log in to your IM application, and add the ID to your messenger list
- Log out and then log on as the new Sterling B2B Integrator ID and add your personal user ID or the ID of another IM user to the messenger list of the Sterling B2B Integrator user.
- Log out of IM.
- Obtain the third-party XMPP client libraries by downloading the smack_3_0_4.zip file from Ignite Realtime.
- Uncompress the .zip file to your hard drive and note the location of the files.
- Download the most recent version of the ymsg_code_jars_v0_6.zip file from jymsg.
- Uncompress the .zip file to your hard drive and note the location of the files.
- Shut down the application.
- Unload the following jar files from steps 6 and 8:
- smack.jar
- ymsg_network_v0_6.jar
- ymsg_support_v0_6.jar
To unload the files, use install3rdParty.sh (or install3rdParty.cmd for Windows). The following examples show the commands; you must change the versions and user directories according to your needs:
./install3rdParty.sh ymsg_network 0_6 -j /
unzip directory/ymsg_network_v0_6.jar
./install3rdParty.sh ymsg_support 0_6 -j /
unzip directory/ymsg_support_v0_6.jar
./install3rdParty.sh smack 3_0 -j /
unzip directory/smack.jar
- Restart the application.
- Do you need the adapter to accept to commands from the IM user
during sessions?
- If Yes, define the commands in the grammar file. For information, see Default Grammar File .
- If No, skip to step 15.
- In Sterling B2B Integrator, edit the IMGrammarLoader configuration of the File System adapter. In the attachFile field, enter the location and name of the grammar file to use. This is the file you modified in step 12.
- In the GPM, configure the Command Processor service. For information, see Configuring the IM Command Processor Service.
- In Sterling B2B Integrator, create a configuration of the IM Begin Session service. Enter the IM user ID and password to represent Sterling B2B Integrator in IM sessions. For information, see Configuring the IM Begin Session Service.
- In Sterling B2B Integrator or in the GPM, edit the IM Begin Chat service configuration. Enter the IM user ID to connect with during the session (this is your ID or the IM user ID of another user that Sterling B2B Integrator will notify). You can enter multiple IDs by separating them with commas. For example, mychatid, yourchatid, thirdchatid. For information, see Configuring the IM Begin Chat Service.
- Use the IM services in a business process.
Default Grammar File
The provided grammar file for the IM adapter is an XML-format file that describes the behavior of the IM Command Processor service. The file, grammar.xml, is located in the data/xmpp directory of your Sterling B2B Integrator installation directory.
You can copy and modify this file as necessary in order to define the commands to be used. This enables the Command Processor to match the correct business processes to commands received in an IM session. If you use a different grammar file or change the location of the file, you must modify the IMCommandProcessor business process to reflect the filename or path change.
The contents of the default grammar file are as follows:
<grammar>
<pattern value="get [a-z]* log" result="IM_GET_LOG"/>
<pattern value="show [a-z]*" result="IM_SHOW_COMMAND"/>
<pattern value="bye" result="IM_EXIT"/>
<pattern value="default" result="IM_DEFAULT"/>
</grammar>
- Root – This is always ‘grammar.'
- Pattern – A repeatable tag comprised of two required attributes, value and result.
This pairing describes the action taken when the system receives a
given command.
The content of ‘value' is a Perl5 type regular expression that will match on command phrases. The content of ‘result' is the business process to execute when the value is matched. In the following example, this is illustrated in the first pattern:
<pattern value="get [a-z]* log" result="IM_GET_LOG"/>
The match will execute the IM_GET_LOG business process when it receives a command of:
get<space><any combination of letters><space>log
Note: The last pattern in the grammar file, with a value of default, is required in every grammar file. This is the pattern the Command Processor uses when it finds no matching command.
Example Commands
The following table provides examples of commands that will execute the IM_GET_LOG business process and commands that will not:
Valid command | Invalid command |
---|---|
get noapp log | get the big log |
get all log | get all logs |
get myspecial log | get log |
Configuring Instant Messaging Adapter Suite Services
Several of the IM Adapter Suite services require configuration.
Configuring the IM Begin Session Service
To configure the IM Begin Session service, you must specify field settings in Sterling B2B Integrator:
Field | Description |
---|---|
Name | Unique and meaningful name for the service configuration. Required. |
Description | Meaningful description for the service configuration, for reference purposes. Required. |
Select a Group | Select one of the options:
|
Protocol | IM provider to use for chat sessions. Select XMPP or Yahoo.
Default is XMPP. Required. Note: Yahoo IM is
not supported at this time.
|
Username | IM user ID name to represent Sterling B2B Integrator use during IM sessions. Required. |
Password | IM password for the Sterling B2B Integrator user ID. Optional. |
Idle Timeout | Length of time in milliseconds to wait for a response from the IM user before halting the process and ending the chat session. Optional. |
Session Timeout | Length of time in minutes to allow for the entire session to run before halting the process and ending the chat session. Optional. |
XMPP Server Name | Name of the server of the chat service you are using. Obtain this name from your IM provider. Required. |
XMPP Server Port | Port number for IM communications. Obtain the port
number from your IM provider. Required. Note: The default port for
XMPP with Jabber is 5222.
|
XMPP Service Name | XMPP service name as defined in the XMPP server if different from the XMPP Server Name value. If omitted, the adapter uses the XMPP Server Name. Optional. |
Configuring the IM Begin Chat Service
To configure the IM Begin Chat service, you must specify field settings in the GPM:
Field | Description |
---|---|
Config | Name of the service configuration. Required. |
IMChatTo | Name of the IM user for Sterling B2B Integrator to have a chat session with, or a comma delimited list of IM user IDs, for an IM conference. Required. |
Configuring the IM Send Message Service
To configure the IM Send Message service, you must specify field settings in the GPM:
Field | Description |
---|---|
Config | Name of the service configuration. Required. |
IMBodyAsAttachment | Valid values are True and False. When the value is set to True, the system sends the primary document body as an attachment during a SendMessage invocation. When the value is set to False, the system chunks the primary document into multiple messages and sends them to the user. The chunk size is determined by the maximum message size for the IM provider. Use this field only when IMUseBody is set to True. Optional. |
IMMessage | Message to display on the screen of the IM user. Use this field if you want to specify exactly what the notification will say when Sterling B2B Integrator initiates a chat session. Optional. |
IMUseBody | Valid values are True and False. When the value is set to True, the system sends the body of the primary document to the user according to the mode specified in the IMBodyAsAttachment field. Optional. |
Configuring the IM Grammar Loader Service
To configure the IM Grammar Loader service, you must specify field settings in the GPM:
Field | Description |
---|---|
Config | Name of the service configuration. Required. |
attachFile | Name of the grammar file for the adapter to reference during the session. Required. |
Configuring the IM Command Processor Service
To configure the IM Command Processor service, you must specify field settings in the GPM:
Field | Description |
---|---|
Config | Name of the service configuration. Required. |
IMCommand | Specifies the command for the command processor to match against. Used in conjunction with IMReceiveMessage, this parameter automatically populates according to the message received from the user. Because this is a system-populated value, do not enter a value. Entering a value will force the service to use your supplied value regardless of the actual command received from the IM user. |
Instant Messaging Adapter Suite Business Processes
The following table describes the predefined business processes associated with the IM Adapter Suite:
BPML Name | Usage Description |
---|---|
IM_DEFAULT.bpml | In the event that the adapter receives a command for which there is no match in the grammar file, this is the default process that runs, to indicate that the system does not understand the command. |
IM_EXIT.bpml | Closes the chat session when the IM user enters an exit command. |
IM_GET_LOG.bpml | Example business process that returns a Sterling B2B Integrator log file. |
IM_SHOW_COMMAND.bpml | Lists all commands in the grammar file. |
IMCommandProcessLoop.bpml | Example process you can configure to run the looping process for proper handling of user-supplied commands within a chat session. |
Example Business Process Models
This section contains two examples, a simple connect-chat-disconnect business process that you can build and use to test your IM connections, and a more complex example.
Business Process Example 1 – Simple
- IM Begin Session service – This service contains the Sterling B2B Integrator IM user ID and password used to log in to IM, and sets basic session parameters. The system logs into IM using the specified ID and password.
- IM Begin Chat service – This service contains the IM user ID (or comma-delimited list of IDs) the system communicates to when initiating an IM session. The system starts a chat session with the IDs specified.
- IM End Chat service – When the IM user closes the chat session, this service ends the chat session.
- IM End Session service – When the chat session has ended, this service signs the Sterling B2B Integrator user ID out of the IM provider application.
The following figure shows the business process in the Graphical Process Modeler:
The BPML for the business process would be similar to the following example:
<process name="default">
<sequence>
<operation name="IM Begin Session Service">
<participant name="IMBeginSession"/>
<output message="IMBeginSessionInputMessage">
<assign to="." from="*"></assign>
</output>
<input message="inmsg">
<assign to="." from="*"></assign>
</input>
</operation>
<operation name="IM Begin Chat Service">
<participant name="IMBeginChat_Instance"/>
<output message="IMBeginChatInputMessage">
<assign to="IMChatTo">myuserid,TomR_Billing,WarehouseUser1</assign>
<assign to="." from="*"></assign>
</output>
<input message="inmsg">
<assign to="." from="*"></assign>
</input>
</operation>
<operation name="IM End Chat Service">
<participant name="IMEndChat_Instance"/>
<output message="IMEndChatInputMessage">
<assign to="." from="*"></assign>
</output>
<input message="inmsg">
<assign to="." from="*"></assign>
</input>
</operation>
<operation name="IM End Session Service">
<participant name="IMEndSession_Instance"/>
<output message="IMEndSessionInputMessage">
<assign to="." from="*"></assign>
</output>
<input message="inmsg">
<assign to="." from="*"></assign>
</input>
</operation>
</sequence>
</process>
Business Process Example 2 – Complex
This example corresponds with the sample business process IMCommandProcessLoop.bp provided with your installation of Sterling B2B Integrator. To use the provided process model and this example, use a configured instance of the IM Begin Session service to call the process.
- The session begins and you see a message in your IM window.
- You type in a command, which the system evaluates at the decision point in the business process model according to the rule, illustrated as the loopRule (your process model may use different labels).
- The grammar file is loaded and the IM Command Processor service attempts to associate the
command with a match in the grammar file:
- If the IM Command Processor service finds a match, it starts the corresponding business process. You receive any output of the business process in your IM window.
- If the IM Command Processor service does not find a match, it sends you an IM message, saying that the match was not found.
- The next step depends on the command you sent in step 2:
- If you sent an end session command, the IM Command Processor ends the session and exits the business process.
- If you sent a command other than to end the session, the IM Command Processor restarts the command loop and the business process waits for another command.
The following figure shows a similar business process model in the GPM. Because of the length of the business process, the figure is broken down into three separate sections here for ease of viewing:
Section 1