Stella Platform Documentation

Stella Platform Documentation

  • Docs
  • API
  • FAQ
  • Languages iconEnglish
    • 中文

›REST API

Get Started

  • Introduction

Context Reference

  • Message Event
  • Member
  • Channel
  • Integrations
  • Agenda Meta
  • Group
  • Methods

REST API

  • Introduction and Prerequisite
  • Errors
  • Meta Object
  • API Methods

API Methods

sendResponse

Sending Response on behalf of your chatbot to a specific user.

Request URI

Single response
POST  /sendResponse

Multiple responses
POST  /sendResponses

Sample Request

Single response

curl -X POST \ 'https://bot.stella.sanuker.com/v2.1/sendResponse?accessToken={ACCESS_TOKEN}' \
  -H 'Content-Type: application/json' \
  -d '{
      "channelId": "aChannelId",
      "recipientId": "85293333333",
      "memberId": "someMemberId",
      "response": {
          type: "TEXT",
          text: "Hello World"
        }
      }'
Multiple responses
curl -X POST \ 'https://bot.stella.sanuker.com/v2.1/sendResponses?accessToken={ACCESS_TOKEN}' \
  -H 'Content-Type: application/json' \
  -d '{
      "channelId": "aChannelId",
      "fbUserRef": "some-user-ref",
      "memberId": "someMemberId",
      "responses": [
          {
            type: "TEXT",
            text: "Hello"
          },
          {
            type: "TEXT",
            text: "World"
          }
          ...
        ]
      }'

Properties

PropertyTypeDescription
channelIdStringChannel ID in stella
fbUserRefStringOptional
User-ref used in Facebook checkbox plugin
memberIdStringEither memberId or recipientId
Member ID in stella.
recipientIdStringEither memberId or recipientId
External ID. E.g. PSID on Facebook, phone number / groupId on WhatsApp, open_id on Wechat, etc.
responseObjectEither response or responses
The data you wish to send as a response. For the example above, we are sending a text response on Facebook, which you can take reference in Facebook Message Types. You can also check the message types of the corresponding platforms to construct the response object.
responsesArray[Object]Either response or responses
The data you wish to send as responses. For the example above, we are sending an array of text responses on Facebook, which you can take reference in Facebook Message Types. You can also check the message types of the corresponding platforms to construct the response object.

Response

The request returns a JSON string containing a “ok” flag indicating if the response/responses are successfully sent or not. In a successful case, an field “success” with truthy value will be returned. Otherwise, an optional “err” object if an error is encountered.

{
  "ok": 1,
  "member": "member-id",
  "sendResult": {
    "ok": 1,
    "member": "member-id",
    "result": [
      {
        "result": {
          "message_id": "m_U0EmmN476hlyPr-0iH2cXMcrTLJ5HeVUQjzqok8vkkF8wnJpPkagYbXU5hr0bXWHM5PPYjgd9RWG10K0oujeHQ"
        },
        "messageEvent": {
          "from": "some-page-id",
          "to": "fb-user-ref",
          "data": {
            "text": "Hello World"
          },
          "type": "TEXT",
          "timestamp": 1583292367324,
          "messageId": "m_U0EmmN476hlyPr-0iH2cXMcrTLJ5HeVUQjzqok8vkkF8wnJpPkagYbXU5hr0bXWHM5PPYjgd9RWG10K0oujeHQ"
        }
      }
    ]
  }
}

Response properties

PropertyTypeDescription
errStringError message
err_codeIntegerError Code
memberStringMember ID in stella
okInteger1 or 0, representing success and error accordingly
sendResultObjectPlease see the description below (sendResult properties)

sendResult properties

PropertyTypeDescription
okInteger1 or 0, representing success and error accordingly
memberStringMember ID in stella
resultArray[Object]Please see the description below (sendResult properties)

result properties

PropertyTypeDescription
messageEventObjectNormalised message event object
resultArray[Object]Raw result object

Error Response

You would encounter an error “Phone Number Invalid” if the phone number you submitted is invalid. (i.e. not a valid phone number or the phone number is not a whatsApp number)

{
 "ok": 0,
 "err_code": 108,
 "err": "Either memberId or recipientId or fbUserRef is required."
}

redirectMemberToNode

Redirecting a member to a specific node in tree and executing all or partial components of the node. This is useful for performing complex operations on a member and keeping all the bot logic in the tree instead of hard-coding in an api.

If memberId is not provided, the system would search for a member with the provided recipientId or fbUserRef, if none is found and the provided channel is a Whatsapp channel, the system would try to create a member with the recipientId and perform the redirection.

Request URI

POST  /redirectMemberToNode

Sample Request

curl - X POST \ 'https://bot.stella.sanuker.com/v2.1/redirectMemberToNode?accessToken=some-access-token' \
-H 'Content-Type: application/json' \
-d '{
      "channelId": "aChannelId",
      "recipientId": "85293333333",
      "fbUserRef": "some-user-ref",
      "memberId": "someMemberId",
      "meta": {
        "orderId": "someOrderId",
        "name": "hello"
        },
      "redirect": {
        "nodeCompositeId": "someNodeCompositeId",
        "tree": "someTreeId",
        "runPreAction": true,
        "runPostAction": true,
        "sendResponse": true
      }
    }'

Properties

PropertyTypeDescription
channelIdStringChannel ID in stella
fbUserRefStringOptional
User-ref used in Facebook checkbox plugin
memberIdStringEither memberId or recipientId
Member ID in stella.
recipientIdStringEither memberId or recipientId
External ID. E.g. PSID on Facebook, phone number / groupId on WhatsApp, open_id on Wechat, etc.
metaObjectOptional
Meta object provided to the node.
redirectObjectPlease see the description below (redirect properties)

redirect Properties

PropertyTypeDescription
nodeCompositeIdStringComposite ID of the node redirecting to
treeStringTree ID of the node redirecting to
runPreActionbooleanFor fine tuning whether preActions should be run after redirect
runPostActionbooleanFor fine tuning whether postActions should be run after redirect
sendResponsebooleanFor fine tuning whether responses should be sent after redirect

Response

The request returns a JSON string containing a “ok” flag indicating if the member is successfully redirected to node, a “member” field with the stella memberId, and an optional “error” object if an error is encountered.

{
  "ok": 1,
  "member": "member-id",
  "sendResults": [
    {
      "ok": 1,
      "member": "member-id",
      "result": [
        {
          "result": {
            "message_id": "m_4a7-MjU8W-k7K1Ws5_hOP8crTLJ5HeVUQjzqok8vkkELEM4sWFpVAAhK4Yz_ELl-eSjueSVEFSr137J1XMpBOQ"
          },
          "messageEvent": {
            "from": "some-page-id",
            "to": "fb-user-ref",
            "data": {
              "text": "Redirecting a member to the test node",
              "transform": ""
            },
            "type": "TEXT",
            "timestamp": 1583291866627,
            "messageId": "m_4a7-MjU8W-k7K1Ws5_hOP8crTLJ5HeVUQjzqok8vkkELEM4sWFpVAAhK4Yz_ELl-eSjueSVEFSr137J1XMpBOQ"
          }
        }
      ]
    }
  ]
}

Response properties

PropertyTypeDescription
errStringError message
err_codeIntegerError Code
memberStringMember ID in stella
okInteger1 or 0, representing success and error accordingly
sendResultObjectArray of sendResults from each node that has been redirected. Please see the description below (sendResult properties)

sendResult properties

PropertyTypeDescription
okInteger1 or 0, representing success and error accordingly
memberStringMember ID in stella
resultArray[Object]Please see the description below (sendResult properties)

result properties

PropertyTypeDescription
messageEventObjectNormalised message event object
resultArray[Object]Raw result object

Error Response

You would encounter an error “Phone Number Invalid” if the phone number you submitted is invalid. (i.e. not a valid phone number or the phone number is not a whatsApp number)

{
 "ok": 0,
 "err_code": 108,
 "err": "Either memberId or recipientId or fbUserRef is required."
}
← Meta Object
  • sendResponse
    • Request URI
    • Sample Request
    • Properties
    • Response
    • Error Response
  • redirectMemberToNode
    • Request URI
    • Sample Request
    • Properties
    • redirect Properties
    • Response
    • Error Response
Stella Platform Documentation
Docs
Get StartedBest PracticesAPI Reference
Community
FAQUser ShowcaseChat with Us
Copyright © 2020 Sanuker Inc. Limited