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.

For the purposes of this documentation, the following terms are defined as follows:
  • 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:
  • IMBeginSession
  • IMBeginChat
  • IMSendMessage
  • IMReceiveMessage
  • IMGrammarLoader
  • IMCommandProcessor
  • IMEndChat
  • IMEndSession
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:
  • IMBeginChat_Instance (requires further configuration)
  • IMGrammarLoader (requires further configuration)
  • IMSendMessage_Instance
  • IMReceiveMessage_Instance
  • IMEndChat_Instance
  • IMEndSession_Instance
  • IMCommandProcessor_Instance
  • IM_FILE_EXTRACT
For information about configuring the services, see Configuring Instant Messaging Adapter Suite Services.
Requires third-party files? Two .jar files are required:
  • jymsg
  • smack.jar, available from Ignite Realtime
Use the install3rdparty.sh or install3rdparty.cmd script to install the jar files. For information, see Implementing the IM Adapter Suite. To download the XMPP client libraries, go to Ignite Realtime and download the smack_3_0_4.zip file. For instructions, see Implementing the IM Adapter Suite.
Platform availability All supported Sterling B2B Integrator platforms
Related services The IM Adapter Suite includes the following services:
  • IM Begin Session – Initiates the IM session as the Sterling B2B Integrator IM user ID.
  • IM Begin Chat – Calls the targeted IM user to have the IM session with.
  • IM Send Message – Sends messages to the IM user. May send attachments to the IM user.
  • IM Receive Message – Receives messages from the IM user. The system uses this service to pause and wait for an interactive message from the user. The receive message service waits for a message until the idle timeout expires.
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.
  • IM Grammar Loader (File System adapter) – Loads the IM command syntax from the grammar file. The commands in the grammar file define the commands that the IM Command Processor will recognize.
  • IM Command Processor – Receives input from the IM Receive Message service and interprets a received command according to the supplied grammar. When a command matches a grammar file entry, the Processor passes the appropriate business process name to invoke the process.

    The value matched from command to grammar file becomes the parameter WFD_NAME in the business process, and a parsed version of the command becomes the primary document. Therefore, input to the IMCommandProcessor is the grammar XML as the primary document, and IMCommand as a process data parameter, and the output of the IMCommandProcessor is the parsed command as the primary document and the matching value as WFD_NAME.

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.
  • IM End Chat – Terminates the IM session visual display.
  • IM End Session – Terminates the IM session communications.
Application requirements
  • Create a user account in the target instant messaging application on behalf of the Sterling B2B Integrator system. This is the IM name you provide when configuring the IMBeginSession.
  • Establish the user account in the target instant messaging application before running the SendMessage service.
Initiates business processes? No
Invocation To enable command initiation using IM with the IM CommandProcessor, you must:
  • Write the corresponding business process for the commands
  • Define the necessary commands in the IM grammar file
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

To implement the IM Adapter Suite, complete the following tasks:
  1. With your IM provider, create a user ID representing Sterling B2B Integrator.
  2. Log in to your IM application, and add the ID to your messenger list
  3. 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.
  4. Log out of IM.
  5. Obtain the third-party XMPP client libraries by downloading the smack_3_0_4.zip file from Ignite Realtime.
  6. Uncompress the .zip file to your hard drive and note the location of the files.
  7. Download the most recent version of the ymsg_code_jars_v0_6.zip file from jymsg.
  8. Uncompress the .zip file to your hard drive and note the location of the files.
  9. Shut down the application.
  10. 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
  11. Restart the application.
  12. 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.
  13. 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.
  14. In the GPM, configure the Command Processor service. For information, see Configuring the IM Command Processor Service.
  15. 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.
  16. 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.
  17. 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> 
The grammar file contains two tag types:
  • 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:
  • None – You do not want to include this configuration in a group at this time.
  • Create New Group – You can enter a name for a new group in this field, which will then be created along with this configuration.
  • Select Group – If you have already created one or more groups for this service type, they display in the list. Select a group from the list.
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

Refer to the figure following the steps as you read the process steps. This example business process progresses through IM Adapter Suite services as follows:
  1. 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.
  2. 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.
  3. IM End Chat service – When the IM user closes the chat session, this service ends the chat session.
  4. 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.

Refer to the figures following the steps as you read the process steps. This example business process progresses through IM Adapter Suite services as follows:
  1. The session begins and you see a message in your IM window.
  2. 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).
  3. 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.
  4. 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

Section 2

Section 3