REST example

This example shows how EngageOne Converse can use the EngageOne Communicate API endpoints to trigger email sending in Communicate. In particular to email the user a transcript of their conversation with the bot.

In Converse, there are three actions and one message interaction.

Example of action interactions in a Converse bot

Note: See here for details of the Communicate API.

Get Chat History action

In Converse, this action configures the bot to make an HTML transcript of the messages sent between the bot and the user available in the current session (the Converse context object):
context.chatHistory = system.getChatHistory();

In Converse, a Set Variable action type is used for this.

EOCM Token action

In Converse, this action configures the bot to request a machine to machine authentication token from Communicate.

Action type REST
Endpoint https://usersapi.communicate.ces.pitneycloud.com/authenticate
Method POST
Body Pass the credentials for your Communicate account. You obtain these from the Company Management page in Communicate. For example:
{
  "client_id": "1234567@communicate.pb.com",
  "secret": "secret",
  "customer_id": "customerID"
}
Variable Name Stores the authorization token returned by Communicate in the session.

EOCM Send Email action

In Converse, this action configures the bot to trigger Communicate to send an email to the user set in the body of the request.

Action type REST
Endpoint https://api.us-east-1.communicate.ces.pitneycloud.com/campaigns/ mycampaign/transactional
Method POST
Authorization The authorization token acquired from Communicate. For example:
Bearer {my-variable}
Headers Your Communicate customer ID:
  • Header Name is always PB-Customer-Id
  • Value is your customer ID
Body The data required by the communication in Communicate. The data must conform to the schema of the data source selected for the communication. For example:
{
    "communication": "Thanks",
    "dataset": [{
        "name": "Henry",
        "email": "an-email-address",
        "chatHistory": "{{chatHistory}}"
    }],
    "email_json_path": "$[*].email",
    "sender": "eocommunicate-dev@pb.com",
    "subject": "Thanks for contacting us today",
    "ignore_missing_fields": true,
    "project": "my-project"
}